question

youki avatar image
0 Votes"
youki asked youki edited

Context menu item selection color height to small

Hello,
how can i change the height?

(The blue color height is to small by default?!)

199986-image.png

Source: http://www.cplusplus.com/forum/windows/106004/

 HMENU hPopupMenu = CreatePopupMenu();
  HMENU hSubMenuGame = CreatePopupMenu();  // Create submenu for Game
  HMENU hSubMenuPlay = CreatePopupMenu();  // submenu for 'play'
    
  // Add items to submenus
  InsertMenu(hSubMenuPlay, 0, MF_BYPOSITION | MF_STRING, 1, _T("Start"));
  InsertMenu(hSubMenuPlay, 0, MF_BYPOSITION | MF_STRING, 2, _T("Stop"));
  InsertMenu(hSubMenuGame, 0, MF_BYPOSITION | MF_STRING, 3, _T("Start"));
  InsertMenu(hSubMenuGame, 0, MF_BYPOSITION | MF_STRING, 4, _T("Stop"));
    
  //Append submenu 'play' to popup menu
  AppendMenu(hPopupMenu, MF_POPUP | MF_STRING, (UINT)hSubMenuGame, _T("Game"));
  //Append menu item 'exit'
  AppendMenu(hPopupMenu, MF_BYPOSITION | MF_STRING, 1245, _T("Exit"));
  // Append submenu 'play'
  AppendMenu(hPopupMenu, MF_POPUP | MF_STRING, (UINT)hSubMenuGame, _T("Play"));
    
    
  SetForegroundWindow(hWnd);
  TrackPopupMenu(hPopupMenu, TPM_BOTTOMALIGN | TPM_LEFTALIGN, 0, 0, 0, hWnd, NULL);
  DestroyMenu(hPopupMenu);


windows-apic++
image.png (3.9 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Do nothing - wait till MS decide to change the UI (for the better) again :)

1 Vote 1 ·

???

Xaml based UIs are a cool concept, aren’t they?! But there is no tray icon and it can‘t be running in the background, so I want to run the WinApi app in the background and add the WinUI/UWP UI as a component. At least that‘s how I imagine it. Took a few days to research how I could do it.

Do I have to custom paint the context menu??

0 Votes 0 ·
Castorix31 avatar image
1 Vote"
Castorix31 answered Castorix31 edited

Use an Owner-Drawn Menu and change the size in WM_MEASUREITEM

Quick test (Windows 10 21H1) :

200119-odmenu.gif 200151-odmenu2.gif



odmenu.gif (35.0 KiB)
odmenu2.gif (55.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JunjieZhu-MSFT avatar image
0 Votes"
JunjieZhu-MSFT answered JunjieZhu-MSFT edited

Hello, @youki
Welcome to Microsoft Q&A!

In the win32 desktop application, By default, the height of the selected blue part is the same as the system default height.
You can refer to this sample: Create Owner-Drawn Menu sample.

Thank you.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

youki avatar image
0 Votes"
youki answered youki edited

Since i'm on Windows 11, it's a litte bit confusing. Will check that later on Windows 10 but i just compare it with other applications and now i've seen it in Teams for private usage, school & work and Defender, sigh. At first it looks weird but the default should be ok (?!).

All on Windows 11:

201438-image.png

201477-image.png

Defender:

201534-image.png



image.png (6.8 KiB)
image.png (6.7 KiB)
image.png (3.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.