Announcement

Collapse
No announcement yet.

Default button does not respond to ENTER

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    Timm Motl
    Member

  • Timm Motl
    replied
    DienyduToit...

    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
    Timm

    [This message has been edited by Timm Motl (edited October 22, 2000).]

    Leave a comment:

  • Guest
    Guest

  • DienyduToit
    Guest started a topic Default button does not respond to ENTER

    Default button does not respond to ENTER

    Peculiar condition, or erroneous code?

    Control Add Button, hDlg&, %NQfinBtn, "OK", 286, 281, 60, 20, _
    %BS_DEFAULT

    There are no other %BS_DEFAULT controls on the dialog.

    This did not have any heavy black border, nor responded to the
    ENTER key.

    Searching the forums, I found a posting from Lance, and used
    that:

    Control Enable hDlg&, %NQfinBtn
    Control Set Focus hDlg&, %NQfinBtn
    Control Send hDlg&, %NQfinBtn, %BM_SETSTYLE, %BS_DEFPUSHBUTTON, _
    %TRUE

    This brought along the border effect, but still no reponse to the
    ENTER key. Adding a specific callback function ---

    Control Add Button, hDlg&, %NQfinBtn, "OK", 286, 281, 60, 20, _
    %BS_DEFAULT Call NewQuoteStarted

    ... doesn't make any difference.

    Anybody have an answer?

    (The Petzold book I have ordered MAY yet materialise -- I just
    received this message: "Just to let you know we are expecting
    your order around 16 November 2000.")


    ------------------
Working...
X