; English forum: ; Author: ; Date: 21. January 2003 ; OS: Windows, Linux ; Demo: Yes ;just compile and run... ;press "M" key for testing... ; I tested it on all versions of Windows and here are the results: ;Win XP Pro: Works ;Win 2K Pro: Works ;Win ME: Works ;Win 98se: Works ;Win NT4: Works ;Win 95b: Works ; ; -------- Init and Open Window -------- ; If OpenWindow(0, 100, 150, 320, 150, #PB_Window_SystemMenu, "PB - AddKeyboardShortcut() Example") = 0 MessageRequester("PB - AddKeyboardShortcut() Example", "Could not open window!", 0) End EndIf ; ; -------- Create our MenuBar -------- ; If CreateMenu(0, WindowID()) MenuTitle("&File") MenuItem( 1, "&Load...") MenuItem( 2, "Save") MenuItem( 3, "Save As...") MenuBar() MenuItem( 4, "&Quit") ; MenuTitle("&Edit") MenuItem( 5, "Cut") MenuItem( 6, "Copy") MenuItem( 7, "Paste") ; MenuTitle("&Help") MenuItem( 8, "&About") EndIf ; ; -------- Add our Keyboard Shortcut ------- ; AddKeyboardShortcut(0,#PB_Shortcut_M,8) ; If pressed, set EventID to MenuItem 8 ; ; -------- Mainloop Check for events -------- ; Repeat ; ; -------- Select WindowEvents -------- ; Select WaitWindowEvent() Case #PB_EventMenu ; ; -------- Select MenuEvents -------- ; Select EventMenuID() ; Check which menu was activated Case 8 ; About MessageRequester("Hi Mike!", "AddKeyboardShortcut() seems to work nice!?", 0) Default MessageRequester("Info", "MenuItem: "+Str(EventMenuID()), 0) EndSelect ; ; -------- End Select MenuEvents ------- ; Case #WM_CLOSE ; #PB_EventCloseWindow quit = 1 EndSelect ; ; -------- End Select WindowEvents -------- ; Until quit = 1 ; End ; ExecutableFormat=Windows ; FirstLine=1 ; DisableDebugger ; EOF