You should have no trouble getting the Enter key to work with the %BS_DEFAULT style. This code example
should show you everything you need to figure out how. Maybe you aren't handling the button notification
properly in your CALLBACK. If this doesn't clarify it for you, I'd suggest you look harder at your code.
Code:
#COMPILE EXE #INCLUDE "WIN32API.INC" %NQfinBtn = 10 CALLBACK FUNCTION DlgProc SELECT CASE CBCTLMSG CASE %BN_CLICKED SELECT CASE CBCTL CASE %NQfinBtn STATIC Counter AS LONG INCR Counter CONTROL SET TEXT CBHNDL, %NQfinBtn, TRIM$(STR$(Counter)) END SELECT END SELECT END FUNCTION FUNCTION PBMAIN LOCAL hDlg AS LONG DIALOG NEW 0, "Button Test...",,, 110, 60, %WS_SYSMENU TO hDlg CONTROL ADD LABEL, hDlg, -1, "Click button or press Enter...", 10, 6, 100, 10 CONTROL ADD BUTTON, hDlg, %NQfinBtn, "OK", 30, 20, 50, 16, %BS_DEFAULT CONTROL SEND hDlg, %NQfinBtn, %BM_SETSTYLE, %BS_DEFPUSHBUTTON, %TRUE DIALOG SHOW MODAL hDlg CALL DlgProc END FUNCTION
[This message has been edited by Timm Motl (edited October 22, 2000).]
Leave a comment: