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

MenuTipp

jaeger0
Principiante
865 Vistas
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 Respuestas
ZlamalJakub
Nuevo Colaborador III
865 Vistas

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

anthonyrichards
Nuevo Colaborador III
865 Vistas
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.
jaeger0
Principiante
865 Vistas
Thanks that works great !!
Responder