调用Windows系统对话框的一些心得,欢迎跟贴!(1分)

  • 主题发起人 主题发起人 Bahl
  • 开始时间 开始时间
B

Bahl

Unregistered / Unconfirmed
GUEST, unregistred user!
调用Windows系统对话框
在Delphi中大家都会调用一些如打开文件,保存文件之类的最常用的对话框。但如何调用一些像关闭系统对话框这样不太常用的对话框呢?本人经过一番研究,小有收获。
1 关闭系统对话框:
procedure ExitWindowsDialog(Handle: THandle); stdcall; external 'shell32.dll' index 60; //API 声明
使用:
procedure TForm1.Button1Click(Sender: TObject);
begin
ExitWindowsDialog(Handle);
end;
2 重启动系统对话框:
function RestartWindowsDialog(Handle: THandle; Reason: PChar; Flags: Integer): Integer; stdcall; external 'shell32.dll' index 59;
使用:
procedure TForm1.Button2Click(Sender: TObject);
begin
RestartWindowsDialog(Handle, PCHAR('这个程序'), EW_RESTARTWINDOWS);
end;
3 选择图标对话框:
function PickIconDialog(Handle:THandle; FileName:PChar; FileNameSize:integer;var IconIndex:integer):Boolean; stdcall; external 'shell32.dll' index 62;
使用:
procedure TForm1.Button3Click(Sender: TObject);
var
IconIndex: Integer;
begin
if PickIconDialog(Handle, PChar('shell32.dll'), Length('shell32.dll'), IconIndex) then
ShowMessage('Selecciono ' + IntTOStr(IconIndex));
end;
4 运行对话框:
procedure RunDialog(Handle: THandle; Icon: HIcon; Directory: PChar; Title: PChar; Description: PChar; Flags: Integer); stdcall; external 'shell32.dll' index 61;
使用:
procedure TForm1.Button4Click(Sender: TObject);
begin
RunDialog(Handle, Icon.Handle, PCHAR('C:'), PCHAR('SELECT THE FILE YOU WANT TO RUN'),
PCHAR(''), 0);
end;
我只找出了调用四种系统对话框的方法,如果诸位还有调用其他的系统对话框的方法,欢迎跟贴。






 
RunDialog为何有乱码?
 
是呀,为什么会出现乱码呢?
 
我测试过所有的代码,没有乱码啊?
 
怎么看Bahl都是好人。
 
这么好的帖子,这么好的人,我坚决帮忙up,让更多的人看到它。
 
我听课来了,Bahl我没迟到吧??/
 
全是乱码

win2k
 
我用的是Win98SE
 
我试试看看先,Bahl,你是好人~~~~~~~~~~~~~~~~~~~~敢问身处何方~
 
马上收藏
 
抄几个
浏览文件夹
function SHBrowseForFolder(var BrowseInfo:TBrowseInfo):PItemIDList;stdcall
格式化
function SHFormatDrive(Owner:HWND;Drive:UNIT;FormatID:UNIT;OptionFlags:UNIT):DWORD;stdcall;
在shell32.dll中
查找文件
function SHFindFiles(SearchRoot:PItemIDList;SavedSearchFile:PitemIDList):LongBool;stdcall
在shell32.dll中index 90
查找电脑
function SHFindComputer(Reservedl:PItemIDList;Reserved2:PItemIDList):LongBool;stdcall;
在shell32.dll中index 91 参数设孔即可
缺少内存
function ShOutofMemoryMessageBox(Owner:HWND;Caption:Pointer;Style:UNIT):integer;stdcall;
在shell32.dll index 126
 
后退
顶部