I have written a class derived from TOpenDialog, for the purpose of adding
room at the top of the dialog to place a few controls. I did this by
following the TOpenPictureDialog source in extdlgs.pas. I figured out that
the only way to modify the size of the form is in the ::Execute()
function.........
bool __fastcall TOpenDcc::Execute(void)
{
if (NewStyleControls && !(Options.Contains(ofOldStyleDialog)))
Template = "DLGTEMPLATE";
else
Template = NULL;
return TOpenDialog::Execute();
}
Somehow by setting Template to "DLGTEMPLATE", extra space on the right of
the dialog is added for more controls. Otherwise, there doesn't seem to be
any way to modify the size of the dialog. How can I add extra space up top?
What is Template?
Thanks in advance,
Jonathan
http://support.microsoft.com/support/kb/articles/Q132/9/09.asp
http://support.microsoft.com/support/kb/articles/Q86/7/20.ASP
http://support.microsoft.com/support/kb/articles/Q102/3/32.asp
What's not clear is where to get the raw dialog if you don't have VC++
or MFC. I have an SDK, but I haven't found the dialog templates yet.
I think much of this is easier, because TOpenDialog "has the hook"
into the dialog already.
So much for the "right" way to do it. I modified a Yoto Yotov post on
*moving* the dialog to increase both the width and height, within the
VCL wrapper. I'm not sure you can then move the Static Rectangle of
basic controls, as it's called, to make room *above* as you want.
Please post what you learn, this is a popular topic:
void __fastcall TForm1::OpenDialog1Show(TObject *Sender)
{
RECT rect;
GetWindowRect(GetParent(dynamic_cast<TOpenDialog*>
(Sender)->Handle), &rect);
const int DialogWidth = rect.right - rect.left +80; // 80 pixels
more
const int DialogHeight = rect.bottom - rect.top +80; // and
centered on parent
MoveWindow(GetParent(dynamic_cast<TOpenDialog*>
(Sender)->Handle),
(Width-DialogWidth)/2 + Left,
(Height-DialogHeight)/2 + Top,
DialogWidth, DialogHeight, true);
Abort();
}
Yoto's original post: http://thunder.prohosting.com/~cbdn/cd002.htm
--
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
Jonathan Halterman <ilmaestro> wrote in message
news:3aa05000$1_2@dnews...
> I have written a class derived from TOpenDialog, for the purpose of
adding
> room at the top of the dialog to place a few controls. I did this by
<snip>
robert
I managed to find the resource template for the "DLGTEMPLATE" Dialog, which
is the one that TOpenPictureDialog uses.
CBuilder4/Source/Vcl/ extdlgs.rc
I have also found a few (old) freeware delphi components which create their
own dialogs based on a resource template. This method seemed to work great
for them so I am determined to go this route myself. The only problem is I
cannot manage to use any of the custom resource templates I have found in my
own custom TOpenDialog class. I have even tried renaming Borland's
DLGTEMPLATE (found in extdlgs.rc) and using it under a different name, but
no luck. When I ::Execute() my dialog, nothing happens.
#pragma resource "extdlgs.res" ///include the compiled resourced containing
a renamed DLGTEMPLATE dialog
bool __fastcall TOpenDcc::Execute(void)
{
if (NewStyleControls && !(Options.Contains(ofOldStyleDialog)))
Template = "NEWDLGTEMPLATE";
else
Template = NULL;
return TOpenDialog::Execute();
}
renaming the dialog in the template resource and including it does not seem
to work for me. Perhaps I have to include the resource in some special way?
I know this can work. Like I said, it has worked for several delphi
components. They all use their own resource templates and all seem pretty
simple and based on the TOpenPictureDialog concept.
Regards,
Jonathan
Timothy H. Buchman <tbuc...@citycenter.org> wrote in message
news:3aa0808f_1@dnews...
> Look for the *.dlg files in the [BCB5]/include folder.
Thanks. I did find them, but unfortunately this project is stuck in BCB4,
and BCB4 seems to get its dialog resources from somewhere else....
Source\Vcl\extdlgs.rc
Lib\Object\extdlgs.res
Either way, I should be able to use either resource file in my application.
My real problem is actually using a modified dialog resource template in my
application. I don't think that it would be too hard as I have seen several
delphi components that do it. As far as I know, it is as simple as...
#pragma resource "ModifiedResourceFile.res"
bool __fastcall TOpenDcc::Execute(void)
{
if (NewStyleControls && !(Options.Contains(ofOldStyleDialog)))
Template = "MODIFIEDDLGTEMPLATE";
....but, I have not been able to get this to work. Do you know the correct
way to use a modified or custom dialog resource template?
Jonathan
I finally found what you need on another one of my machines: Go
immediately to
http://members.nbci.com/_XMCM/mitov/Downloads/body_downloads.html
(home is http://members.nbci.com/mitov/ )and download Boian Mitov's
TBMMediaDialogs. When you unzip it, you'll have a complete, working
*BCB3* sample of extending the TOpenDialog to examine. It *does not*
show how to get empty space *above* the StaticRect controls.
Friendly warning: Trim down your >previous message quotations or
you'll attract attention from the newsgroup managers.
On your notes:
> bool __fastcall TOpenDcc::Execute(void)
> {
> if (NewStyleControls && !(Options.Contains(ofOldStyleDialog)))
> Template = "NEWDLGTEMPLATE";
> else
> Template = NULL;
> return TOpenDialog::Execute();
> }
>
> renaming the dialog in the template resource and including it does
not seem
> to work for me. Perhaps I have to include the resource in some
special way?
I notice that Yoto Yotov assigns the VCL Template property in the
*constructor*
http://thunder.prohosting.com/~cbdn/cd005.htm ,not in the Execute
method. (This site is not is good working shape, that's why I didn't
give you this link before.)
Because the MERS search site is down this weekend, I'm quoting at
length from a man who is seldom wrong, Kent Reisdorph:
"1. Create a dialog resource using a resource editor (I use Borland
C++
5.02). The dialog resource should contain only those controls you want
added
to the common dialog. Also, the dialog resource must have the WS_CHILD
window style and, if I recall, the WS_CLIPSIBLINGS style as well.
2. Add the RC file containing the dialog resource to the project.
3. Derive a class from TOpenDialog. You have to do this because...
4. Assign the name of the dialog to the Template property of your new
class.
Template is protected in TOpenDialog so you have to derive a class to
be
able to access the protected property.
I'll add that getting all of this working right can take some time and
can
be frustrating. That's the best I can do in a short message.<g>["END
QUOTE]
Paragraph 1 suggests that you don't get "a chance" to put new
coordinates
for the "old" controls into your template. Does that make this method
futile for your needs? Or are you willing to give up and put your new
controls to the bottom and right?
Skim this for some similar points:
http://msdn.microsoft.com/library/techart/msdn_cmndlg32.htm
Best of luck,
> I finally found what you need on another one of my machines:
I came across Boian's component sometime yesterday. At first I was excited,
but actually his component uses the same DLGTEMPLATE template that
TOpenPictureDialog uses, which simply adds space on the right for more
controls. The only difference between Boian's component and
TOpenPictureDialog is that Boian's preview window displays media as well as
images. I am still trying to figure out how to get a different dialog
template to work in builder. The delphi components that I found which do
this, work in delphi, but in builder ::Execute() does nothing. Also, I love
the simplicity of Yoto Yotov's method, but it doesn't seem that the Static
control rect can be moved. I am still determined to get the dialog templates
to work, mostly because they 'should' work, but aren't.
Regards,
Jonathan
> I notice that Yoto Yotov assigns the VCL Template property in the
> *constructor*
> http://thunder.prohosting.com/~cbdn/cd005.htm ,not in the Execute
> method.
I forgot to mention my results with regards to Yoto Yotov's article. I tried
assigning the Template in the constructor to no avail. Actually, I created a
quick sample application following Yoto's article exactly, and
Dialog->Execute() does nothing, just as in my application. I am starting to
think that there is something wrong with my Builder settings, or something
related to builder.
Jonathan
Jonathan
No, I have looked into it from time to time, but I never actually coded
anything. Have you looked at the Customizing Common Dialog Boxes topic
in the WinAPI help?
robert
Using the MSDN reference above, and the secret that stc32 is 0x045F, I
used this custom template. It has the desired result of moving what
is called the StaticRectangle (of course it has more than static
controls in it) *down and right*. I also learned that stc32 *is* the
dialog item ID for the StaticRectangle. Needless to say, the second
LTEXT line below is based on the MSDN link above.
MYDIALOG DIALOG DISCARDABLE 0, 0, 100, 40
STYLE WS_CHILD | WS_CLIPSIBLINGS
| DS_3DLOOK | DS_CONTROL
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "I'm Customized!",4000,20,5,50,15
LTEXT "",0x045F,30,30,8,8,NOT WS_VISIBLE | NOT WS_GROUP
END
-------
Timothy H. Buchman
========================================
City Center Theater, New York NY
mail address tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Please treat this signature information as confidential.
========================================
Search .borland message archive on http://www.mers.com/searchsite.html
Jonathan Halterman <ilmaestro> wrote in message
news:3aa1df41$1_2@dnews...
> Using the MSDN reference above, and the secret that stc32 is 0x045F, I
> used this custom template. It has the desired result of moving what
> is called the StaticRectangle (of course it has more than static
> controls in it) *down and right*. I also learned that stc32 *is* the
> dialog item ID for the StaticRectangle.
Thanks a lot for your help. I have successfully modified my opendialog class
to look just like I want it, moving the static rectangle down. I am not sure
if you knew why I created the thread in 'components.using' group.
Apparently, the reason that the custom dialogs only worked by unchecking
'Build with runtime packages,' was related to a VCL bug that seems to exist
in Builder and Delphi. A message in delphi.objectpascal written by Peter
Below points out how to fix this so that custom dialogs work no matter what.
http://groups.google.com/groups?q=topenfilename&hl=en&lr=&safe=off&rnum=8&se
ld=919515187&ic=1
another resonse to the same problem is...
http://groups.google.com/groups?q=topenfilename&hl=en&lr=&safe=off&rnum=10&s
eld=926547392&ic=1
In the message I posted in components.using, I was just attempting to
convert the delphi code to be used in builder, but I was having trouble
casting to the TOpenFilename class, which is no problem in delphi. I am not
sure whether or not I will ultimately want to compile the runtime packages
into my application, but chances are that I will not, so it would be useful
to get this fix working in builder. It works great in delphi (I gave it a
try).
Thanks a lot,
Jonathan.
My last post. I got the fix working in Builder. A simple custom dialog can
now be created by following Yoto Yotov's article, and doing something like
this...
BOOL __fastcall TMyOpenDialog::TaskModalDialog(void * DialogFunc, void
*DialogData) ///overloaded function
{
((LPOPENFILENAMEA)DialogData)->Flags =
((LPOPENFILENAMEA)DialogData)->Flags | OFN_ENABLETEMPLATE;
((LPOPENFILENAMEA)DialogData)->lpTemplateName = "MYDLGTEMPLATE";
((LPOPENFILENAMEA)DialogData)->hInstance =
(void*)FindClassHInstance(this->ClassType());
return TCommonDialog::TaskModalDialog(DialogFunc, DialogData);
}
I hope you keep track of everything we have discovered so that hopefully it
can be shared with others that come along. Thanks for all of your help.
Jonathan
It's on a different server now and it's www.mitov.com :-) . I will
update the members.nbci.com/mitov/index.html to say so.
With best regards,
Boian Mitov