Page 1 of 1

LoadMenu Function (+Example)

Posted: Mon Jan 02, 2006 9:22 pm
by Dr. Dri
For 2k6 i offer you a small sweet function ^^
It loads a resource menu and make it like a native PB menu

it means
-you can use it with any PB menu function
-your menu can be availlable in several languages

i also made a small example program ^^
File:1->Menu.zip
Image

Code: Select all

Procedure.l LoadMenu(Library.l, Index.l)
  Protected Load.l, LibraryID.l
  Protected *MenuID.Long, MenuID.l
  Static    ModuleID.l
  
  
  If ModuleID = #Null
    ModuleID = GetModuleHandle_(#Null)
  EndIf
  
  If Library = #PB_Default
    LibraryID = ModuleID
  Else
    If IsLibrary(Library)
      LibraryID = LibraryID(Library)
    EndIf
  EndIf
  
  If LibraryID
    MenuID = LoadMenu_(LibraryID, Index)
    
    CreateMenu( Index, WindowID() )
    *MenuID = IsMenu(Index)
    
    SetMenu_(WindowID(), MenuID)
    DestroyMenu_(*MenuID\l)
    *MenuID\l = MenuID
  EndIf
  
  ProcedureReturn MenuID
EndProcedure
Dri ;)