main.dpr
来自「用API写WINDOWS窗体!」· DPR 代码 · 共 49 行
DPR
49 行
program small;
uses
windows,messages,sysutils;
var
wclass:twndclass;
msg:tmsg;
hinst,handle,hfont:integer;
procedure exit;
begin
deleteobject(hfont);
unregisterclass(wclass.lpszclassname,hinst);
exitprocess(hinst);
end;
function windowproc(hwnd,msg,wparam,lparam:integer):longint;stdcall;
begin
result:=defwindowproc(hwnd,msg,wparam,lparam);
case msg of
wm_destroy:exit;
end;
end;
function createmain(name:pchar;x1,y1,x2,y2:integer):hwnd;
begin
hinst:=getmodulehandle(nil);
with wclass do
begin
style:=cs_parentdc;
hicon:=loadicon(hinst,'mainicon');
lpfnwndproc:=@windowproc;
hinstance:=hinst;
hbrbackground:=color_btnface+1;
lpszclassname:='mainclass';
hcursor:=loadcursor(0,idc_arrow);
end;
registerclass(wclass);
result:=createwindow(wclass.lpszclassname,name,ws_overlappedwindow or ws_visible,x1,y1,x2,y2,0,0,hinst,nil);
end;
begin
handle:=createmain('mainform',0,0,384,140);
while (getmessage(msg,handle,0,0)) do
begin
translatemessage(msg);
dispatchmessage(msg);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?