Board index » cppbuilder » Is it possible to add components/controls to TOpenDialog Dialog box?

Is it possible to add components/controls to TOpenDialog Dialog box?


2005-08-24 05:22:45 AM
cppbuilder14
Hello,
I'm attempting to add a TEdit control to the standard TOpenDialog box. The
code I've written compiles correctly and I'm able to resize the TOpenDialog
box in order to fit the additional TEdit control I'm trying to add. The
TEdit appears to get created but it's not showing up on the TOpenDialog box.
Is what I'm trying to do possible or is it just wishfull thinking?
I've created a descending class from TOpenDialog which also includes a
TEdit control. I realize that the actual DialogBox isn't created/accessable
until a call to TOpenDialog->Execute is called. I create/initialize the
TEdit control within the OnShow event handler. (See below)
I'm assuming tht the TEdit control I create in the OnShow event handler will
need to be destroyed in the OnHide event handler since the actual dialog box
is also destroyed after the "OK" or "Cancel" buttons are pressed.
Thanks for any assistance.
James O'Brien
//********************************************************
Code for constructor and OnShow event handler
//********************************************************
__fastcall TMyOpenDialog::TMyOpenDialog(TComponent* AOwner) :
TOpenDialog(AOwner)
{
Options << ofHideReadOnly << ofShowHelp << ofOldStyleDialog <<
ofEnableSizing;
OnShow = FormShow;
}
//---------------------------------------------------------------------------
void __fastcall TMyOpenDialog::FormShow(TObject *Sender)
{
RECT R;
GetWindowRect(Handle, &R);
R.bottom+=50;
SetWindowPos(Handle,
HWND_TOP,
R.left,
R.top,
(R.right-R.left),
(R.bottom-R.top)+50,
SWP_NOACTIVATE);
CommentLabel = new TStaticText(Handle);
CommentLabel->Visible = true;
CommentLabel->Enabled = true;
CommentLabel->Left = 5;
CommentLabel->Top = (R.bottom-R.top);
CommentLabel->Width = 100;
CommentLabel->Height = 20;
CommentLabel->Caption = "Comments:";
CommentLabel->Color = clRed;
CommentEdit = new TEdit(Handle);
SearchMode = new TStaticText(Handle);
}
//---------------------------------------------------------------------------
 
 

Re:Is it possible to add components/controls to TOpenDialog Dialog box?

