|
-
December 20th, 2006, 02:29 AM
#1
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.
-
December 20th, 2006, 03:41 AM
#2
Re: tab order
Can you elaborate on "It does not work fine"? Can you post some code?
-
December 20th, 2006, 03:43 AM
#3
Re: tab order
 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.
-
December 20th, 2006, 04:27 AM
#4
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.
-
December 20th, 2006, 04:35 AM
#5
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.
-
December 20th, 2006, 05:08 AM
#6
Re: tab order
But i have HWND handle of dialog. It is win32 application, C++
How i will do it same by using this
-
December 20th, 2006, 05:45 AM
#7
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.
-
December 20th, 2006, 06:03 AM
#8
Re: tab order
 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
-
December 20th, 2006, 09:37 AM
#9
Re: tab order
oops, blame me for that...
-
December 20th, 2006, 11:46 AM
#10
Re: tab order
But i did not any answer.
-
December 20th, 2006, 02:18 PM
#11
Re: tab order
 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...
-
December 20th, 2006, 11:19 PM
#12
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.
-
December 21st, 2006, 12:49 AM
#13
Re: tab order
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|