CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: tab order

  1. #1
    Join Date
    Oct 2006
    Posts
    49

    tab order

    How will set new tab order of controls that we added in dialog? Suppose dialog have some controls and in this dialog i hide one controls and add new one dynamically. Now i want to set new tab order.

    I already used SetWindowPos() function. It does not work fine . It is win32 application.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: tab order

    Can you elaborate on "It does not work fine"? Can you post some code?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: tab order

    Quote Originally Posted by MartinJulie
    ...
    I already used SetWindowPos() function. It does not work fine .
    Please, explain what in this context "fine" means.
    Besides, if SetWindowPos does not work as expected then you, probrbly, are using it not 100% correct.
    Last edited by VictorN; December 20th, 2006 at 03:45 AM.

  4. #4
    Join Date
    Oct 2006
    Posts
    49

    Re: tab order

    I have four controls in dialog, But i hide second control and add new control dynamically. Now now tab goes to one then two but after then it does not go to third one so on

    //code given below:
    HWND hwnd; //handle of main dialog
    HWND hwnctrl1, hwnctrl2,hwnctrl3,hwnctrl4,hwnNewctrl;

    // first i hide control
    ShowWindow(hwnctrl2,SW_HIDE);

    hwnNewctrl = CreateWindow(TEXT ("edit"), NULL, ES_LEFT | ES_PASSWORD | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP,
    nLeft , nTop , nWidth, nHeight, hwnd, (HMENU) ID_EDIT,
    (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;

    //set tab order
    SetWindowPos(hwnNewctrl , hwnctrl1,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
    //set to third one
    SetWindowPos(hwnctrl3, hwnNewctrl ,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);

    //set to forth one
    SetWindowPos(hwnctrl4, hwnctrl3,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);




    Waiting for your response.

  5. #5
    Join Date
    May 2006
    Location
    Norway
    Posts
    1,709

    Re: tab order

    Not quite sure what you want, but if I udnerstand you correct, you hide some control during runtime and then you want the tab order to be modified so that the hided controls are not in the tab order list?

    What you have to do is to set the enabled state for each control depending on wheter the control is visible or not.

    1. Loop throug all control on your dialog
    Code:
    CWnd* pWndControl = yourDialog->GetWindow(GW_CHILD);
    
    while(pWndControl != NULL) {
    
       pWndCOntrol->EnableWindow( //true or false, depending if it is hided or not
    
       pWndControl->pWndControl->GetWindow(GW_HWNDNEXT);
    
    
    }


    Laitinen
    Last edited by laitinen; December 20th, 2006 at 04:41 AM.

  6. #6
    Join Date
    Oct 2006
    Posts
    49

    Re: tab order

    But i have HWND handle of dialog. It is win32 application, C++

    How i will do it same by using this

  7. #7
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720

    Re: tab order

    Well, you gave the same coords in SetWindowPos, thus all the 3 controls woul overlap each other, give other coords and try also UpdateWindow, not sure this might work, anyway have nothing to tell more which guess might help.

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: tab order

    Quote Originally Posted by AvDav
    Well, you gave the same coords in SetWindowPos, thus all the 3 controls woul overlap each other, give other coords ...
    Wrong.
    SetWindowPos does NOT change the position/size of these controls (hwnNewctrl, hwnctrl3, hwnctrl4) because of the flags SWP_NOSIZE|SWP_NOMOVE

  9. #9
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720

    Re: tab order

    oops, blame me for that...

  10. #10
    Join Date
    Oct 2006
    Posts
    49

    Re: tab order

    But i did not any answer.


  11. #11
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: tab order

    Quote Originally Posted by MartinJulie
    But i did not any answer.

    Remove second and third calls to SetWindowPos().
    Just leave CreateWindow followed by
    Code:
    //set tab order
    SetWindowPos(hwnNewctrl , wnctrl1,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
    Works for me...
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  12. #12
    Join Date
    Feb 2000
    Location
    Indore, India
    Posts
    1,046

    Re: tab order

    Hello,

    Tab order is the order in which controls are there in the resource file (if they are created using resource editor) or the order in which they are created (if they are created dynamically). I do not know any method to chenge the order during run time.

    But, there can be a shortcut solution in your case. You want to replace the second control with another control at run time. Is it not so? Create five the controls (i) first, (ii) second (A), (iii) second (B), (iv) third and (v) fourth. Set the tab order in the same sequence. And hide the second (B) control initially. Instead of deleting second (A) during run time, hide it at the time showing second (B).

    Regards,
    Pravin.
    Let me know if I have helped by rating this post

    Recent FAQs

    Drag an image
    Area of a window exposed on desktop
    Display rotated bitmap

  13. #13
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: tab order

    Quote Originally Posted by Pravin Kumar
    ...I do not know any method to chenge the order during run time.
    The second parameter in SetWindowPos():
    hWndInsertAfter
    [in] Handle to the window to precede the positioned window in the Z order.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured