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 的内存操作函数(3): 给结构体指针分配内存

Delphi 删除指定字符串的所有实例

Delphi 中文urlencode的简单办法

Delphi 获取自身软件的版本号

Delphi10.3通过json.serializers单元对大量数据序列化

Delphi指针

Delphi 屏蔽特殊字符

Delphi (vcl及fmx[firemonkey])启动时的欢迎窗口实现代码

Delphi 双击dbgrid然后得到字段里面的内容

Delphi winapi: writeprivateprofilestring、getprivateprofilestring - 简单读写 ini 文件

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



打赏

取消

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

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

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

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

评论

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