program Modal;
uses
Windows, Messages;
var
Hwnd: Thandle; {主窗口句柄}
{$R *.RES}
{处理消息}
function WndProc(hWnd:Thandle;Msg:Integer;wParam:WPARAM;
lParam:LPARAM):HRESULT;stdcall;
begin
Result:=HRESULT(0); {清除警告信息}
case Msg of
WM_CLOSE: Begin
PostMessage(hWnd,WM_QUIT,wParam,lParam); Exit; end;
end;
Result:= DefWindowProc(Hwnd,Msg,wParam,lParam);
end;
function InitApplication:Boolean;
var
WndCls: TWndClass; {窗口类声明}
begin
wndcls.style := CS_DBLCLKS;
wndcls.lpfnWndProc := @WndProc;
wndcls.cbClsExtra := 0;
wndcls.cbWndExtra := 0;
wndcls.hInstance := hInstance;
wndcls.hIcon := 0;
wndcls.hCursor := LoadCursor(hInstance, 'IDC_ARROW');
wndcls.hbrBackground := COLOR_BACKGROUND;
wndcls.lpszMenuName := nil;
wndcls.lpszClassName := 'WCTemplate';
if RegisterClass(wndcls) = 0 then begin
Result:=False;
Exit;
end;
Result:=True;
end;
function InitInstance(Title: String = 'Win32Modal'):Boolean;
begin
hWnd := CreateWindow(
'WCTemplate',PChar(Title),
WS_OverLappedWindow,
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
0,0,hInstance,nil);
if hWnd = 0 then begin
Result:=False;
Exit;
end;
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
Result:=True;
end;
{程序入口}
function WinMain(hInst:HINST;hPrevInst:HINST;lpCmdLine
![Stick Out Tongue :P :P](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f61b.png)
Char;
nCmdShow:Integer):Integer;stdcall;
var
msg: TMsg;
begin
if not InitApplication then begin
Result:=0;
Exit;
end;
if not InitInstance then begin
Result:=0;
Exit;
end;
While GetMessage(msg,Hwnd,0,0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
Result:=Msg.wParam;
end;
begin
WinMain(hInstance,0,pChar(''),0);
end.
2、之上是全局的对象或变量,之下是局部的对象或变量
3、www.playicq.com,www.51delphi.com