Home > C++, VC++, MFC > Creating a dialog from it’s template!

Creating a dialog from it’s template!

Here is a sample on how to do it…

CDialogTemplate dlgTemplate;
// Load dialog template into memory
dlgTemplate.Load( MAKEINTRESOURCE( IDD_DIALOG_ID ));
// Change font of dialog
dlgTempl.SetFont( _T( "Courier" ), 10 ); 

// Creates and displays a modal dialog from a template in memory
CDialog dlg;
dlg.InitModalIndirect( dlgTemplate.m_hTemplate, 0 );
dlg.DoModal();

What’s the use of this? Well you can change the font of dialog at runtime? Just call dlgTemplate.SetFont. This changes the font of entire dialog. Cool isn’t it!

To use CDialogTemplate include “afxpriv.h”. Microsoft(R) says that this file could be changed in near future, so use with care.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: