Edit control tab / child windows / tabstop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qhimq
    New Member
    • May 2007
    • 48

    Edit control tab / child windows / tabstop

    Hi,

    I'm working with win32API c++. I added the WS_TABSTOP to the edit windows, as well as the WS_EX_CONTROLPA RENT and DS_CONTROL to the parent window. Yet any numerous times of punching the tab key does nothing.

    Anyone have sample code that works? I've searched for acouple hours and couldnt find anything without MFC. I refuse to use Visual products, hence my problem with the tab key not working.

    Any help would be super,
    Thanks,
    Quincy
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    What product are you using then?

    For that matter what type of container are you using? Dialogue box or a window?

    Are you sure that you have set the focus onto one of the controls in the first place (using SetFocus).

    Comment

    • qhimq
      New Member
      • May 2007
      • 48

      #3
      I'm using gcc to compile without MFC.

      I want to tab through edit windows (text boxes)

      ...| WS_TABSTOP | WM_SETFOCUS is in my styles for the edit window I want to be focused first.


      All my edit windows are created in some fashion close to this:

      Code:
      CreateWindow(
      								"EDIT",
      								"CY",
      								WS_VISIBLE | WS_CHILD | ES_LEFT | WS_BORDER | WS_TABSTOP| WM_SETFOCUS,
      								110,
      								25,
      								350,
      								20, 
      								hWnd, 
      								(HMENU)IDE_TITLE,
      								hInstance,
      								NULL);

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        OK, but are you placing these edit boxes on a Window or on a Dialogue box?

        In response to which message to the parent window are you creating these edit boxes, or where with-in the structure of your code?

        If you don't wish to use MS software but do wish to write windows programs you may wish to consider using the Dev-C++ which comes with resource editors allowing you to create dialogue boxes in the normal way, as a resource, rather than creating them on the fly at runtime.

        Comment

        • qhimq
          New Member
          • May 2007
          • 48

          #5
          O a Dialogue Box is made from a resource?

          and a Window is made from code?

          If that is true, then I just learned that lingo. Since I like code more than
          pretty pictures dragging on items, I've only used code (windows) in this
          project. My parent window was created like this:
          Code:
          hwndMain = CreateWindowEx(0, //Extended window style
          				ClassName, // Window class name
          				WindowTitle, // Window title
          				dwStyles, // Window style:WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_EX_CONTROLPARENT|DS_CONTROL
          				desktopRect->top, desktopRect->left, // (x,y) pos of the window
          				desktopRect->right, desktopRect->bottom, // Width and height of the window
          				NULL, // HWND of the parent window (can be null also)
          				NULL, // Handle to menu
          				g_hInstance, // Handle to application instance
          				(void*)this); // Pointer to window creation data
          And my tab key works, though instead of it jumping to a new text box it indents inside the text box. I would like for it to jump.

          Thanks.

          Comment

          • qhimq
            New Member
            • May 2007
            • 48

            #6
            so basically i'm asking how to tab across these child windows(text boxes), if it is possible.

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              You still have not explicitly said if you are trying to create a window or a dialogue box.

              However assuming from the DS_CONTROL in this

              Originally posted by qhimq
              Code:
              hwndMain = CreateWindowEx(0, //Extended window style
              				ClassName, // Window class name
              				WindowTitle, // Window title
              				dwStyles, // Window style:WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_EX_CONTROLPARENT|DS_CONTROL
              				desktopRect->top, desktopRect->left, // (x,y) pos of the window
              				desktopRect->right, desktopRect->bottom, // Width and height of the window
              				NULL, // HWND of the parent window (can be null also)
              				NULL, // Handle to menu
              				g_hInstance, // Handle to application instance
              				(void*)this); // Pointer to window creation data
              that you are trying to create a dialog box then you should not be calling CreateWindowEx (or CreateWindow) because these create windows.

              You need to look up and call

              DialogBoxIndire ct - if you wish to create a modal dialogue box

              CreateDialogInd irect - if you wish to create a modeless dialogue box


              These 2 functions do not use a dialogue resource to create the dialogue box so you will be able to create your edit boxes in them once they are created.

              If the dialogue box layout is fixed it is normal to create a dialog resource to define them, then you could use

              DialogBox - if you wish to create a modal dialogue box

              CreateDialog - if you wish to create a modeless dialogue box

              to create them at runtime.

              Comment

              • qhimq
                New Member
                • May 2007
                • 48

                #8
                I made a window inside a window. I don't know how else to explain except for saying I want to be able to tab between child windows which are in this case edit windows.

                Comment

                • Mickevh
                  New Member
                  • Jun 2007
                  • 3

                  #9
                  I don't know if it helps, but I'm exploring the same issue except I'm using VC++ 5 (stop laughing at the back, I've had it for years and it was cheap.)

                  Anyway, I've got a class derived from CView which has a number of objects embedded in it representing "lines" of information. Each "line" is itself a class derived from plain old CWnd that contains static text, two CButton controls and two "custom" controls derived from CEdit.

                  I spite of defining all the controls with WS_TABSTOP & WS_EX_CONTROLPA RENT I can't tab between the controls unless I add handlers to look for the "tab" keystrokes in my CEdit derived controls, and I can't do anything with the standard CButtons (and don't really want to create by own simply to handle the tab key.)

                  So in my case it's definitely CWnd's within CWnd's and not a CDialog box anywhere.

                  Any help would be much appreciated since I can't find anything in the VC++ online manuals.

                  Mick

                  Comment

                  • Mickevh
                    New Member
                    • Jun 2007
                    • 3

                    #10
                    Aha: I think I've found the answer to my own problem: Take a look at...

                    .... http://www.microsoft.c om/mind/0499/faq/faq0499.asp

                    and

                    .... http://support.microso ft.com/?kbid=165074

                    ... for a description of what's up with tabbing between CWnd child window controls. The first article is specific to "web browsers within other windows" but the descriptions contained of how Windows handles tab keystrokes should prove illumunating.

                    And just in case anyone's reading this years after it was posted and the links have gone dead, look up "IsDialogMessag e" and "PreTranslateMe ssage" functions in your favourite search engine and hopefully you should find some useful information.

                    If your problems are inside Dialog boxes, hopefully the original respondant to this post can help you out.

                    Good Luck

                    Mick

                    Comment

                    • Mickevh
                      New Member
                      • Jun 2007
                      • 3

                      #11
                      More info:

                      If you want to control the order in which you tab through controls at run time, use the SetWindowPos function. My (MFC) code fragment for doing this is...

                      // From the parent window of the the controls...

                      CWnd* pWnd; // Ptr to window we're changing.
                      CWnd* pAfter; // Ptr to window we want pWnd after.
                      UINT nFlags=SWP_SHOW WINDOW|SWP_NOSI ZE|SWP_NOMOVE; // Ignore window size and position parameters in SetWindowPos calls.

                      pAfter =GetDlgItem(1ST CONTROL);
                      pAfter->SetWindowPos(& wndTopMost,0,0, 0,0,nFlags);
                      pWnd =GetDlgItem(2ND CONTROL);
                      pWnd->SetWindowPos(p After,0,0,0,0,n Flags);
                      pAfter =pWnd;
                      pWnd =GetDlgItem(3RD CONTROL);
                      pWnd->SetWindowPos(p After,0,0,0,0,n Flags);
                      pAfter =pWnd;
                      pWnd =GetDlgItem(4TH CONTROL);
                      pWnd->SetWindowPos(p After,0,0,0,0,n Flags);

                      etc.

                      As mentioned, this is MFC code, but the MFC calls are more or less just wrappers to API calls of the same name, so you'll need to use Window handles insteand of CWnd pointers.

                      Hope that helps.

                      Mick

                      Comment

                      Working...