FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Question about control tab order
Posts: 3
Joined: Fri May 04, 2012 12:05 PM
Question about control tab order
Posted: 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.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Question about control tab order
Posted: Fri May 04, 2012 06: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Question about control tab order
Posted: Fri May 04, 2012 06: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
Posts: 3
Joined: Fri May 04, 2012 12:05 PM
Re: Question about control tab order
Posted: Mon May 07, 2012 06:32 AM

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

Regards

G.

Posts: 3
Joined: Fri May 04, 2012 12:05 PM
Re: Question about control tab order
Posted: Mon May 07, 2012 07:18 AM

Works like a charm!

Thank you again. ;)

G

Continue the discussion