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 软件welcome窗口代码

Delphi中自适应窗体的实现

Delphi 64位汇编编程

Delphi动态建立panel无法更改颜色?

Delphi 域名转ip并判断ip是否可以联通 复制代码

Delphi jsondataobjects

Delphi xe5 android平台 调用 webservice

Delphi cef4 忽略不安全网站

Delphi 运行带参数的程序等待其并获取结果

Delphi 判断特定字符是为单字节还是双字节

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



打赏

取消

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

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

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

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

评论

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