"James O'Brien" < XXXX@XXXXX.COM >wrote in message
Quote
OnShow = FormShow;
You should not be doing that. Components should NEVER assign handlers to
their own events. That prevents external user code from being able to use
those same events without overriding your own handlers, since an event can
only have one handler assigned at a time. Instead, you should be overriding
the virtual DoShow() method.
Quote
CommentLabel = new TStaticText(Handle);
You did not set the Parent window at all. You must do so, as it is the
parent window that controls visibility. In the case of a dialog, however,
use the ParentWindow property instead of the Parent property. For example:
__fastcall TMyOpenDialog::TMyOpenDialog(TComponent* AOwner) :
TOpenDialog(AOwner)
{
CommentLabel = new TStaticText(this);
CommentLabel->Caption = "Comments:";
CommentLabel->Color = clRed;
CommentEdit = new TEdit(this);
SearchMode = new TStaticText(this);
Options << ofHideReadOnly << ofShowHelp << ofOldStyleDialog <<
ofEnableSizing;
}
void __fastcall TMyOpenDialog::DoShow()
{
RECT R;
GetWindowRect(Handle, &R);
SetWindowPos(Handle,
NULL,
0,
0,
(R.right-R.left),
(R.bottom-R.top) + 50,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
CommentLabel->ParentWindow = Handle;
CommentLabel->Left = 5;
CommentLabel->Top = (R.bottom-R.top);
// set up CommentEdit and SearchMode as needed ...
TOpenDialog::DoShow();
}
Gambit
 

Re:Is it possible to add components/controls to TOpenDialog Dialog box?

Hi,
You can try to use our Dialog Workshop for Delphi/C++Builder.
All our customized dialogs allow to "dock" your own Delphi form to the left,
top,
right or bottom of original common dialog window. You can assign your form
and
preview resulting dialog at design-time without leaving your IDE.
Also we have .NET and VCL.NET editions.
Please visit www.componentage.com for details.
Sergey
"James O'Brien" < XXXX@XXXXX.COM >wrote in message
Quote
Hello,

I'm attempting to add a TEdit control to the standard TOpenDialog box.
The code I've written compiles correctly and I'm able to resize the
TOpenDialog box in order to fit the additional TEdit control I'm trying to
add. The TEdit appears to get created but it's not showing up on the
TOpenDialog box. Is what I'm trying to do possible or is it just wishfull
thinking?


I've created a descending class from TOpenDialog which also includes a
TEdit control. I realize that the actual DialogBox isn't
created/accessable until a call to TOpenDialog->Execute is called. I
create/initialize the TEdit control within the OnShow event handler.
(See below)

I'm assuming tht the TEdit control I create in the OnShow event handler
will need to be destroyed in the OnHide event handler since the actual
dialog box is also destroyed after the "OK" or "Cancel" buttons are
pressed.

Thanks for any assistance.
James O'Brien


//********************************************************
Code for constructor and OnShow event handler
//********************************************************

__fastcall TMyOpenDialog::TMyOpenDialog(TComponent* AOwner) :
TOpenDialog(AOwner)
{

Options << ofHideReadOnly << ofShowHelp << ofOldStyleDialog <<
ofEnableSizing;
OnShow = FormShow;
}
//---------------------------------------------------------------------------



void __fastcall TMyOpenDialog::FormShow(TObject *Sender)
{

RECT R;
GetWindowRect(Handle, &R);
R.bottom+=50;
SetWindowPos(Handle,
HWND_TOP,
R.left,
R.top,
(R.right-R.left),
(R.bottom-R.top)+50,
SWP_NOACTIVATE);


CommentLabel = new TStaticText(Handle);
CommentLabel->Visible = true;
CommentLabel->Enabled = true;
CommentLabel->Left = 5;
CommentLabel->Top = (R.bottom-R.top);
CommentLabel->Width = 100;
CommentLabel->Height = 20;
CommentLabel->Caption = "Comments:";
CommentLabel->Color = clRed;



CommentEdit = new TEdit(Handle);
SearchMode = new TStaticText(Handle);



}
//---------------------------------------------------------------------------





 

{smallsort}

Re:Is it possible to add components/controls to TOpenDialog Dialog box?

Quote
You did not set the Parent window at all. You must do so, as it is the
parent window that controls visibility. In the case of a dialog, however,
use the ParentWindow property instead of the Parent property. For
example:
This corrected the problem, I can now see the additional components on the
TOpenDialog
once the dialog box has been resized
Quote
>OnShow = FormShow;

You should not be doing that. Components should NEVER assign handlers to
their own events. That prevents external user code from being able to use
those same events without overriding your own handlers, since an event can
only have one handler assigned at a time. Instead, you should be
overriding
the virtual DoShow() method.
Aside from preventing external user code from overriding event-handler, is
there another reason not do do this? (ie. stability)
There are some events which don't have an equivalent "Do??????" method (For
instance: TOpenDialog::OnFolderChange or
TOpenDialog::OnSelectionChange). My goal is to have a modified TOpenDialog
component which updates an edit window when a file selection change has
occurred. I'd rather not have to supply these event-handlers from outside
the class.
Thanks,
James O'Brien
 

Re:Is it possible to add components/controls to TOpenDialog Dialog box?

"James O'Brien" < XXXX@XXXXX.COM >wrote in message
Quote
Aside from preventing external user code from overriding event-handler,
is
there another reason not do do this? (ie. stability)
No.
Quote
There are some events which don't have an equivalent "Do??????" method
(For instance: TOpenDialog::OnFolderChange or
TOpenDialog::OnSelectionChange).
Yes, they do. TOpenDialog has virtual DoFolderChange() and
DoSelectionChange() methods, respectively.
Gambit
 

Re:Is it possible to add components/controls to TOpenDialog Dialog box?

Hello,
Quote
Yes, they do. TOpenDialog has virtual DoFolderChange() and
DoSelectionChange() methods, respectively.

I'm not finding anything in Borland's documentation that these exist for
TOpenDialog.
I've written the code for DoSelectionChange() and it compiles, but it never
gets called when file list-box selection
is changed.
I used the same steps in creating DoShow() and DoHide() both of which are
being called at the appropriate times.
James O'Brien
 

Re:Is it possible to add components/controls to TOpenDialog Dialog box?

"James O'Brien" < XXXX@XXXXX.COM >wrote in message
Quote
I'm not finding anything in Borland's documentation that
these exist for TOpenDialog.
They are not listed in the documentation, but they are available in the code
nonetheless. You can look in Dialogs.hpp to verify that for yourself.
Quote
I've written the code for DoSelectionChange() and it compiles,
but it never gets called when file list-box selection is changed.
Then you likely did not declare it properly. Please look at Dialogs.hpp,
and show your actual code.
Gambit