Add item in system menu...

Just starting out? Need help? Post your questions and find answers here.
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Add item in system menu...

Post 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... :idea:

If anybody can help, thks in advance.

Regards,
WW
Beware of the man who has the solution before he understands the problem...
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

The forum search feature is your friend :wink: : http://www.purebasic.fr/english/viewtop ... ystem+menu
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Post 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
Beware of the man who has the solution before he understands the problem...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post 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..
Post Reply