?
Solved

Extending Common Dialogs (File Open/Save) in IE and Windows Explorer

Posted on 2004-03-30
3
Medium Priority
?
295 Views
Last Modified: 2010-04-05

or in any third party app that uses common dialogs.

I want to add a button and an edit control to the dialogs. I am sure I have seen this done, but don't know how to do it in Delphi. Something to do with OFNHookProc I think.

Some example code would be nice.

Thanks
0
Comment
Question by:Mutley2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 10729993
Tricky but doable :)

First you have to create a resource file:

<<< Start of NEWTEMPLATE.RC >>>
NEWTEMPLATE DIALOG 0, 0, 316, 76
STYLE 0x404L | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL , SUBLANG_NEUTRAL
{
 LTEXT "", 1119, 0, 0, 204, 76, SS_LEFT | WS_CHILD | NOT WS_VISIBLE | WS_GROUP
}
<<< End of NEWTEMPLATE.RC >>>

To have this file compiled into your DPR choose Project/Add to project from the menu. Change the file extyension to *.rc and select the newly created NEWTEMPLATE.RC. This will add the following line to you DPR:

{$R 'NEWTEMP.res' 'NEWTEMP.RC'}

The template in this resource will be used by windows to alter the width of the OpenDialog for us. The 316 on the first line indicates this width. (Remember to use "build all" if you do not use "auto save editor files" otherwise the RC will not be recompiled)

The subclassing of TOpenDialog is shown in Unit1.pas below. It is fairly simple: Just create your components in the constructor and set the ParentWindow and positions in the override of DoShow. Then the only thing left to do is tell windows what template to use in the override of the Execute method.

<<< Start of Unit1.pas >>>
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

type
  TSpecialDialog = class(TOpenDialog)
  private
    fButton: TButton;
    fEdit: TEdit;
  protected
    procedure DoShow; override;
  public
    function Execute: Boolean; override;
    constructor Create(aOwner: TComponent); override;
  end;

{ TSpecialDialog }

constructor TSpecialDialog.Create(aOwner: TComponent);
begin
  inherited Create(aOwner);
  fButton := TButton.Create(Self);
  with fButton do
  begin
    Caption := 'Click me...';
  end;
  fEdit := TEdit.Create(Self);
  with fEdit do
  begin
    Text := 'Read me...';
  end;
end;

procedure TSpecialDialog.DoShow;
var
      lStaticRect: TRect;
begin
  inherited DoShow;
  lStaticRect := GetStaticRect;
  fButton.ParentWindow := Handle;
  fButton.Left := lStaticRect.Right + 8;
  fButton.Top := 5;
  fEdit.ParentWindow := Handle;
  fEdit.Left := lStaticRect.Right + 8;
  fEdit.Top := 30;
end;

function TSpecialDialog.Execute: Boolean;
begin
  if ofOldStyleDialog in Options then
    Options := Options -[ofOldStyleDialog];
  Template := 'NEWTEMPLATE';
  Title := 'Test';
  Result := inherited Execute;
end;

{ TSpecialDialog }

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TSpecialDialog.Create(Self) do
  try
    Execute;
  finally
    Free;
  end;
end;

end.
<<< End of Unit1.pas >>>

Regards Jacco

P.S: If you are creating a component use can convert NEWTEMPLATE.RC to NEWTEMPLATE.RES using the commandline tool BRCC32 and then include it in the project putting {$R NEWTEMPLATE.RES} in one of the units.
P.P.S.S: If looked up how to do this on http://www.torry.net/extdialogs.htm PBPreviewDialog component v.4.30.00.00 by Poul Bak
0
 

Author Comment

by:Mutley2003
ID: 10730443

Jacco

Thanks for the pointer to http://www.torry.net/extdialogs.htm
- lots of nice dialog extensions there.

But I don't think your nice code does what I am after - perhaps I did not explain well enough.

Assume a user is running IE or Windows Explorer and clicks on "file save" from within that app.. I then want an enhanced save dialog to appear (extra buttons etc) and if the user clicks on that extra button,   the original app should call a Delphi app or COM object.

I think this VB code does what I want, or maybe not

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=12394&lngWId=1

I still think the answer lies with hooking, somewhere.

I'd be grateful for any further ideas and insights

thanks


 
0
 
LVL 10

Accepted Solution

by:
Jacco earned 1500 total points
ID: 10734064
Sorry I don't know how to do that.

It would be an illegal hack though. This way you could make for example Word to not save correctly any more. But I guess with some nifty hooking you could do it.

Regards Jacco
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question