How do I check if a menu item has been clicked in another pr

Just starting out? Need help? Post your questions and find answers here.
coderchris
New User
New User
Posts: 5
Joined: Sun May 23, 2004 11:06 pm

How do I check if a menu item has been clicked in another pr

Post by coderchris »

Ok, I have made a dll with ALL pb menu functions. I open up a window and draw some menu items and thats works well. However, I have this function :

Code: Select all

ProcedureDLL menu_check()
  WaitWindowEvent()
  ProcedureReturn Str(EventMenuID())
EndProcedure
which is supposed to return if/which of the menu items are being pressed
but it wont work. Is there a way I can check if a menu item is bein pressed on this menu?
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

coderchris,

First you should return EventMenuID() and not Str(EventMenuID()) (which is a string address in fact).

But then you also should not use WaitWindowEvent() in a DLL procedure I guess, except if you are sure not to need it somewhere else in your program.

Here is an example using such a DLL you suggest (to be compared to the menu.pb source code available in the PureBasic's user's manual - Press F1 and select Menu library functions) :

Code: Select all

ProcedureDLL menu_check() 
  WaitWindowEvent() 
  ProcedureReturn EventMenuID()
EndProcedure 

If OpenWindow(0, 100, 150, 195, 260, #PB_Window_SystemMenu, "PureBasic - Menu")
  If CreateMenu(0, WindowID())
    MenuTitle("File")
      MenuItem( 1, "&Load...")
      MenuItem( 2, "Save")
      MenuItem( 3, "Save As...")
      MenuBar()
      OpenSubMenu("Recents")
        MenuItem( 5, "C:\Autoexec.bat")
        MenuItem( 6, "D:\Test.txt")
        OpenSubMenu("Even more !")
          MenuItem( 12, "Test")
        CloseSubMenu()
        MenuItem( 13, "C:\Ok.bat")
      CloseSubMenu()
      MenuBar()
      MenuItem( 7, "&Quit")
    MenuTitle("Edition")
      MenuItem( 8, "Cut")
      MenuItem( 9, "Copy")
      MenuItem(10, "Paste")
    MenuTitle("?")
      MenuItem(11, "About")
  EndIf
  DisableMenuItem(3, 1)
  DisableMenuItem(13, 1)
  Repeat
    menu_check = menu_check()
  Until menu_check = 7

EndIf

End
Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Post Reply