Page 1 of 1
Add item in system menu...
Posted: Mon Nov 20, 2006 1:00 pm
by Skipsy
Hi all,
I am looking for informations explaining how to add an item in a window
system menu.
I guess I have to manage this with a DLL but... what else...
If anybody can help, thks in advance.
Regards,
WW
Posted: Mon Nov 20, 2006 1:15 pm
by gnozal
Posted: Mon Nov 20, 2006 1:23 pm
by srod
Here's another one I just hacked up.
No dll required, you just use GetSystemMenu_() to make a copy of the window menu etc.
Code: Select all
If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
hwndmenu=GetSystemMenu_(WindowID(0),0)
minfo.MENUITEMINFO
minfo\cbSize=SizeOf(MENUITEMINFO)
minfo\fMask=#MIIM_TYPE
minfo\fType=#MFT_STRING
minfo\fState=#MFS_ENABLED
minfo\dwTypeData=@"Hello!"
InsertMenuItem_(hwndmenu, 0,1,minfo)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
You'll need a callback to intercept the #WM_SYSCOMMAND message etc.
Posted: Mon Nov 20, 2006 2:45 pm
by Skipsy
Hum... I did a search in the forum and found nothing. Probably not with
the correct keywords.
I am going to work with thes info.
Thks a lot.
WW
Posted: Mon Nov 20, 2006 6:12 pm
by netmaestro
#WM_SYSCOMMAND should be available in the main loop. Just check EventwParam() and EventlParam() to get its details.
[edit] Although, since
MSDN wrote:An application should return zero if it processes this message.
you're better off listening to srod and use a callback.
Posted: Mon Nov 20, 2006 8:17 pm
by Edwin Knoppert
Not perse.
This return value is only valid for the 'known' menuitems.
For example to abort the window closing you'll need to abort the procedure or return a value.
For custom menuitems Windows does not know what to do and skips these anyway.
If you can avoid the callback, do so..