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()
{
	CDialog::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 );
   UINT nFlags = SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE;

   ::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



Comments

  • 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=http://www.zyprexabuyonline.com/#56-cheap-zyprexa-online-pharmacy]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.

    Reply
  • 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=http://www.prozacbuyonline.com/#28-purchase-cheap-prozac-online]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...

    Reply
  • 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

    Reply
  • 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=http://www.lexaprobuyonlinepills.com#purchase-lexapro-no-rx-cheap]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

    Reply
  • 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=http://www.prozacbuyonline.com/#54-purchase-prozac-medication-cheap] Prozac Online Medication Cheap [/url] prozac bad bipolar Prozac Medication how does prozac cause weight gain

    Reply
  • 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

    Reply
  • purchase Xanax online

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

    Buy Xanax Generic Order Cheap Alprazolam Generic - Order Alprazolam Cheap

    Reply
  • 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=http://www.diazepambuyonlinemed.com/#873605-order-valium-anxiety-treatment]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.

    Reply
  • 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=http://www.onlinetramadolbuy.net/#discount-tramadol]purchase tramadol[/url] 1997 purchase tramadol online, Cheap Ultram Price - cheap tramadol. ultram detox. Ultram online pharmacies. tramadol and ibuprofen

    Reply
  • purchase Tramadol online

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

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

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • Do you know where your data is? Consumer cloud-based file sharing services store your sensitive company data on servers outside of your control, outside of your policy and regulatory guidelines – maybe even outside your country – and not managed by you. The potential for data leakage, security breaches, and harm to your business is enormous. Download this white paper to learn about file sync and share alternatives that allow you to manage and protect your sensitive data while integrating and …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds