Question about control tab order

Question about control tab order

Postby GeorgeW » Fri May 04, 2012 12:15 pm

Greetings.

I need to set up the Tab Order of some GET/COMBOBOX controls during run time, and I cannot find any way of doing it.

I know the default Tab Order is arranged in the same order as the control declarations (either in the .rc file, or when defining the controls in your code).

Unfortunately, I have a basic dialog with some pre-designed controls in a resource (.RC) file. This RC file, per requisites, cannot be modified at all.
Then, during the program execution, and depending on user input, I need to paint some other controls (Gets and maybe Comboboxes) in that same dialog. Then I need to rearrange the tab order of the controls, so the window behaves as expected (my 'runtime' controls must be usually painted in the middle of the window, and the Tab is required to smootly go from the top to the bottom of the dialog).

Right now, following the default behavior, tabbing make a first up-down pass focusing first all the .RC painted controls, and after that, another up-down pass focusing the controls I created on the fly.

Any ideas? Thank you in advance.

George.
GeorgeW
 
Posts: 3
Joined: Fri May 04, 2012 12:05 pm

Re: Question about control tab order

Postby Antonio Linares » Fri May 04, 2012 6:42 pm

George,

You may use SetWindowPos() to change the tab order of a control:

SetWindowPos( hWndControl, hWndControlInsertAfter, 0, 0, 0, 0, nOr( SWP_NOMOVE, SWP_NOSIZE ) )

i.e., if you have two GETs, oGet1 and oGet2, then:

SetWindowPos( oGet2:hWnd, oGet1:hWnd, 0, 0, 0, 0, nOr( SWP_NOMOVE, SWP_NOSIZE ) )

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Question about control tab order

Postby Antonio Linares » Fri May 04, 2012 6:45 pm

Also, as controls are kept in oDialog:aControls, it may also be required to swap their order there:

oPrev = oDialog:aControls[ n ]
oNext = oDialog:aControls[ n + 1 ]

oDialog:aControls[ n ] = oNext
oDialog:aControls[ n + 1 ] = oPrev
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Question about control tab order

Postby GeorgeW » Mon May 07, 2012 6:32 am

Hey!
Many many thanks for the answer. I'll try this as soon as I get to my office.

Regards

G.
GeorgeW
 
Posts: 3
Joined: Fri May 04, 2012 12:05 pm

Re: Question about control tab order

Postby GeorgeW » Mon May 07, 2012 7:18 am

Works like a charm!

Thank you again. ;)

G
GeorgeW
 
Posts: 3
Joined: Fri May 04, 2012 12:05 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 104 guests