Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding a Control to a Common Dialog

2 views
Skip to first unread message

Mauricio Díaz

unread,
Jun 21, 2001, 12:04:45 PM6/21/01
to
How can i add a control to "TPrintDialog"


Timothy H. Buchman

unread,
Jun 22, 2001, 9:41:32 AM6/22/01
to
Mauricio Díaz <mad...@epm.net.co> wrote in message
news:3b321a32_2@dnews...

> How can i add a control to "TPrintDialog"

Start by reading these sites:
http://thunder.prohosting.com/~cbdn/cd005.htm

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui
/hh/winui/commdlg3_7yib.asp
(long link-repaste in browser URL line)

Because there is a bug in the Borland run-time code, you *also* have
to override a VCL routine like this (I derived from TOpenDialog):

in header:
public:
__fastcall TObsOpenDialog(TComponent * Owner);// Constructor

BOOL __fastcall TObsOpenDialog::TaskModalDialog(void * DialogFunc,
void
*DialogData);


in .cpp:
BOOL __fastcall TObsOpenDialog::TaskModalDialog(void * DialogFunc,
void
*DialogData) // override Dialogs::TOpenDialog method
{
((LPOPENFILENAMEA)DialogData)->Flags =
((LPOPENFILENAMEA)DialogData)->Flags | OFN_ENABLETEMPLATE;
((LPOPENFILENAMEA)DialogData)->lpTemplateName = "MYOPNDLG";
((LPOPENFILENAMEA)DialogData)->hInstance =
(void*)FindClassHInstance(this->ClassType());
return TCommonDialog::TaskModalDialog(DialogFunc, DialogData);
}

The example in the first link above is static text. If you want to
receive button presses, you have to include an Explorer-Style Hook
Procedure, which is well-documented on MSDN. I don't have BCB5, but
the Help suggests that ExplorerHook() may be available for overriding,
which it is not in BCB3. In BCB3, you'd set the value like this, in
TaskModalDialog,

oldhookproc = ((LPOPENFILENAMEA)DialogData)->lpfnHook;
((LPOPENFILENAMEA)DialogData)->lpfnHook =ObsOpenDialogHook;

You should end your hook procedure with
oldhookproc(hwnd,msg,wParam,lParam);
so that the usual TCommonDialog VCL events will occur. Note that your
hook procedure cannot be a member function, it's a static function
like this:
UINT APIENTRY ObsOpenDialogHook(
HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

If you add an Edit control, you can fill it like this,
SetDlgItemText((static_cast<TOpenDialog*>(Handle)),
edSHOWCMNT,( LPCTSTR)c);
where edSHOWCMNT is your control identifier and c is an array of char.
"Handle" indicates that this is in a member function of the derived
dialog class.

All that said, there is a good, more VCL oriented example at
http://www.mitov.com/Dwnd/dwnd.html
as "TBMMediaDialogs" but it's not much less code. I've shown the
official Microsoft way.

--
Timothy H. Buchman
========================================
City Center Theater New York NY
tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Please treat this signature information as confidential.
========================================
Search .borland newsgroup archives at:
http://www.mers.com/searchsite.html


0 new messages