Within the context of Borland C++ Builder, not a pure API program, here is an example of an Explorer-Style Custom Template. This is not independent of "The Explorer Hook Procedure" and "Extending TOpenDialog, API Solution". However, you don't need to have a hook procedure to use a custom template. But you do need to use the material in those papers to force Windows to use your custom template.
You should review the Microsoft Win32 SDK documents about common dialog templates. Note that your template can not replace the default template, or prevent the creation of any of the default controls. (You can hide default controls if you wish.) You should be able to change the text of added controls by sending messages like this:
SetDlgItemText((static_cast<TOpenDialog*>(hwnd)),edSHOWCMNT,(LPCTSTR)"Clicked!!");
Note that this can't be done in the constructor of your derived dialog, because the controls don't yet exist. You have to do it in the OnShow event of the BCB-derived dialog. You'll also be able to collect input data from controls if you interrogate them in response to an Event that the VCL provides, like OnSelectionChange. But you won't be able to receive button-press messages from the controls in a custom template unless you also install an Explorer-Style Hook Procedure.
Although I haven't tried it yet, one reason for using a template, but no hook procedure might be to reserve space above the default controls, but then use the "...VCL Solution" to insert and operate new controls in that space. The SDK document "Open and Save As ..." explains how to reserve space above the "static rectangle", using a custom template that defines the special control labelled stc32.
If you need to do this, also read Q86720, because it describes the stc32 processing in another way. It's a difficult concept. Kent Reisdorph wrote a nice article on the same topic, "Extending the common dialogs"
BCB makes it very easy to add the dialog resource to a project you devlop in the IDE. Just use the "Project" menu item to "Add to Project" two files like the ones below:
#ifndef CustIDsH #define CustIDsH #define USERIDS 0x0EED #define pbPRNTFILE (USERIDS+1) #define lbSHOWNAME (USERIDS+3) #define edSHOWNAME (USERIDS+4) #define lbSHOWCMNT (USERIDS+5) #define edSHOWCMNT (USERIDS+6) #define lbOBSNVERS (USERIDS+7) #define edOBSNVERS (USERIDS+8) #endif
#include "dlgs.h" #include "custids.h" MYOPNDLG DIALOG DISCARDABLE 0, 0, 300, 70 STYLE WS_CHILD | WS_CLIPSIBLINGS| DS_3DLOOK | DS_CONTROL FONT 8, "MS Sans Serif" BEGIN PUSHBUTTON "Print File",pbPRNTFILE,222,0,50,14,WS_GROUP LTEXT "Show Name:",lbSHOWNAME,5,8,42,9,NOT WS_GROUP EDITTEXT edSHOWNAME,50,6,150,12,ES_AUTOHSCROLL | ES_OEMCONVERT LTEXT "Show Cmnt:",lbSHOWCMNT,5,26,40,9,NOT WS_GROUP EDITTEXT edSHOWCMNT,50,24,170,12,ES_AUTOHSCROLL | ES_OEMCONVERT LTEXT "Obsn:",lbOBSNVERS,222,26,30,9,NOT WS_GROUP EDITTEXT edOBSNVERS,242,24,35,12,ES_AUTOHSCROLL | ES_OEMCONVERT END
The window title is not part of the template. It's set in the constructor, using the inherited VCL Title property.
If it has a slightly unfinished appearance, that's because I abandoned this approach in favor of "Extending TOpenDialog, VCL Solution". But there's merit to both methods.
|