说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

用最原始的方法编制程序-Delphi资料

HTML文档下载 WORD文档下载 PDF文档下载
用最原始的方法编制程序-Delphi资料

program MyApp;

uses Windows

Messages;

function AppWindowProc( hWnd:HWND; uMsg:UINT; wParam:WPARAM; lParam:LPARAM):LRESULT; stdcall; // 回调函数

begin

Result := 0;

case uMsg of WM_DESTROY:begin

PostQuitMessage(0);

Exit;

end;

end;

Result := DefWindowProc(hWnd

uMsg

wParam

lParam);

end;

var

wc: TWndClass;

hWnd: Integer;

MSG: TMsg;

begin // 程序从这里开始执行

wc.style := CS_VREDRAW or CS_HREDRAW;

wc.lpfnWndProc := @AppWindowProc;

wc.cbClsExtra := 0;

wc.cbWndExtra := 0;

wc.hInstance := HInstance;

wc.hIcon := LoadIcon(0

IDI_APPLICATION);

wc.hCursor := LoadCursor(0

IDC_ARROW);

wc.hbrBackground := (COLOR_BTNFACE+1);

wc.lpszMenuName := nil;

wc.lpszClassName := 'My App';

if RegisterClass(wc)=0 then Exit;

hWnd := CreateWindow( wc.lpszClassName

'TEST'

WS_OVERLAPPEDWINDOW

CW_USEDEFAULT

CW_USEDEFAULT

CW_USEDEFAULT

CW_USEDEFAULT

0

0

HInstance

nil);

if hWnd=0 then Exit;

ShowWindow(hWnd

SW_SHOWNORMAL);

while GetMessage(MSG

0

0

0) do

begin

TranslateMessage(MSG);

DispatchMessage(MSG);

end;

Halt(MSG.wParam);

end.