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; WM_LBUTTONDOWN: MessageBox(hwnd, '你已经触发了一个消息,恭喜你!','Billy.Chen的测试',MB_ICONINFORMATION); end; Result:=DefWindowProc(hWnd, uMsg, wParam, lParam); end;
var wcfirst: TWndClass; hWnd: Integer; MSG: TMsg; begin wcfirst.style := CS_VREDRAW or CS_HREDRAW; wcfirst.lpfnWndProc := @AppWindowProc; wcfirst.cbClsExtra := 0; wcfirst.cbWndExtra := 0; wcfirst.hInstance := HInstance; wcfirst.hIcon := LoadIcon(0, IDI_APPLICATION); wcfirst.hCursor := LoadCursor(0, IDC_ARROW); wcfirst.hbrBackground := (COLOR_BTNFACE+1); wcfirst.lpszMenuName := nil; wcfirst.lpszClassName := 'MyTest'; if RegisterClass(wcfirst)=0 then Exit; hWnd := CreateWindow( wcfirst.lpszClassName, 'Billy.Chen的SDK/API测试!', WS_OVERLAPPEDWINDOW, Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(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; end.
//点击FILI->NEW->CONSOLE APPLICATION
//删除所有系统生成的程序代码
//COPY以下代码到程序:
program first;
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;
WM_LBUTTONDOWN:
MessageBox(hwnd, '你已经触发了一个消息,恭喜你!','Billy.Chen的测试',MB_ICONINFORMATION);
end;
Result:=DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
var
wcfirst: TWndClass;
hWnd: Integer;
MSG: TMsg;
begin
wcfirst.style := CS_VREDRAW or CS_HREDRAW;
wcfirst.lpfnWndProc := @AppWindowProc;
wcfirst.cbClsExtra := 0;
wcfirst.cbWndExtra := 0;
wcfirst.hInstance := HInstance;
wcfirst.hIcon := LoadIcon(0, IDI_APPLICATION);
wcfirst.hCursor := LoadCursor(0, IDC_ARROW);
wcfirst.hbrBackground := (COLOR_BTNFACE+1);
wcfirst.lpszMenuName := nil;
wcfirst.lpszClassName := 'MyTest';
if RegisterClass(wcfirst)=0 then Exit;
hWnd := CreateWindow(
wcfirst.lpszClassName,
'Billy.Chen的SDK/API测试!',
WS_OVERLAPPEDWINDOW,
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(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;
end.
才可以获得最高的控制权利!