急!关于按钮的添加 利用SelectDirectory('画面上label的显示内容','',Dir)方法,可以显示的Directory画面,希望在这个画面添加一个按钮,并实现该按钮的功能应该怎么做?请各位高手帮忙,指点一下小妹。小妹先行谢过了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看它的源码,用ShellTreeView和几个按钮来做一个也不难 ShellTreeView是什么?我在源码中没看到阿? 我意思是你用Sample页的ShellTreeView控件仿照SelectDirectory来做一个窗口 我觉得很难仿照,我要的是SelectDirectory完全相同的效果,而且delphi5根本没有你说的那个控件。我希望用继承类相关的方法实现,不破坏原有的功能,只是添加一个新的按钮功能。这样应该会比较简单。 unit QxOpenFileDialog;//一个在打开文件框中加入WEBBROWSER的对话框interface uses Messages, Windows, SysUtils, Classes, Controls, StdCtrls, Graphics, ExtCtrls, Buttons, Dialogs, Consts,SHDocVw; type{ TOpenPictureDialog } TQxOpenFileDialog = class(TOpenDialog) private FBrowserPanel: TPanel; FBrowserLabel: TLabel; FPaintPanel: TPanel; FBrowserCtrl: TWebBrowser; FSavedFilename: string; procedure WMSize(var Message: TWMSize); message WM_SIZE; protected procedure DoClose; override; procedure DoSelectionChange; override; procedure DoShow; override; property BrowserCtrl: TWebBrowser read FBrowserCtrl; property BrowserLabel: TLabel read FBrowserLabel; Function GetDlgItemRect(Item: Integer): TRect; published // property Filter stored IsFilterStored; public constructor Create(AOwner: TComponent); override; function Execute(ParentWnd: HWND): Boolean; override; end;implementationuses Math, Forms, CommDlg, Dlgs, Types; type TSilentPaintPanel = class(TPanel) protected procedure WMPaint(var Msg: TWMPaint); message WM_PAINT; end;procedure TSilentPaintPanel.WMPaint(var Msg: TWMPaint);begin try inherited; except Caption := SInvalidImage; end;end;{ TOpenPictureDialog }//{$R ExtDlgs.res}constructor TQxOpenFileDialog.Create(AOwner: TComponent);begin inherited Create(AOwner); Filter:='FLASH格式文件(*.Swf)|*.SWF|Word文件(*.Doc)|*.Doc|Excel文件(*.Xls)|*.xls'; FBrowserPanel := TPanel.Create(Self); with FBrowserPanel do begin Name := 'BrowserPanel'; Caption := ''; BevelOuter := bvNone; BorderWidth := 6; TabOrder := 1; FBrowserCtrl := TWebBrowser.Create(FBrowserPanel); with FBrowserCtrl do begin Align := alClient; TWinControl(FBrowserCtrl).Parent := FBrowserPanel; MenuBar:=false; StatusBar:=false; end; end;end;procedure TQxOpenFileDialog.DoSelectionChange;var FullName: string; ValidBrowser: Boolean; function ValidFile(const FileName: string): Boolean; begin Result := GetFileAttributes(PChar(FileName)) <> $FFFFFFFF; end;begin FullName := FileName; if FullName <> FSavedFilename then begin FSavedFilename := FullName; ValidBrowser := FileExists(FullName) and ValidFile(FullName); if ValidBrowser then try FBrowserCtrl.Navigate(FullName); except ValidBrowser := False; end; if not ValidBrowser then begin FBrowserCtrl.Stop; end; end; inherited DoSelectionChange;end;procedure TQxOpenFileDialog.DoClose;begin inherited DoClose; { Hide any hint windows left behind } Application.HideHint;end;procedure TQxOpenFileDialog.DoShow;var WndRect,PreviewRect, StaticRect: TRect;begin {调整主对话框} GetWindowRect(GetParent(Handle), WndRect); WndRect.Bottom:=WndRect.bottom+100; MoveWindow(GetParent(Handle), WndRect.Left, WndRect.Top, WndRect.Right, WndRect.Bottom, TRUE); {调整子对话框} { Set preview area to entire dialog } GetClientRect(GetParent(Handle), PreviewRect); MoveWindow(handle,0,0,PreviewRect.Right,PreviewRect.Bottom,true); StaticRect := GetStaticRect; { Move preview area to Bottom of static area } //调整浏览处的位置 PreviewRect.Top:=StaticRect.Bottom-StaticRect.Top; PreviewRect.left:=2; PreviewRect.Bottom:=PreviewRect.Top+140; PreviewRect.Right:=PreviewRect.Right-10; FBrowserPanel.BoundsRect := PreviewRect; FBrowserCtrl.Stop; FSavedFilename := ''; FBrowserPanel.ParentWindow := Handle; FBrowserCtrl.ParentWindow:=FBrowserPanel.Handle;//FPaintPanel.Handle; inherited DoShow;end;function TQxOpenFileDialog.Execute(ParentWnd: HWND): Boolean;begin if NewStyleControls and not (ofOldStyleDialog in Options) then Template := 'TEXTFILEDLG' else Template := nil; Result := inherited Execute(ParentWnd); REsult:=true;end;procedure TQxOpenFileDialog.WMSize(var Message: TWMSize);var LRect: TRect;begin inherited; GetClientRect(GetParent(Handle), Lrect); FBrowserPanel.Width:=Lrect.Right-5;end; function TQxOpenFileDialog.GetDlgItemRect(Item: Integer): TRect;begin if Handle <> 0 then begin if not (ofOldStyleDialog in Options) then begin GetWindowRect(GetParent(Handle), Result); MapWindowPoints(0, Handle, Result, 2); end else Result := Rect(0, 0, 0, 0); end else Result := Rect(0, 0, 0, 0);end;end. 需要修改,修改后才能用。但是显示不了dialog。但是我要用的那个SelectDirectory并不是一个class中的function,这个方法对我来说也不行。 DefineProperties 中Filer 是什么意思? 无法使用DELPHI自带的ZLIB,气死我了 *****请问数值型数据怎么转化为大写***** 怎么我双击pageControl控件就直接进入代码窗口? 如何设置输入焦点 Why can't load package.... realaudio控件的问题!在线等待!!! 在DELPHI 7 中怎么找不到QReport组件? 请问:如何纵向合并单元格?在线等待... 开展“09年Delphi学习热潮”学习活动 IdFTP断点上传时,文件一直累加该如何解决? 对多个EDIT的文本进行SQL查询 请教一个好方法
//一个在打开文件框中加入WEBBROWSER的对话框
interface
uses Messages, Windows, SysUtils, Classes, Controls, StdCtrls, Graphics,
ExtCtrls, Buttons, Dialogs, Consts,SHDocVw; type{ TOpenPictureDialog } TQxOpenFileDialog = class(TOpenDialog)
private
FBrowserPanel: TPanel;
FBrowserLabel: TLabel;
FPaintPanel: TPanel;
FBrowserCtrl: TWebBrowser;
FSavedFilename: string;
procedure WMSize(var Message: TWMSize); message WM_SIZE; protected procedure DoClose; override;
procedure DoSelectionChange; override;
procedure DoShow; override;
property BrowserCtrl: TWebBrowser read FBrowserCtrl;
property BrowserLabel: TLabel read FBrowserLabel;
Function GetDlgItemRect(Item: Integer): TRect;
published
// property Filter stored IsFilterStored;
public
constructor Create(AOwner: TComponent); override;
function Execute(ParentWnd: HWND): Boolean; override;
end;
implementation
uses Math, Forms, CommDlg, Dlgs, Types;
type
TSilentPaintPanel = class(TPanel)
protected
procedure WMPaint(var Msg: TWMPaint); message WM_PAINT;
end;procedure TSilentPaintPanel.WMPaint(var Msg: TWMPaint);
begin
try
inherited;
except
Caption := SInvalidImage;
end;
end;
{ TOpenPictureDialog }//{$R ExtDlgs.res}constructor TQxOpenFileDialog.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Filter:='FLASH格式文件(*.Swf)|*.SWF|Word文件(*.Doc)|*.Doc|Excel文件(*.Xls)|*.xls';
FBrowserPanel := TPanel.Create(Self);
with FBrowserPanel do
begin
Name := 'BrowserPanel';
Caption := ''; BevelOuter := bvNone;
BorderWidth := 6;
TabOrder := 1;
FBrowserCtrl := TWebBrowser.Create(FBrowserPanel);
with FBrowserCtrl do
begin
Align := alClient;
TWinControl(FBrowserCtrl).Parent := FBrowserPanel;
MenuBar:=false;
StatusBar:=false;
end;
end;end;procedure TQxOpenFileDialog.DoSelectionChange;
var
FullName: string;
ValidBrowser: Boolean; function ValidFile(const FileName: string): Boolean;
begin
Result := GetFileAttributes(PChar(FileName)) <> $FFFFFFFF;
end;begin
FullName := FileName;
if FullName <> FSavedFilename then
begin
FSavedFilename := FullName;
ValidBrowser := FileExists(FullName) and ValidFile(FullName);
if ValidBrowser then
try
FBrowserCtrl.Navigate(FullName);
except
ValidBrowser := False;
end;
if not ValidBrowser then
begin
FBrowserCtrl.Stop; end;
end;
inherited DoSelectionChange;
end;procedure TQxOpenFileDialog.DoClose;
begin
inherited DoClose;
{ Hide any hint windows left behind }
Application.HideHint;
end;procedure TQxOpenFileDialog.DoShow;
var
WndRect,PreviewRect, StaticRect: TRect;
begin
{调整主对话框}
GetWindowRect(GetParent(Handle), WndRect);
WndRect.Bottom:=WndRect.bottom+100; MoveWindow(GetParent(Handle), WndRect.Left, WndRect.Top, WndRect.Right, WndRect.Bottom, TRUE);
{调整子对话框}
{ Set preview area to entire dialog }
GetClientRect(GetParent(Handle), PreviewRect);
MoveWindow(handle,0,0,PreviewRect.Right,PreviewRect.Bottom,true);
StaticRect := GetStaticRect;
{ Move preview area to Bottom of static area } //调整浏览处的位置
PreviewRect.Top:=StaticRect.Bottom-StaticRect.Top;
PreviewRect.left:=2;
PreviewRect.Bottom:=PreviewRect.Top+140;
PreviewRect.Right:=PreviewRect.Right-10; FBrowserPanel.BoundsRect := PreviewRect; FBrowserCtrl.Stop;
FSavedFilename := ''; FBrowserPanel.ParentWindow := Handle;
FBrowserCtrl.ParentWindow:=FBrowserPanel.Handle;//FPaintPanel.Handle;
inherited DoShow;
end;function TQxOpenFileDialog.Execute(ParentWnd: HWND): Boolean;
begin
if NewStyleControls and not (ofOldStyleDialog in Options) then
Template := 'TEXTFILEDLG' else
Template := nil;
Result := inherited Execute(ParentWnd);
REsult:=true;
end;procedure TQxOpenFileDialog.WMSize(var Message: TWMSize);
var
LRect: TRect;
begin
inherited;
GetClientRect(GetParent(Handle), Lrect);
FBrowserPanel.Width:=Lrect.Right-5;
end;
function TQxOpenFileDialog.GetDlgItemRect(Item: Integer): TRect;
begin
if Handle <> 0 then
begin
if not (ofOldStyleDialog in Options) then
begin
GetWindowRect(GetParent(Handle), Result);
MapWindowPoints(0, Handle, Result, 2);
end
else Result := Rect(0, 0, 0, 0);
end
else Result := Rect(0, 0, 0, 0);
end;
end.