Modeless child dialog in a Main Dialog with corrected tab order

This article was written to help the programmer put a modeless child dialog "into" another dialog and maintain the proper tab order for the new combination.


Normally when a modeless child dialog is created and placed in a parent dialog, the tab order follows the parent dialog. This is illustrated in the in the following picture. The first tab item (5) of the child dialog follows the last tab item of the parent (4)


What we would like to have is the first child tab item following the control of choice in the main dialog:


To perform this feat is fairly simple but if you dont know how to do it you may spend quite a few hours coding pretranslate messages and setting focus to controls.


Step 1: Create the Main dialog and the child dialog using the dialog editor. Create classes for the dialogs using the class wizard. Then change some properties of the child dialog:

The child dialog will have the "child dialog" and the "control" style. Note: I have set the border to thin, but in this example the border will not show up because of the control style.

Using the dialog editors properties dialog, set the CHILD dialog styles as follows:


You will also have click on the More Styles tab and set the "control" style:


To make the child dialog show up exactly where is designed to show up on the main dialog, the X,Y locations in the general tab can be set. The child dialog will show up in this application at X = 23 and Y = 36.



Step 2:

The program will compile now and it will run, but the child dialog will not show up on the main dialog. You will have to place an instance of the child dialog in the main dialog class. Include the header file for the child dialogs class and create a member variable for the child dialog:

#include "ChildDialog.h"

class CDlgSampleDlg : public CDialog
   CChildDialog m_child;


Since the child dialog will need a CWnd pointer in the constructor you will have to place the m_child variable in the constructor for the main dialog.

CDlgSampleDlg::CDlgSampleDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgSampleDlg::IDD, pParent),
	m_child( this )
	// Dialog constructor code

The next coding you will perform is a call to Create via the child dialog member variable in the OnInitDialog function of the main dialog. Dont forget to show the window after you create the child dialog

BOOL CDlgSampleDlg::OnInitDialog()

   m_child.Create( IDD_CHILD_DIALOG, this );
   m_child.ShowWindow( TRUE );


At this point the project should compile and run. However the tab order will not be what we originally set out to correct. To fix the tab order the following code will have to be inserted at the end of the OnInitDialog function:

	// TODO: Add extra initialization here

   CWnd * pWnd = GetDlgItem( IDC_CONTROL_1 );

   ::SetWindowPos( m_child.m_hWnd, pWnd->m_hWnd, 0, 0, 0, 0, nFlags );
   return TRUE;


The ID "IDC_CONTROL_1" is the control in the main dialog that will be just before the first tab order item in the child dialog.


Compile the program, run it and tab through the controls the child dialogs controls will follow the correct tabbing order as expected.

Download demo project - 5 KB

Download source - 12 KB


  • order generic Zyprexa Olanzapine online

    Posted by BuyZyprexa56 on 07/09/2013 08:20am

    Changes made to regular dietary consumption can also make a big difference to the severity of your anxiety problems. order Zyprexa 2mg online buy cheap Zyprexa online without a prescription You would be even more surprised then, because these are just to name a very small few. [url=]order Zyprexa 10mg online[/url] Looking for your signs of anxiety, get your Free Report on the 5 top causes of Stress and take control of your life now.

  • buy Prozac 10mg online without a prescription

    Posted by ProzacOnline23 on 07/04/2013 08:14pm

    Recent stressful life experiences purchase Prozac online no prescription order generic Prozac Fluoxetine online no prescription When to get emergency help [url=]purchase Prozac online without a prescription[/url] Chronic depression symptoms differ on many levels from major depression symptoms. Often, chronic depression is caused by an environmental stressor such as...

  • Purchase Olanzapine Drug Cheap

    Posted by Kristen162 on 07/02/2013 12:33pm

    Purchase Cheap Olanzapine Online Medication Purchase Zyprexa Online Without Rx - zyprexa false claims act

  • order Escitalopram online without a prescription

    Posted by Traistasteway on 06/30/2013 11:22pm

    or, at the most, only marginal benefit, in a fourth study. Marital or relationship problems lexapro side effects last long. Family and Pregnancy Centers did anyone lose weight lexapro. Buy Cheap Lexapro, Read Full Article- [url=]lexapro[/url] 1999 generic lexapro online, Order Cheap Lexapro Online - buy generic lexapro online. my experience lexapro. Enter Search Keywords. Use the arrow keys to navigate suggestions. lexapro anxiety panic

  • buy cheap Prozac online no prescription

    Posted by BuyProzac17 on 06/25/2013 02:06am

    prozac forum ufficiale Purchase Cheap Fluoxetine Medication side effects of increasing prozac dosage [url=] Prozac Online Medication Cheap [/url] prozac bad bipolar Prozac Medication how does prozac cause weight gain

  • purchase cheap Tramadol online no prescription

    Posted by higImmimi on 06/24/2013 04:24pm

    Cheap Tramadol Online Without Rx Ultram Online Cheap - Order Cheap Ultram Without a Prescription

  • purchase Xanax online

    Posted by Mataundenrepe on 06/02/2013 04:09pm

    Buy Xanax Generic Order Cheap Alprazolam Generic - Order Alprazolam Cheap

  • purchase Valium online

    Posted by Fraveartebamb on 05/30/2013 05:27am

    Besides, like every drug, you can get addicted to it! order Valium 2mg online without a prescription buy generic Valium Diazepam online One of the worst things about panic disorder is that the attacks are totally unpredictable, and can even strike while the individual is sleeping. [url=]order Diazepam online without a prescription[/url] They claim to treat anxiety and panic attacks with no medications, in a couple of weeks and with truly extraordinary success rates.

  • buy cheap Tramadol online

    Posted by atosurbassy on 05/30/2013 12:05am

    Created by some of the world's leading aromatherapists for their own practices to relieve pain and heal specific shown that the analgesic potency of an oral dose of 100 mg of tramadol is equivalent to 1000 mg of acetaminophen. tramadol restless legs. Tadalafil 20mg $1. tramadol high like vicodin. Tramadol Generic Cheap, Look At This- [url=]purchase tramadol[/url] 1997 purchase tramadol online, Cheap Ultram Price - cheap tramadol. ultram detox. Ultram online pharmacies. tramadol and ibuprofen

  • purchase Tramadol online

    Posted by antedeknire on 05/27/2013 03:38pm

    Tramadol Online Cheap Ultram Drug Cheap - Purchase Cheap Ultram Online Pharmacy

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date