抄的别人的,肯定对你有帮助.模拟开始菜单Run的功能.<br>---<br>netke (2001-11-28 9:26:00) <br>unit RunDialog;<br>interface<br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<br>type<br> TRunDialog = class(TComponent)<br> private<br> { Private declarations }<br> FDescription: String;<br> FHideBrowseButton: Boolean;<br> FIcon: TIcon;<br> FInitialDir: String;<br> FTitle: String;<br> procedure SetDescription(Value: String);<br> procedure SetHideBrowseButton(Value: Boolean);<br> procedure SetIcon(Value: TIcon);<br> procedure SetInitialDir(Value: String);<br> procedure SetTitle(Value: String);<br> protected<br> { Protected declarations }<br> constructor Create(AOwner: TComponent); override;<br> destructor Destroy; override;<br> public<br> { Public declarations }<br> procedure Execute;<br> published<br> { Published declarations }<br> property Description: String read FDescription write SetDescription;<br> property HideBrowseButton: Boolean read FHideBrowseButton write SetHideBrowseButton;<br> property Icon: TIcon read FIcon write SetIcon;<br> property InitialDir: String read FInitialDir write SetInitialDir;<br> property Title: String read FTitle write SetTitle;<br> end;<br><br>var<br> Flags: LongInt = 0;<br><br>const<br> RFF_NOBROWSE = 1;<br><br>procedure Register;<br><br>implementation<br>procedure RunFileDlgA(OwnerWnd: HWND; Icon: HICON; lpstrDirectory: PAnsiChar;<br> lpstrTitle: PAnsiChar; lpstrDescription: PAnsiChar; Flags: LongInt); stdcall;<br> external 'Shell32.dll' index 61;<br>constructor TRunDialog.Create(AOwner: TComponent);<br>begin<br> inherited Create(AOwner);<br> FIcon := TIcon.Create;<br>end;<br><br>destructor TRunDialog.Destroy;<br>begin<br> FIcon.Free;<br> inherited Destroy;<br>end;<br><br>procedure TRunDialog.Execute;<br>begin<br>if FHideBrowseButton = True then<br> begin<br> Flags := Flags or RFF_NOBROWSE;<br> end;<br>RunFileDlgA(0,FIcon.Handle,PChar(FInitialDir),PChar(FTitle),PChar(FDescription),Flags);<br>end;<br><br>procedure TRunDialog.SetDescription(Value: String);<br>begin<br>if Value <> FDescription then<br> begin<br> FDescription := Value;<br> end;<br>end;<br><br>procedure TRunDialog.SetHideBrowseButton(Value: Boolean);<br>begin<br>if Value <> FHideBrowseButton then<br> begin<br> FHideBrowseButton := Value;<br> end;<br>end;<br><br>procedure TRunDialog.SetIcon(Value: TIcon);<br>begin<br>if Value <> FIcon then<br> begin<br> FIcon.Assign(Value);<br> end;<br>end;<br><br>procedure TRunDialog.SetInitialDir(Value: String);<br>begin<br>if Value <> FInitialDir then<br> begin<br> FInitialDir := Value;<br> end;<br>end;<br><br>procedure TRunDialog.SetTitle(Value: String);<br>begin<br>if Value <> FTitle then<br> begin<br> FTitle := Value;<br> end;<br>end;<br><br>procedure Register;<br>begin<br> RegisterComponents('Dialogs', [TRunDialog]);<br>end;<br>end.