Announcement

Collapse
No announcement yet.

ENTER Key in DDT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ENTER Key in DDT

    In my program I am not trapping KB events (yet). I do process
    the ESC key because it generates the message %IDCANCEL. I
    want to do something with the ENTER key using its message
    %IDOK. But I find that the ENTER key always sends a message
    with the ID of the last button drawn on the screen
    (CONTROL ADD BUTTON). I confirmed this by moving buttons
    around on the screen and get a different ID depending on
    the last button drawn.

    I know that the focus is always set to the first button on the
    screen, not the last. And I have removed all %WS_TABSTOP
    options from all buttons.

    Does anyone have any idea what "option" I have set that causes
    the ENTER key to identify itself as the last button on the
    screen instead of delivering %IDOK.

  • #2
    Joe --
    You can set "default" button
    1) in CONTROL ADD BUTTON - see %BS_DEFAULT
    2) dynamically
    CONTROL SET FOCUS hDlg, CtlId
    CONTROL SEND hDlg, CtlId, %BM_SETSTYLE, %BS_DEFPUSHBUTTON, %TRUE (Lance' suggestion)



    ------------------

    Comment


    • #3
      Semen, I checked and do not have %BS_DEFAULT anywhere in the
      program. I do have CONTROL SET FOCUS in the program, but it
      is set to different button than the last button on the screen.

      I had a few SENDMESSAGE's for FONT Selection. Removing them
      had no effect.

      My problem is NOT trying to set a default value for the ENTER
      key. It is unsetting it, if that indeed is what I have
      inadvertently done.

      ------------------

      Comment


      • #4
        Joe;

        Create a "Dummy" button which is placed outside the boundaries of the Dialog. If the Dialog is 400 units wide , put the button at 420 (X coordinate), so it can't be seen.

        Then use %IDOK for the ID number for that button.

        Make sure the Button doesn't use the default Styles (0), but define it as %WS_CHILD or %WS_VISIBLE . Do not use the %WS_TABSTOP style for it.

        Then when you press enter, that buttons event (CallBack) should be fired.

        %IDOK needs to be assigned to a real control.


        ------------------
        Chris Boss
        Computer Workshop
        Developer of "EZGUI"
        http://cwsof.com
        http://twitter.com/EZGUIProGuy

        Comment


        • #5
          Thanks for a great suggestion!

          I was down another very long process that was going to cost me
          a lot of time. I discovered that if I removed %BS_OWNERDRAW
          from the buttons that I did not have the problem. But most
          consfusing if I left %BS_OWNERDRAW but removed all drawing
          code the problem still occured. Somehow %BS_OWNERDRAW had
          something to do with have %IDOK being assigned to the last
          button drawn. Glad I won't have to figure out why.

          ------------------

          Comment

          Working...
          X