网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Delphi
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.在Delphi程序中调用控制面板设置.
.用Delphi实现BP机、手机短讯.
.Delphi菜单如何做成word2000的可.
.怎么样知道硬盘上有哪几个分区或.
.偶写的第一个控件,一个用选择代替.
.用程序模拟键盘和鼠标键盘.
.Dephi快捷健.
.用Delphi创建服务程序.
.一个计算器的代码,欢迎大家点评.
.使用XMLDocment遍历CSDN论坛帖子.
.在Delphi7中实现停靠功能.
.Delphi编码标准——文件命名.
.delphi一句话帮助终.
.Delphi实现对注册表的监视和扫描.
.游戏开发者社区对底层API的投票.
.DELPHI基础开发技巧.
.Delphi数据库应用程序中常见错误.
.Delphi中预编译指令如何使用.
.Delphi帮助里的虚拟键值表.
.(delphi)程序运行过程中等待对话.

在DELPHI中如何调用系统对话框

发表日期:2006-2-4


在写程序的时候,有时我们为了省力,或者为了别的目的,我们常常想借用系统的对话框,那么,如何才能调用系统对话框呢?一位朋友是VB中是这样调用“打开方式”对话框的:
winexec(PChar('rundll32  shell32,OpenAs_RunDLL  '+FilePath),SW_SHOWDEFAULT);
这句代码是运行rundll32.exe,让它调用shell32.dll中的资源来实现的。方法可行,但是有许多像我一样的菜鸟并不明白如何调用shell32.dll中的宝贵资源,我们应该如何去做呢?
下面说说我是如何调用的:
一、调用系统“About”对话框:
首先在uses中加入SHellApi,
然后写下如下代码:
procedure TForm1.Button1Click(Sender: TObject);
var
  shellapp: variant;
begin
  ShellAboutW(0,'Timer v1.03','kedy版权所有',1);
end;
其他步骤我不详述。运行后点击button就会弹出标准的WINDOWS关于对话框。对话框标题为"关于Timer v 1.03"。大家可以看到,在程序中我使用了ShellAboutW这个函数。在MSDN2003中这个函数是这样描述的:
ShellAbout Function
Displays a ShellAbout dialog box. 
Syntax
int ShellAbout(          HWND hWnd,
    LPCTSTR szApp,
    LPCTSTR szOtherStuff,
    HICON hIcon
);
Parameters
hWnd
[in] Window handle to a parent window. This parameter can be NULL. 
szApp
[in] Pointer to a null-terminated string containing text that will be displayed in the 
title bar of the ShellAbout dialog box and on the first line of the dialog box after the 
text "Microsoft". If the text contains a separator (#) dividing it into two parts, the 
function displays the first part in the title bar and the second part on the first line 
after the text "Microsoft". 
szOtherStuff
[in] Pointer to a null-terminated string containing text that will be displayed in the 
dialog box after the version and copyright information. 
hIcon
[in] Icon that the function displays in the dialog box. If this parameter is NULL, the 
function displays the Microsoft® Windows® or Microsoft Windows NT® icon. 
什么意思我想不用我来翻译了吧,这些东西自己去看最好。
二、调用关机对话框
我们只要把begin部分代码改为
begin
  shellapp := CreateOleObject('Shell.Application');
  shellapp.ShutDownWindows;
end;
其他部分不变。运行点击button我们就可以看到标准的系统关机对话框了。
其实这还是调用的WindowsAPI函数shutdownwindows.
这个部分使用的是windows的shell application的method中的两个函数。method其他的函数还有:
BrowseForFolder、CascadeWindows、ControlPanelItem、EjectPC、Explore、FileRun、FindComputer、FindFiles、Help、MinimizeAll、NameSpace、Open、RefreshMenu、SetTime、TileHorizontally、TileVertically、TrayProperties、UndoMinimizeALL。我也只是学会了使用其中的几个函数。详细情况请大家查看MSDN中有关shell object的内容。

我最想说的是,学windows下的程序一定要用MSDN。这个库里的资源让我实在惊叹不已,大家可以看一看,我想你也会这样认为的。
上一篇:第三方控件使用方法 人气:4679
下一篇:用Delphi编写数据报存储控件 人气:4313
浏览全部Delphi的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