delphi 建立最小的应用程序


本文整理自网络,侵删。

 program project;

uses

windows,Messages;

{$R *.RES}

const

appname='abc';

var

aMessage:tmsg;

hwindow,button1,button2:hwnd;

function WindowProc(window:hwnd;amessage,wparam,lparam:longint):longint;stdcall;export;

begin

windowproc:=0;

case amessage of

WM_DESTROY:

begin

destroywindow(button1);

destroywindow(button2);

PostQuitMessage(0);

exit;

end;

wm_command:

if lparam=button1 then

begin

MessageBox(hwindow,'fksd','kfdsl',MB_OK+MB_ICONINFORMATION);

end;

end;

windowproc:=defwindowproc(window,aMessage,wParam,lParam);

end;

function WinRegister:boolean;

var

WindowClass:TWndClass;

begin

WindowClass.style:=cs_hredraw or cs_vredraw ;

windowclass.lpfnWndProc:=@windowProc;

windowClass.cbClsExtra:=0;

windowClass.cbWndExtra:=0;

windowclass.hInstance:=hinstance;

windowclass.hIcon:=LoadIcon(0,IDI_APPLICATION);

windowclass.hCursor:=LoadCursor(0,IDC_ARROW);

windowclass.hbrBackground:=COLOR_BTNSHADOW;

windowclass.lpszMenuName:=nil;

windowclass.lpszClassName:=appname;

result:=Registerclass(windowClass)<>0;

end;

function WinCreate:hwnd;

var

hWindow:hwnd;

pchartemp:pchar;

param:tagCREATESTRUCT;

begin

hwindow:=CreateWindowEx(WS_EX_RTLREADING or WS_EX_APPWINDOW,appname,'文件分解与合并演示程序',WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,hinstance,nil);

if hwindow<>0 then

begin

param.cx:=20;

param.cy:=20;

param.dwExStyle:=WS_CHILD+BS_PUSHBUTTON;

param.hInstance:=hinstance;

param.hMenu:=0;

param.hwndParent:=hwindow;

param.lpszClass:='button';

param.x:=20;

param.y:=20;

pchartemp:='Kingron TEMP';

button1:=createwindow('button','合并文件',param.dwExStyle,param.y,param.y,60,30,hwindow,0,hinstance,@param);

param.x:=40;

param.y:=60;

button2:=createwindow('button','分解文件',param.dwExStyle,param.y,param.y,60,30,hwindow,0,hinstance,@param);

showwindow(hwindow,cmdshow);

showwindow(button2,cmdshow);

showwindow(button1,cmdshow);

updatewindow(hwindow);

end;

result:=hwindow;

end;

begin

if not winregister then

begin

MessageBox(0,'窗口注册失败','错误',MB_OK+MB_ICONINFORMATION);

exit;

end;

hwindow:=wincreate;

while GetMessage(aMessage,0,0,0) do

begin

TranslateMessage(amessage);

DispatchMessage(aMessage);

end;

halt(amessage.wParam);

end.

相关阅读 >>

Delphi 判断系统服务是否运行

Delphi 利用tidencodermime tiddecodermime 组件字符串加密解密

Delphi 正则提取txt中的email 数据

Delphi 加载大文件显示进度条

相对完整的多线程idhttp文件下载代码

Delphi 阿里云发送短信的Delphi单元

Delphi 判断文本文件的编码格式

Delphi inc函数和dec函数的用法

Delphi android 平台加载文件

Delphi xe7 android通过配置实现splash功能

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...