Page 1 of 1

Combining a Ressource Menu Template with PB

Posted: Thu Jul 26, 2007 6:54 pm
by milan1612
I figured out how to use Ressource Menu Templates with PureBasic:

The RC Script I used:

Code: Select all

2001 MENU
BEGIN
  POPUP "&File"
  BEGIN
    MENUITEM "New", 6001
    MENUITEM "Open", 6002
    MENUITEM SEPARATOR
    MENUITEM "Exit", 6003
  END
  POPUP "&Edit"
  BEGIN
    MENUITEM "Undo", 6004
    MENUITEM "Redo", 6005
    MENUITEM SEPARATOR
    MENUITEM "Cut", 6006
    MENUITEM "Copy", 6007
    MENUITEM "Paste", 6008
    MENUITEM SEPARATOR
    MENUITEM "Select All", 6009
  END
  POPUP "Help"
  BEGIN
    MENUITEM "About", 6010
  END
END

Compile it with "Porc.exe" (in the PB Compilers Directory)

The code:

Code: Select all

Import "menu.res" ;the compiled RC Script
EndImport

OpenWindow(0, 0, 0, 350, 200, "Resource Menu Test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)

hMenu = LoadMenu_(GetModuleHandle_(0), 2001) ;Load the menu...
SetMenu_(WindowID(0), hMenu) ;...and attach it to your window

;You can use the PB Event System to determine events
;Use the IDs from your script
Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Menu
    Select EventMenu()
      Case 6001
        Debug "New"
      Case 6002
        Debug "Open"        
      Case 6003
        End
      Case 6004
        Debug "Undo"      
      Case 6005
        Debug "Redo"
      Case 6006
        Debug "Cut"
      Case 6007
        Debug "Copy"
      Case 6008
        Debug "Paste"
      Case 6009
        Debug "Select All"
      Case 6010
        Debug "About"                                                
    EndSelect
  EndIf
Until Event = #PB_Event_CloseWindow
There are many free Ressource Editors out there, you can use them
to create the templates.
Don't know if somebody finds this useful :?

Posted: Thu Jul 26, 2007 7:23 pm
by Edwin Knoppert
This way of preparing menus is part. useful icw TrackPopupMenu() API.

Posted: Thu Jul 26, 2007 7:31 pm
by milan1612
I use it because there is no easy Menu Editor for PB,
so I create RC Scripts with VisualStudio Express.

Posted: Thu Jul 26, 2007 7:33 pm
by Edwin Knoppert
Solid website you have..

Posted: Thu Jul 26, 2007 7:36 pm
by milan1612
Edwin Knoppert wrote:Solid website you have..
Thanks! It is simple HTML+CSS without any images. This makes it damn fast, 3 sec. with 56K 8)
But I need some more content, going to update it in the holidays.

Posted: Fri Jul 27, 2007 4:58 am
by NoahPhense
Edwin Knoppert wrote:Solid website you have..
Yeah I like one of his tags..

Code: Select all

Optimized for Firefox, I simply ignore IE s**t!
;)

- np

Posted: Fri Jul 27, 2007 7:11 am
by milan1612
:twisted:

Posted: Thu Jan 17, 2008 7:55 am
by superadnim
Hi guys, I was wondering... how one goes around using resource menus on a multi-language application?, would you just have multiple resources for the different languages?... sounds naughty :(

Any ideas?, I would like to use existent menu editors while still being able to dynamically change the language of my application.

Resources are cool but I can't get around this issue yet.

To anyone interested, I'm trying this editor as we speak: Resource Builder << looks very nice, although its 50 bucks for the standard version (any freeware options that are worth a try?).


Thanks.