You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Make sure you are not using duplicate ID's %IDCANCEL = 2
Same effect if I do this...
Code:
CONTROL ADD BUTTON, hDlg, %IDC_MTP_INPUT_CANCEL_BUTTON, "&Cancel", 75, 53, 40, 16
...
%IDC_MTP_CANCEL_BUTTON = 2 'Cancel button <-allow Esc Key
...
CASE %WM_COMMAND
SELECT CASE CBCTL
CASE %IDC_MTP_CANCEL_BUTTON
IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
'cancel, abort changes
DIALOG END CBHNDL, 0
END IF
but if i remove/comment the part of code responsible for ESC, and press ESC it runs a control (button). why??
Raed,
please take some time to write, maybe it's just me, but If someone posts questions here in "chat-I-don't-have-time-to-write"-slang, It's a lot of harder (for me) to understand them
B2T:
Do you have in your callback something like
Code:
CASE %IDC_BUTTON_send
IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
for every button? All controls can recieve a bunch of messages, maybe you didn't catch the ones, which shouldn't trigger the button?
Regards,
Marc Giesmann
Last edited by Marc Giesmann; 4 Nov 2008, 09:45 AM.
Reason: Too goddamn stupid to use codetags ;)
thank u all for the replies.
i managed to close app when press ESC.
but if i remove/comment the part of code responsible for ESC, and press ESC it runs a control (button). why??
hints
thanx
how can i activate/deactivate the ESC key to do certain task?
(Emphasis added)
Typically a two state situation requires a state test. The decision to ignore als requires aa test since this is being trapped in the dialog's callback. Without testing a "flag" variable, which could just as well be some other existing program variable, the program does not know to "ignore" the escape key press or act on it. Surely one could pass the "flag", e.g. in a USER memory of say the dialog, but a flag it is and "static" it is none the less.
Case %WM_COMMAND
Select Case As Long CbCtl
' Built-in. Sent to dialog by Escape and Return keys..
Case %IDCANCEL ' Escape Key
If CbCtlMsg = %BN_CLICKED Then
Dialog End CbHndl
End If
Case %IDOK ' Return Key
If CbCtlMsg = %BN_CLICKED Then
WinBeep 800, 50
End If
Michael points out the key equate, bu you will still need to set a STATIC (or GLOBAL) flag to do what you want.
Code:
#COMPILER PBWIN
#COMPILE EXE
#DIM ALL
#INCLUDE "Win32API.inc"
%IDD_DIALOG1 = 101
%IDC_BTN_TEST = 1001
CALLBACK FUNCTION MainDlgProc()
STATIC escflag AS LONG
SELECT CASE AS LONG CB.MSG
CASE %WM_INITDIALOG
escflag = 0
CASE %WM_COMMAND
SELECT CASE AS LONG CBCTL
CASE %IDC_BTN_TEST
IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
'toggle the STATIC escflag
IF escflag = 0 THEN escflag = 1 ELSE escflag = 0
EXIT FUNCTION
END IF
CASE %IDCANCEL
IF escflag = 0 THEN
DIALOG SET TEXT CBHNDL,"Hint: Press Test key to set ESC to quit mode"
EXIT FUNCTION
ELSE
DIALOG END CBHNDL
END IF
END SELECT
END SELECT
END FUNCTION
FUNCTION PBMAIN () AS LONG
LOCAL hDLG AS DWORD
LOCAL lRslt AS LONG
DIALOG NEW PIXELS, 0, "Test This",,, 640, 480, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
CONTROL ADD BUTTON, hDlg, %IDC_BTN_TEST, "Test", 500, 10, 100, 100
DIALOG SHOW MODAL hDlg, CALL MainDlgProc TO lRslt
END FUNCTION
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: