메인 메뉴의 팝업 메뉴가 펼쳐질 때 마다 발생 // ?
CheckMenuItem(), CheckMenuRadioItem(), EnableMenuItem()
c.f. TrackPopupMenu()
on WM_INITMENUPOPUP
WM_INITMENUPOPUP is sent every time a menu is about to be displayed. This
means all drop-down menus from the menu bar, context menus (from right
mouse click), cascading sub-menues, and of course the system menu that
pops up when you click the little window icon. The message gives you the
handle of the menu and even says if it's the system menu.
Now that seems pretty straightforward and hard to mess up.
By contrast, WM_INITMENU is sent only once when a menu loop is entered.
This is usually when the menu bar is clicked. You can even click in a
blank spot on the menu bar and receive a WM_INITMENU message. Normally
you will click something like "File" at which point you get WM_INITMENU(handle=menu bar) followed by WM_INITMENUPOPUP(handle="file"
menu).
Unsurprisingly, when you right-click to pop up a context menu you will get
both WM_INITMENU(handle=context menu) followed by WM_INITMENUPOPUP(handle=context menu). So far so good.
The system menu is where things start to get weird. One might think it
would work like a context menu. But instead it generates WM_INITMENU(handle = menu bar) followed by WM_INITMENUPOPUP(handle=system
menu). Well...most of the time. If the window doesn't have a menu bar
then the handle from WM_INITMENU refers to something mysterious. This
also is true if the window is minimized and you right-click on the task
bar button.
WM_INITMENU seems pretty worthless to me. If the app used it to know when
to update menu items it would have to traverse the whole menu tree since
it couldn't know which drop-down or sub-menu would be called up. And in
the case of the system menu, all bets are off. Might as well check the
system menu every time (assuming you have something to do with the system
menu). Is this some kind of legacy message that hasn't translated well
into the Win32 world?
WM_INITMENUPOPUP would appear to be the message of choice for updating
menus as they are needed.
on
WM_CONTEXTMENU // (플로팅 )팝업 메뉴
ScreenToClient()
TrackPopupMenu()
on WM_MENUSELECT
on WM_HELP
on WM_MENURBUTTONUP
TrackPopupMenuEx() // TPM_RECURSE
IDR_MENU1 MENU DISCARDABLE
BEGIN
POPUP "보기"
BEGIN
MENUITEM "항상 위", ID_VIEW_TOP
MENUITEM SEPARATOR
MENUITEM "텍스트 보기", ID_VIEW_TEXT
MENUITEM "이미지 보기", ID_VIEW_IMAGE
MENUITEM "헥사 보기", ID_VIEW_HEXA
MENUITEM SEPARATOR
MENUITEM "이미지 미리 보기", ID_VIEW_PRE
MENUITEM SEPARATOR
MENUITEM "Add", ID_MENU_ADD
MENUITEM "Delete", ID_MENU_DELETE
MENUITEM SEPARATOR
END
END
IDR_MENU2 MENU DISCARDABLE
BEGIN
POPUP "dummy"
BEGIN
MENUITEM "Red", ID_POPUP_RED
MENUITEM "Green", ID_POPUP_GREEN
MENUITEM "Blue", ID_POPUP_BLUE
END
END