本文整理自网络,侵删。
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.
相关阅读 >>
Delphi10.3通过json.serializers单元对大量数据序列化
Delphi (vcl及fmx[firemonkey])启动时的欢迎窗口实现代码
Delphi winapi: writeprivateprofilestring、getprivateprofilestring - 简单读写 ini 文件
更多相关阅读请进入《Delphi》频道 >>