Archived

This topic is now archived and is closed to further replies.

Xeee

Cycling through the controls

Recommended Posts

Xeee    144
I want to know how to cycle through the controls using tab !! i''ve tried everything , WS_TABSTOP (for the controls) , WS_EX_CONTROLPARENT (for the controls parent) , WS_GROUP (for the parent) and nothin'' worked , should i do it manually with SetFocus!! what is the proper way to do it ? i''m programming in Win32(NO MFC) with VC++ 6.0 , on XP oh btw , i remembered something , does AnimateWindow() operate on windows XP?? thanks for your help ... ...Xeee

Share this post


Link to post
Share on other sites
Oluseyi    2115
Given that you have N controls with values arranged such that base_number + ( random_number % N ) yields one of the controls' id:

// subclass control with this procedure:
LRESULT CALLBACK SubclassProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
if( msg == WM_CHAR && wparam == VK_TAB )
{
SetFocus( GetDlgItem( GetParent(hwnd),
base_number + ( (GetWindowLong(GWL_ID) + 1) % N ) );
}
return 0;

return CallWindowProc( DefaultProc, hwnd, msg, wparam, lparam );
}


[Edit: Left out base_number.]

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!


[edited by - Oluseyi on April 29, 2002 6:04:08 PM]

Share this post


Link to post
Share on other sites
Xeee    144
isn''t there another way , i thought that it can b done automatically , if there isn''t another way , what are WS_TABSTOP and WS_EX_CONTROLPARENT flags for?
i understand your way of doing it , but i just want to know if there''s another way , and y not use it



...Xeee

Share this post


Link to post
Share on other sites