Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Tab order by code in a MFC Dialog

Tags:

tabs

mfc

I created a control by code in the OnInitDialog, but i cannot find any way to change the tab order of the dialog by code.

Anyone have any idea on how to do this?

like image 345
Lishi Avatar asked Nov 12 '10 09:11

Lishi


1 Answers


First Option

use ctrl+d on resource view in visual studio. and change tab order


Other option

An easier solution is change the sequence of controls in .rc file...that will change your tab order and z order both.

For Eg. this dialog will have Tab Order IDOK first, then IDCANCEL

IDD_ABOUT DIALOG DISCARDABLE  0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My About Box"
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON   "&OK",IDOK,174,18,50,14
    PUSHBUTTON      "&Cancel",IDCANCEL,174,35,50,14
END

now if you change it to

IDD_ABOUT DIALOG DISCARDABLE  0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My About Box"
FONT 8, "MS Sans Serif"
BEGIN
    PUSHBUTTON      "&Cancel",IDCANCEL,174,35,50,14
    DEFPUSHBUTTON   "&OK",IDOK,174,18,50,14
END

This will have Tab Order IDCANCEL first then IDOK

like image 149
Sahil Doshi Avatar answered Oct 04 '22 13:10

Sahil Doshi