Hello everyone,
Coming from VB6 and using Vista, I had to decide whether I follow the .net line or go for something completely (or not that too) different. So here I am, a new PB owner who is learning-by-doing by porting some applications from VB to PB.
While the first application was - hmmm- quite easy to code in PB, the second one I try puts me to a problem.
Here is why:
I drew a simple dialog and added a menu bar in PBForms 1.51. Then I added some keyboard shortcuts (accellerators) by adding an ampersand to the caption of the top level menu (hpopup1).
Now, when I test drive the form in PBForms, all seems to work ok.
But then in PBEdit, while debugging or after compiling, the keyboard shortcuts don't work. All that happens is the appearence of the underscore when pressing [alt]. Mouse-clicks do work, of course.
I looked through the samples (which work) and another code I found here in this board but could not find any
significant difference in the seemingly relevant parts.
Can anyone push me in the right direction?
Thanks in advance
Greetings from Switzerland,
Markus
-> here's the code in question:
Coming from VB6 and using Vista, I had to decide whether I follow the .net line or go for something completely (or not that too) different. So here I am, a new PB owner who is learning-by-doing by porting some applications from VB to PB.
While the first application was - hmmm- quite easy to code in PB, the second one I try puts me to a problem.
Here is why:
I drew a simple dialog and added a menu bar in PBForms 1.51. Then I added some keyboard shortcuts (accellerators) by adding an ampersand to the caption of the top level menu (hpopup1).
Now, when I test drive the form in PBForms, all seems to work ok.
But then in PBEdit, while debugging or after compiling, the keyboard shortcuts don't work. All that happens is the appearence of the underscore when pressing [alt]. Mouse-clicks do work, of course.
I looked through the samples (which work) and another code I found here in this board but could not find any
significant difference in the seemingly relevant parts.
Can anyone push me in the right direction?
Thanks in advance
Greetings from Switzerland,
Markus
-> here's the code in question:
Code:
#PBFORMS CREATED V1.51 '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ #COMPILE EXE #DIM ALL '------------------------------------------------------------------------------ ' ** Includes ** '------------------------------------------------------------------------------ #PBFORMS BEGIN INCLUDES #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF #PBFORMS END INCLUDES '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Constants ** '------------------------------------------------------------------------------ #PBFORMS BEGIN CONSTANTS %IDD_DIALOG1 = 101 %IDR_MENU1 = 102 %IDM_FILE_NEW = 1001 %IDM_OPTIONS_CLOSE = 1002 #PBFORMS END CONSTANTS '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Declarations ** '------------------------------------------------------------------------------ DECLARE FUNCTION AttachMENU1(BYVAL hDlg AS DWORD) AS DWORD DECLARE CALLBACK FUNCTION ShowDIALOG1Proc() DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG #PBFORMS DECLARATIONS '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Main Application Entry Point ** '------------------------------------------------------------------------------ FUNCTION PBMAIN() ShowDIALOG1 %HWND_DESKTOP END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Menus ** '------------------------------------------------------------------------------ FUNCTION AttachMENU1(BYVAL hDlg AS DWORD) AS DWORD #PBFORMS BEGIN MENU %IDR_MENU1->%IDD_DIALOG1 LOCAL hMenu AS DWORD LOCAL hPopUp1 AS DWORD LOCAL hPopUp2 AS DWORD MENU NEW BAR TO hMenu MENU NEW POPUP TO hPopUp1 MENU ADD POPUP, hMenu, "&File", hPopUp1, %MF_ENABLED MENU ADD STRING, hPopUp1, "New", %IDM_FILE_NEW, %MF_ENABLED MENU NEW POPUP TO hPopUp1 MENU ADD POPUP, hMenu, "&Options", hPopUp1, %MF_ENABLED MENU ADD STRING, hPopUp1, "Close", %IDM_OPTIONS_CLOSE, _ %MF_ENABLED MENU ATTACH hMenu, hDlg #PBFORMS END MENU FUNCTION = hMenu END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** CallBacks ** '------------------------------------------------------------------------------ CALLBACK FUNCTION ShowDIALOG1Proc() SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL CASE %IDM_FILE_NEW MSGBOX "%IDM_FILE_NEW=" + FORMAT$(%IDM_FILE_NEW), _ %MB_TASKMODAL CASE %IDM_OPTIONS_CLOSE MSGBOX "%IDM_OPTIONS_CLOSE" + _ FORMAT$(%IDM_OPTIONS_CLOSE), %MB_TASKMODAL END SELECT END SELECT END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Dialogs ** '------------------------------------------------------------------------------ FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG #PBFORMS BEGIN DIALOG %IDD_DIALOG1->%IDR_MENU1-> LOCAL hDlg AS DWORD DIALOG NEW hParent, "Dialog1", 70, 70, 201, 132, TO hDlg AttachMENU1 hDlg #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_DIALOG1 #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '------------------------------------------------------------------------------
Comment