Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

MenuTipp

jaeger0
Beginner
862 Views
In my application I use a Menu, where I want to have a menu-tipp similar to tooltipps. If a user passes a Menu-item there should appear a message in the statusbar or somewhere, which explains the menu item. Is there a simple way to make such a menu-tipp ?
0 Kudos
3 Replies
ZlamalJakub
New Contributor III
862 Views

If you are using Win32 api, you should catch WM_MENUSELECT message in your window procedure. Get menu item info from this message it (load resource text for menu item) and then update status bar text.

This is part of my code called on WM_MENUSELECT message

recursive subroutine ShowMenuHelpInStatusBar(hWnd,wParam,lParam)
! called from mainwndproc when WM_MENUSELECT is called
! displays menu help on statusbar
use dfwina


integer*4 hWnd

integer*4 wParam,lParam
character*256 text

Item=INT4(LOWORD(wParam))
iFlags=INT4(HIWORD(wParam))

if ((iFlags == -1) .AND. (lParam == 0)) then ! menu has been closed
nStringID = 0
else
if (IAND(iFlags,MF_POPUP) /= 0) then ! Popup menu
nStringID = 0
else
if (IAND(iFlags,MF_SYSMENU) /=0) then ! System menu
nStringID = IDS_SYSMENU
else
if (Item /= 0) then
nStringID = Item ! String ID == Command ID
else
! menu item separator
nStringID = 0
endif
endif
endif
endif

! Load the string if we have an ID
if (nStringID/=0) then
iret=LoadString(GetWindowLong(hWnd,GWL_HINSTANCE),Item, text,len(text))
if (iret > 0) then
Text=Text(:iret)//""C
iret=SendMessage(hWndStatusBar,SB_SETTEXT,IOR(0,SBT_NOBORDERS),LOC(Text))
endif
endif
return
end

I put text to be shown in statusbar in to the "prompt" control when editing menu in resource editor, to be available through LoadString

I do not use QuickWin.

Jakub

0 Kudos
anthonyrichards
New Contributor III
862 Views
Note that to do this, you will have to sub-class your main window procedure in order to intercept the WM_MENUSELECT messages, and then pass all other messages on to the default window procedure.
0 Kudos
jaeger0
Beginner
862 Views
Thanks that works great !!
0 Kudos
Reply