Default
Google

How can I add controls to an OpenDialog?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

I would like to add additional controls to the OpenDialog. Is it possible to extend this component?
 
 
 1.
  Create using a resource editor or a text editor the appropriate dialog

      that will be merged with OpenDialog. For example, using C++Builder,

      go to File | New... and choose Text. Enter the following:
 
MYDIALOG DIALOG 0, 0, 200, 40
STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
    | DS_3DLOOK | DS_CONTROL
FONT 8, "MS Sans Serif"
BEGIN
    CONTROL "This is an extended OpenDialog.",
    555, "STATIC", SS_LEFT | WS_CHILD |
    WS_VISIBLE, 5, 15, 195, 15
END
 
 2.
  Save your resource file as MYDIALOG.RC.
 
 3.
  Start a new application.
 
 4.
  Go to Project | Add to Project... and choose MYDIALOG.RC.
 
 5.
  Insert in your header file:
 
class TExOpenDialog : public TOpenDialog
{
public:
    __fastcall TExOpenDialog(TComponent *Owner);
};
 
 6.
  Insert in your source code:
 
__fastcall TExOpenDialog::TExOpenDialog(TComponent *
    Owner) : TOpenDialog(Owner)
{
    Template = "MYDIALOG";
}
 
 7.
  Add a Button. Edit its OnClick event:
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TExOpenDialog *Dialog = new TExOpenDialog(this);
    Dialog->Execute();
    delete Dialog;
}
 
Tips
- Some versions of C++Builder come with the Resource Workshop editor. You could use it to create your dialogs.
- Your dialog resource must have the following styles: WS_CHILD and WS_CLIPSIBLINGS.

C++Builder Developer's Network
Copyright © Yoto Yotov



Acquiring image from ProHosting Banner Exchange