Announcement

Collapse
No announcement yet.

Entire Dialog: Getting page up/down and up/down arrows

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

  • Entire Dialog: Getting page up/down and up/down arrows

    I have been trying for some time to make all the edit controls
    in a dialog box (about 50) send JUST the page up/page down and
    up/down arrow keys to my subclass procedure without changing the
    standard windows functions for TAB, Shft-TAB, etc.
    So far I'm unsuccessful.
    I've tried subclassing each control individually, and they do go
    to the subclass procedure, but it seems I have to use the
    wantallkeys in order to get the needed keys, and that turns off
    the standard TAB and shift TAB (which I'm so far unable to duplicate).

    Anyone have any ideas?

    Best Regards

    Jim


    ------------------
    Jim Seekamp
    Jim Seekamp

  • #2
    I think you need a modelless dialog.

    Then use a standard getmessage message loop.
    You can Use Msg.Message for this.


    ------------------
    [email protected]
    hellobasic

    Comment


    • #3
      I do not quite understand your question but here are two examples of subclass procedures
      for edit controls. Note, the second shows one method of handling shifting the keyboard
      focus among edit controls. 50 controls on a dialog, hmmm...., design flaw?
      Code:
      '----------------------------------------------------------------------
      '
      '   FUNCTION: EditSubclassProc(LONG, LONG, LONG, LONG)
      '   PURPOSE:  Subclass procedure for input field edit control.
      '   NOTES:    glOldWndProc - original window procedure of edit control.
      '
      '----------------------------------------------------------------------
      
      FUNCTION EditSubclassProc _
        ( _
          BYVAL hWnd    AS LONG, _  ' edit control handle
          BYVAL lMsg    AS LONG, _  ' type of message
          BYVAL lParam1 AS LONG, _  ' additional information
          BYVAL lParam2 AS LONG _   ' additional information
        ) EXPORT        AS LONG
      
        LOCAL lRet  AS LONG
      
        SELECT CASE lMsg
          CASE %WM_GETDLGCODE
            ' Ensure that the edit control processes all keyboard input
            lRet = CallWindowProc(glOldWndProc, hWnd, lMsg, lParam1, lParam2)
            FUNCTION = lRet OR %DLGC_WANTALLKEYS
            EXIT FUNCTION
      
          CASE %WM_CHAR
            ' Process this message to avoid message beeps
            IF (lParam1 = %VK_RETURN) OR (lParam1 = %VK_TAB) THEN
              FUNCTION = %FALSE
              EXIT FUNCTION
            END IF
      
          CASE %WM_KEYDOWN
            ' Process the enter key
            IF (lParam1 = %VK_RETURN) OR (lParam1 = %VK_TAB) THEN
              ' Set the focus to the general properties listbox
              ' (There is some code here to get the handle of the listbox)
              SetFocus hWndList
              FUNCTION = %FALSE
              EXIT FUNCTION
            END IF
        END SELECT
      
        ' Let Windows handle anything we are not interested in
        FUNCTION = CallWindowProc(glOldWndProc, hWnd, lMsg, lParam1, lParam2)
      
      END FUNCTION
      
      '----------------------------------------------------------------------
      '
      '   FUNCTION: Color_EditSubProc(LONG, LONG, LONG, LONG)
      '   PURPOSE:  Subclass procedure for edit controls in colorbox.
      '
      '----------------------------------------------------------------------
      
      FUNCTION Color_EditSubProc _
        ( _
          BYVAL hWnd    AS LONG, _  ' listbox handle
          BYVAL lMsg    AS LONG, _  ' type of message
          BYVAL lParam1 AS LONG, _  ' additional information
          BYVAL lParam2 AS LONG _   ' additional information
        ) EXPORT        AS LONG
      
        LOCAL lRet      AS LONG
        LOCAL hWndFocus AS LONG
        LOCAL szName    AS ASCIIZ * %MAX_PATH  ' MAX_PATH = 260
      
        SELECT CASE lMsg
          CASE %WM_GETDLGCODE
            ' Ensure that the edit control processes all keyboard input
            lRet = CallWindowProc(glOldWndProc, hWnd, lMsg, lParam1, lParam2)
            FUNCTION = lRet OR %DLGC_WANTALLKEYS
            EXIT FUNCTION
      
          CASE %WM_CHAR
            ' Process this message to avoid message beeps
            IF (lParam1 = %VK_RETURN) OR (lParam1 = %VK_TAB) THEN
              FUNCTION = %FALSE
              EXIT FUNCTION
            END IF
      
          CASE %WM_KEYDOWN
            ' Process the enter key
            IF lParam1 = %VK_RETURN THEN
              SendMessage GetParent(hWnd), %WM_COMMAND, MAKLNG(%IDOK, 0), 0
              FUNCTION = %FALSE
              EXIT FUNCTION
              ' Process the tab key
              ELSEIF lParam1 = %VK_TAB THEN
                IF GetKeyState(%VK_SHIFT) < 0 THEN
                  ' Go backward
                  hWndFocus = GetNextDlgTabItem(GetParent(hWnd), hWnd, %TRUE)
                ELSE
                  ' Go forward
                  hWndFocus = GetNextDlgTabItem(GetParent(hWnd), hWnd, %FALSE)
                END IF
                IF ISTRUE hWndFocus THEN
                  SetFocus hWndFocus
                  GetClassName hWndFocus, VARPTR(szName), %MAX_PATH
                  ' Hilite all the text in the edit control
                  IF UCASE$(szName) = "EDIT" THEN SendMessage hWndFocus, %EM_SETSEL, 0, -1
                END IF
                FUNCTION = %FALSE
                EXIT FUNCTION
            END IF
        END SELECT
      
        ' Let Windows handle anything we are not interested in
        FUNCTION = CallWindowProc(glOldWndProc, hWnd, lMsg, lParam1, lParam2)
      
      END FUNCTION
      ------------------
      Dominic Mitchell
      Dominic Mitchell
      Phoenix Visual Designer
      http://www.phnxthunder.com

      Comment


      • #4
        Edwin; it works most of the way with a modal dialog, it just doesn't let Windows
        process the TAB key press; are you sure it has to be modeless?

        Thanks for the reply Dominic; you're doing about the same thing I am,
        except I'm doing the setwindowlong for about 50 controls to the
        same subclass procedure.

        - Jim


        ------------------
        Jim Seekamp
        Jim Seekamp

        Comment


        • #5
          jim --
          you simply didn't understand edwin.
          sure, that he meant a code, similar posted by me in http://www.powerbasic.com/support/pb...ead.php?t=2439

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

          Comment


          • #6
            I understood him Semen...

            I just got it working with a modal dialog, so I guess it doesn't
            matter. I just didn't have it falling through correctly.

            Thanks for the code Dominic; it was your code that showed me
            what I had wrong.

            Best Regards

            Jim


            ------------------
            Jim Seekamp
            Jim Seekamp

            Comment


            • #7
              I must be dumb but if you subclass the modal dialog, it should help you out?

              Subclassing 50 controls is not the way.

              ??


              ------------------
              [email protected]
              hellobasic

              Comment


              • #8
                You can also try this one;
                It's written for 16bit so you need to rewrite it a little.
                Incomplete code, check msdn

                INFO: Context-Sensitive Help in a Dialog Box Through F1
                ID: Q72219

                lpProcAbout = MakeProcInstance(About, hInst);
                lpfnFilterProc = MakeProcInstance(FilterFunc, hInst);
                hHook = SetWindowsHookEx(WH_MSGFILTER,
                lpfnFilterProc,
                hInst,
                NULL);
                DialogBox(hInst, "AboutBox", hWnd, lpProcAbout);
                UnhookWindowsHookEx(hHook); FreeProcInstance(lpfnFilterProc);
                FreeProcInstance(lpProcAbout); break;


                ------------------
                [email protected]
                hellobasic

                Comment


                • #9
                  http://www.powerbasic.com/support/pb...ead.php?t=2068

                  variant #2



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

                  Comment


                  • #10
                    Thanks... I'll check that out too.

                    Best Regards

                    Jim


                    ------------------
                    Jim Seekamp
                    Jim Seekamp

                    Comment

                    Working...
                    X