Board index » cppbuilder » How to manipulate / hook the TOpenDialog ??

How to manipulate / hook the TOpenDialog ??


2003-11-06 01:56:31 PM
cppbuilder97
hi dear builders,
I got some questions about TOpenDialog..
- is it possible to manipulate the TOpenDialog to be "Resizeable" like the
MS Office OpenDialog ?
- how can I simulate a mouseclick on the "type-column" at the viewmode
"details"
so I can see all (for example) all Textfiles *.txt sorted...?
I use the following code to change the labels on the TOpenDialog..
/******************************************************************/
void __fastcall TfrmStringDetails::OpenDialogShow(TObject *Sender)
{
/*
"Up One Level"=0xA001,
"New Directory"=0xA002,
"List View"=0xA003,
"Details"=0xA004.
*/
#define DETAILS_TOOLBUTTON_CMD (0xA004)
HWND parenthandle=NULL;
OpenDialog=dynamic_cast<TOpenDialog *>(Sender);
if(OpenDialog) parenthandle = GetParent(OpenDialog->Handle);
if (parenthandle != NULL )
::PostMessage(parenthandle,WM_COMMAND, DETAILS_TOOLBUTTON_CMD, NULL);
// Label ID's changing...
SetDlgItemText(::GetParent(OpenDialog->Handle), 1089,
"Dateityp ------->");
SetDlgItemText(::GetParent(OpenDialog->Handle), 1090, "Dateiname --->");
SetDlgItemText(::GetParent(OpenDialog->Handle), 1, "?ffnen");
SetDlgItemText(::GetParent(OpenDialog->Handle), 2, "&Abbrechen");
SetDlgItemText(::GetParent(OpenDialog->Handle), 1038, "&Hilfe");
SetDlgItemText(::GetParent(OpenDialog->Handle), 1040, "&Screibgeschützt
öffnen");
SetDlgItemText(::GetParent(OpenDialog->Handle), 1091, "Suchen in");
}
Thanks for any help in advance..
Oren
 
 

Re:How to manipulate / hook the TOpenDialog ??

Oren (Halvani.de) < XXXX@XXXXX.COM >wrote in message
Quote
- is it possible to manipulate the TOpenDialog to be "Resizeable"
like the
MS Office OpenDialog ?
When you use BCB6 in WinXP or, probably, Win98, this will happen
automatically. I haven't had time to try it yet, but if the *end
user* has the latest version of comctl32.dll (name from memory...)
because of updating IE, it's likely that you could derive from
TOpenDialog, override TaskModalDialog, and add (that is, AND in) the
new switch for ...EnableResize, using BCB3. In WinAPI (not the VCL
Collection type, that is), it's
#define OFN_ENABLESIZING 0x00800000
I belive you'll find an example of overriding TaskModalDialog here
home.att.net/~secondcut/opdlgapi.htm
but it would be worth trying to put it into the Options property after
instantiating an ordinary TOpenDialog in your code. I don't know if
that will work.
Quote
- how can I simulate a mouseclick on the "type-column" at the
viewmode
"details"
so I can see all (for example) all Textfiles *.txt sorted...?
I feel it's unreliable to assume the columns will break in a certain
way, so I wouldn't "feel" my way from the Top/Left of the listview and
click blindly.... It looks like you've seen my pages on TOpenDialog.
I offer the code to sort the contents of the listview any way you
want, without clicking at all. It seems very reliable to me.
home.att.net/~secondcut/opdlglv.htm
Note that this involves OnSelectionChange, not just OnShow. Read it
carefully.
 

Re:How to manipulate / hook the TOpenDialog ??

"Timothy H. Buchman" <tbuchmanPLEASE(at sign)REMOVEcitycenter.org>
wrote in message news:3faa6d0d$ XXXX@XXXXX.COM ...
Quote
Oren (Halvani.de) < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>- is it possible to manipulate the TOpenDialog to be "Resizeable"
like the
>MS Office OpenDialog ?

I might say that I left out some boring Microsoft stuff about
combinations of Windows versions, Explorer-style dialogs, and hooked
dialogs. They're not material to BCB, because TOpenDialog is always
Explorer-style, always hooked, and in BCB6, the new option bit is
included by the VCL...
I did try this with Win98SE and BCB3 after I got home tonight. The
code below works just fine. But as I said, it depends on the user
having Win98 or above, or having a recent comctl32.dll. I've left out
the .h line, which you can deduce from the definition below:
#define OFN_ENABLESIZING 0x00800000
BOOL __fastcall TInfoOpen::TaskModalDialog(void * DialogFunc,
void* DialogData) // override Dialogs::TOpenDialog method
{
((LPOPENFILENAMEA)DialogData)->Flags =
((LPOPENFILENAMEA)DialogData)->Flags | OFN_ENABLESIZING;
((LPOPENFILENAMEA)DialogData)->hInstance =
(void*)FindClassHInstance(this->ClassType());
return TCommonDialog::TaskModalDialog(DialogFunc, DialogData);
}
 

{smallsort}

Re:How to manipulate / hook the TOpenDialog ??

hi Timothy,
when I try to compile the code you gave me I'll get these error-messages:
[C++Error] Unit_Details.cpp(218): '_fastcall
Dialogs::TCommonDialog::TaskModalDialog(void *,void *)' is not accessible.
[C++Error] Unit_Details.cpp(218): Use . or ->to call '_fastcall
Dialogs::TCommonDialog::TaskModalDialog(void *,void *)'.
any ideas...??
Oren
 

Re:How to manipulate / hook the TOpenDialog ??

Oren (Halvani.de) <neroniker>wrote in message
Quote
when I try to compile the code you gave me I'll get these
error-messages:

[C++Error] Unit_Details.cpp(218): '_fastcall
Dialogs::TCommonDialog::TaskModalDialog(void *,void *)' is not
accessible.
[C++Error] Unit_Details.cpp(218): Use . or ->to call '_fastcall
Dialogs::TCommonDialog::TaskModalDialog(void *,void *)'.
Well, I assure you that I compiled and ran my code before I posted it,
in BCB3. I realize you can't post an entire project in a newsgroup,
so you probably haven't shown the real cause of these errors. I
suspect that your code wasn't in this kind of class (and better yet,
in a separate .cpp):
class PACKAGE TResizeableDialog : public TOpenDialog
{
}
I think the easiest way to build a new component is to use File|New|
Choose "Component", but you *don't* have to "install" the component to
use it. That's a distraction with many pitfalls! In the Component
wizard, chose TOpenDialog as "Ancestor", and type TResizeableDialog as
the "Classname". But do note that you have to Save the component
files in order to #include the new component header for use in your
little Form1 test program. Here are some more complete files. In
fact, you don't have to use the New Component wizard, you can just
write the constructor (which is empty) and TaskModalDialog, if you
know how to write a derived C++ class. Because I don't have access to
BCB3 today, this was done in BCB6. That means you probably *can't*
just paste in this code, you have to use the BCB3 wizard, or just
write a new .cpp file with the constructor and TaskModalDialog as the
only other member function.
Test program in Form1:
i.e. Don't do any of your own special coding until this skeleton
works!
// ----
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "ResizeableDialog.h"
// ---
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
// ----
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
TResizeableDialog * rsd=new TResizeableDialog(this);
rsd->Title="Oren's Test";
rsd->Execute();
Application->Terminate();
}
// ----
Component header file:
// ----
#ifndef ResizeableDialogH
#define ResizeableDialogH
// ----
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Dialogs.hpp>
// ----
class PACKAGE TResizeableDialog : public TOpenDialog
{
private:
protected:
BOOL __fastcall TResizeableDialog::TaskModalDialog(void * DialogFunc,
void* DialogData); // override Dialogs::TOpenDialog method
public:
__fastcall TResizeableDialog(TComponent* Owner);
__published:
};
// ----
#endif
BCB Generated .cpp with override pasted in:
// ---
#include <basepch.h>
#pragma hdrstop
#include "ResizeableDialog.h"
#pragma package(smart_init)
// ---
// ValidCtrCheck is used to assure that the components created do not
have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TResizeableDialog *)
{
new TResizeableDialog(NULL);
}
// ----
__fastcall TResizeableDialog::TResizeableDialog(TComponent* Owner)
: TOpenDialog(Owner)
{
}
#define OFN_ENABLESIZING 0x00800000
BOOL __fastcall TResizeableDialog::TaskModalDialog(void * DialogFunc,
void* DialogData) // override Dialogs::TOpenDialog method
{
((LPOPENFILENAMEA)DialogData)->Flags =
((LPOPENFILENAMEA)DialogData)->Flags | OFN_ENABLESIZING;
((LPOPENFILENAMEA)DialogData)->hInstance =
(void*)FindClassHInstance(this->ClassType());
return TCommonDialog::TaskModalDialog(DialogFunc, DialogData);
}
// ----
namespace Resizeabledialog
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TResizeableDialog)};
RegisterComponents("Samples", classes, 0);
}
}
// ----
This was coded and run in BCB6 WinXP Pro, (but it's unnecessary
because TOpenDialog *is* resizeable there.)
 

