Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to set Tab Stop order programmatically?

957 views
Skip to first unread message

Vincent

unread,
Jan 26, 2004, 11:39:34 AM1/26/04
to
Hi there,

In a dialog, there are three controls: A, B, and C, the tab stop order is
A -> B -> C, it is set in the design time. My question is how to change this
order when the program is running, like change to A -> C -> B.

Thanks in advance

Vincent


Bjarne Nielsen

unread,
Jan 26, 2004, 11:49:00 AM1/26/04
to
"Vincent" <ms...@cwbsupport.com> skrev i en meddelelse
news:%23Utp8rC...@TK2MSFTNGP09.phx.gbl...

You can do it with the SetWindowPos() function.

--
Bjarne Nielsen


Mark Rance

unread,
Jan 26, 2004, 2:47:55 PM1/26/04
to

"Bjarne Nielsen" <bnielse...@post11.tele.dk> wrote in message
news:%23GQEOxC...@TK2MSFTNGP12.phx.gbl...


But this will not change the Tab order for a program that is already
running.
I am not aware of any way to change tab Order once the program has been
compiled.

-Mark


Jeff Partch

unread,
Jan 26, 2004, 3:06:17 PM1/26/04
to
"Mark Rance" <m...@pcisys.net> wrote in message
news:101arnc...@corp.supernews.com...

>
> "Bjarne Nielsen" <bnielse...@post11.tele.dk> wrote in message
> news:%23GQEOxC...@TK2MSFTNGP12.phx.gbl...
> > "Vincent" <ms...@cwbsupport.com> skrev i en meddelelse
> > news:%23Utp8rC...@TK2MSFTNGP09.phx.gbl...
> > > Hi there,
> > >
> > > In a dialog, there are three controls: A, B, and C, the tab stop order
> is
> > > A -> B -> C, it is set in the design time. My question is how to
change
> > this
> > > order when the program is running, like change to A -> C -> B.
> > >
> > > Thanks in advance
> > >
> > > Vincent
> > >
> > >
> >
> > You can do it with the SetWindowPos() function.
>
>
> But this will not change the Tab order for a program that is already
> running.

Yes, SetWindowPos can change the tab order of dialog box controls while the
program is running.

--
Jeff Partch [VC++ MVP]


Ali R.

unread,
Jan 26, 2004, 4:11:49 PM1/26/04
to
"Jeff Partch" <je...@mvps.org> wrote in message
news:uQkIdfE5...@TK2MSFTNGP11.phx.gbl...

It would be something like this

A.SetWindowPos(&wndTop,....,SWP_NOSIZE|SWP_NOMOVE);
C.SetWindowPos(&A,....,SWP_NOSIZE|SWP_NOMOVE);
B.SetWindowPos(&B,....,SWP_NOSIZE|SWP_NOMOVE);

Ali R.


Bjarne Nielsen

unread,
Jan 26, 2004, 4:56:28 PM1/26/04
to
>
> It would be something like this
>
> A.SetWindowPos(&wndTop,....,SWP_NOSIZE|SWP_NOMOVE);
> C.SetWindowPos(&A,....,SWP_NOSIZE|SWP_NOMOVE);
> B.SetWindowPos(&B,....,SWP_NOSIZE|SWP_NOMOVE);
>
> Ali R.
>

Well, actually it would be

A.SetWindowPos(&wndTop,....,SWP_NOSIZE|SWP_NOMOVE);
C.SetWindowPos(&A,....,SWP_NOSIZE|SWP_NOMOVE);
B.SetWindowPos(&C,....,SWP_NOSIZE|SWP_NOMOVE);

just to be pedantic :-)

--
Bjarne Nielsen


Ali R.

unread,
Jan 26, 2004, 4:58:52 PM1/26/04
to
"Bjarne Nielsen" <bnielsen_...@mail.dk> wrote in message
news:%23U6aRaF...@TK2MSFTNGP12.phx.gbl...

See, this is how you end up with bugs :) thanks Bjarne

Ali R.


Rail Jon Rogut

unread,
Jan 26, 2004, 7:05:01 PM1/26/04
to
The Z-order sets the tabbing order.

Rail
--
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro
mailto:rai...@earthlink.net


Yan-Hong Huang[MSFT]

unread,
Jan 27, 2004, 2:08:01 AM1/27/04
to
Hello Vincent,

Thanks for posting in the group.

Based on your description, the question is: How to change control's tab
order in a dialog in runtime?

A lot of community member has give your the right answer. Yes, to change
the tab order at run time you would need to call the SetWindowPos API.

Generally speaking, Microsoft Windows maintains all the windows in the
system in a list. It uses this list for purposes like painting the windows,
maintaining the z order, and so on. The order in which the child controls
(in a dialog) are created determines their position in the list and, hence,
the tabbing order. By changing the position of the windows in this list, we
can change the tabbing order. Change the window list order by calling
SetWindowPos and passing the relevant windows handles in the first
parameter (handle of the window to insert in order) and the second
parameter (handle of the window to insert after). The window handle
specified in the first parameter would come after the second in the tab
order.

If there is anything unclear, please feel free to post here. :)

Have a good day.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

0 new messages