Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set the tab order of dynamically inserted items? 1

Status
Not open for further replies.

apostolchopov

Programmer
Joined
Jun 8, 2004
Messages
53
Location
BG
Hello, guys!
Could you tell me how to set the tab order of dynamically inserted controls in a CDialog object?
I am trying to insert several CEdit and CComboBox controls into a CDialog dynamically but I could not manage the tab order of these control. I suppose the tab order could be managed in CDialog::OnInitDialog() method... Or in some static variables...
Thank you in advance for your cooperation!

Ragards!
 
apostolchopov,

You need to use the following functions to change the Z-Order which changes the tab order:

BeginDeferWindowPos
DeferWindowPos
EndDeferWindowPos

An example is shown below where m_CtrlOne is positioned before m_CtrlTwo and two before 3 etc.

HDWP hdwp = BeginDeferWindowPos( 3 );

DeferWindowPos( hdwp,
m_CtrlOne.GetSafeHwnd(),
HWND_TOP,
0,
0,
0,
0,
SWP_NOMOVE | SWP_NOSIZE );

DeferWindowPos( hdwp,
m_CtrlTwo.GetSafeHwnd(),
m_CtrlOne.GetSafeHwnd(),
0,
0,
0,
0,
SWP_NOMOVE | SWP_NOSIZE );

DeferWindowPos( hdwp,
m_CtrlThree.GetSafeHwnd(),
m_CtrlTwo.GetSafeHwnd(),
0,
0,
0,
0,
SWP_NOMOVE | SWP_NOSIZE );

EndDeferWindowPos( hdwp );



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top