Re:How to manipulate / hook the TOpenDialog ??

"Oren \(Halvani.de\)" < XXXX@XXXXX.COM >wrote:
Quote
hi dear builders,

I got some questions about TOpenDialog..

- is it possible to manipulate the TOpenDialog to be "Resizeable" like the MS Office OpenDialog ?

How strange. On my system MS Open Dialog (i.e. in Word is not
resizable) but in my own application the TOpenDialog is
resizable without any effort on my part. I assume that means
that at run time you can grap the bottom left hand corner and
make the window bigger or smaller.
I am using BCB4.
George.
 

Re:How to manipulate / hook the TOpenDialog ??

"george probyn" < XXXX@XXXXX.COM >wrote in message
Quote
How strange. On my system MS Open Dialog (i.e. in Word is not
resizable) but in my own application the TOpenDialog is
resizable without any effort on my part. I assume that means
that at run time you can grap the bottom left hand corner and
make the window bigger or smaller.
I am using BCB4.
If you use WinSpy or WinSight32 (part of BCB), you will see that the
open dialog in Word is *not* the GetOpenFilename() dialog! So that
observation doesn't relate to Oren's problem.
I don't have BCB4, but perhaps that's where the addition was made to
the VCL. If you have Pro or better, you could search
..\Borland\...\Source\VCL for text of "OFN_ENABLESIZING". In BCB3,
those Windows constants are defined in commdlg.pas and used in
dialogs.pas .
Here's the MS data on the flag:
OFN_ENABLESIZING
Windows 2000/XP, Windows 98/Me: Enables the Explorer-style dialog box
to be resized using either the mouse or the keyboard. By default, the
Explorer-style Open and Save As dialog boxes allow the dialog box to
be resized regardless of whether this flag is set. This flag is
necessary only if you provide a hook procedure or custom template. The
old-style dialog box does not permit resizing.
The key phrase is "only if you provide ....". The VCL always hooks
the GetOpenFilename() dialog. Your report suggests that the new flag
was added in BCB4.
 

Re:How to manipulate / hook the TOpenDialog ??

"Timothy H. Buchman" <tbuchmanPLEASE(at sign)REMOVEcitycenter.org>
wrote in message news:3faeec09$ XXXX@XXXXX.COM ...
Quote
Oren (Halvani.de) <neroniker>wrote in message
news: XXXX@XXXXX.COM ...
>when I try to compile the code you gave me I'll get these
error-messages:
Here's the whole thing, as a BCB3 project in three posted files:
home.att.net/~secondcut/opdlgrs.htm
THB