Page 1 sur 1
Gestion des evenements sur les menus
Publié : mar. 22/nov./2005 9:48
par Droopy
Si je créé un menu + un CreateToolBar j'ai deux menus.
Comment savoir dans ma boucle d'évèment quel menu a généré l'évènement ?
Publié : mar. 22/nov./2005 9:59
par Chris
Essaye ça
Code : Tout sélectionner
If OpenWindow(0, 100, 200, 195, 260, #PB_Window_SystemMenu | #PB_Window_SizeGadget, "ToolBar example")
If CreateToolBar(0, WindowID())
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
ToolBarSeparator()
ToolBarStandardButton(3, #PB_ToolBarIcon_Print)
ToolBarToolTip(3, "Print")
ToolBarStandardButton(4, #PB_ToolBarIcon_Find)
ToolBarToolTip(4, "Find a document")
ToolBarSeparator()
ToolBarImageButton(5, LoadImage(0, "Data\NewProject.ico"))
ToolBarImageButton(10, LoadImage(5, "Data\SaveProject.ico"))
EndIf
If CreateMenu(1, WindowID())
MenuTitle("Project")
MenuItem(0, "New")
MenuItem(1, "Open")
MenuItem(2, "Save")
EndIf
;
; Attach our previously created ToolBar to this window
;
DisableToolBarButton(2, 1) ; Disable the button '2'
;
; The event loop. A ToolBar event is like a Menu event (as tools are shortcut for menu the most
; of the time). This is handy, as if the ToolBar buttons and the MenuItem have the same ID, then
; the same operation can be done on both action without any adds..
;
Repeat
EventID = WaitWindowEvent()
;Debug EventID
;Debug EventGadgetID()
Select EventID
Case #PB_Event_Menu
Select EventlParam()
Case 0 : MessageRequester("Information", "Menu ID: "+Str(EventMenuID()), 0)
Default: MessageRequester("Information", "ToolBar ID: "+Str(EventMenuID()), 0)
EndSelect
Case #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
EndSelect
Until Quit = 1
EndIf
Publié : mar. 22/nov./2005 10:15
par Droopy
Merci, c'est exactement ce que je recherchais
A+
Publié : mar. 22/nov./2005 10:20
par Chris
Ca fera 15 euros

Publié : mar. 22/nov./2005 21:42
par venom
a se prix la tu va etre rapidement riche
0/10 je sort