Dialog Templates in Memory

This article was previously published under Q155257
This article has been archived. It is offered "as is" and will no longer be updated.
Dialog boxes can be created by using templates in resources or from templates built in memory at run time. The sample contains a class CDlgTempl, which can be used to create these templates in memory. This class provides an easy interface for building and manipulating templates in memory.

The following files are available for download from the Microsoft Download Center:


For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

More information
The DLGTEMPLATE and DLGITEMTEMPLATE structures are used for building templates in memory. These structures are not fixed-length structures. They also must aligned properly.

This sample provides a class to build these structures correctly. It also provides the ability to read a template from the resource and then manipulate them. Some of the important functions are:
SetDlgTemplate Sets some of the properties of the dialog box.

SetCaption Sets the caption for the dialog box.

AddControl Adds a control to the template.

RemoveControl Removes a control from the template.

MoveControl Changes the TAB order of the control.

LockTemplate Returns a pointer to memory that contains the dialog box template in a form that can be used with CreateDialogIndirect.

UnlockTemplate Should be called to free the memory allocated by LockTemplate.

CreateTemplateInMemory Fills the memory passed into the function with the dialog box template.

FromResource Initializes the object with information from the template in resource.
The sample illustrates using the class by loading the about box from resource and changing the Caption for the dialog box.
See the Win32 SDK.
4.00 4.10 4.20 DLGTEMPLATE DLGITEMTEMPLATE kbDSupport kbdsi

Article ID: 155257 - Last Review: 11/02/2013 23:40:00 - Revision: 4.0

Microsoft Foundation Class Library 4.2

  • kbnosurvey kbarchive kbdownload 4.00 kbdialog kbdlg kbfile kbgrpdsmfcatl kbnokeyword kbresource kbsample KB155257
ERROR: at System.Diagnostics.Process.Kill() at Microsoft.Support.SEOInfrastructureService.PhantomJS.PhantomJSRunner.WaitForExit(Process process, Int32 waitTime, StringBuilder dataBuilder, Boolean isTotalProcessTimeout)