program FirstWinMain;uses Windows,Messages;//窗口函数,窗口接到消息时被WINDOWS调用 function WindowFunc(hwnd:HWND;uMsg:Cardinal;wParam:WPARAM; lParam:LPARAM):LResult;stdcall; begin Result := 0; case uMsg of WM_CLOSE : PostMessage(hwnd, WM_QUIT, 0, 0); else Result := DefWindowProc(hWnd, uMsg, wParam, lParam); end; end;var wcl : WNDCLASS; hwnd : THandle; Msg : tagMSG; begin wcl.hInstance := hInstance; //将hThisInst所指定的当前实例的句柄赋给hInstance。 wcl.lpszClassName := 'FirstWinMain'; //指向窗口类的名字 wcl.lpfnWndProc := @WindowFunc; //窗口函数的地址被赋给lpfnWndProc wcl.style := 0; // default style wcl.hIcon := 0; //定义标准图标 // wcl.hIconSm := 0;(呀,这个我忘了对应的Delphi里的小图标是什么去了) wcl.hCursor := LoadCursor(hInstance,'IDC_ARROW'); //读取鼠标光标
wcl.lpszMenuName := nil; // no menu wcl.cbClsExtra := 0; // no extra information needed wcl.cbWndExtra := 0; // no extra information needed wcl.hbrBackground :=COLOR_WINDOWFRAME; //框架所创建的背景颜色 // Register the window class. if RegisterClass(wcl) = 0 then Exit; //创建窗口 hwnd := CreateWindow( 'FirstWinMain', // name of window class 'Windows 98 Skeleton', //name of window WS_OVERLAPPEDWINDOW, // window style - normal Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), 0, 0, hInstance, nil ); if hwnd=0 then Exit; // Display the window. //显示窗口 ShowWindow(hwnd, SW_SHOWNORMAL); UpdateWindow(hWnd); // Create the message loop. //消息循环 while GetMessage(msg, hwnd, 0, 0) do begin TranslateMessage(msg); // translate keyboard messages DispatchMessage(msg); // return control to Windows 98 end; end.
function WindowFunc(hwnd:HWND;uMsg:Cardinal;wParam:WPARAM;
lParam:LPARAM):LResult;stdcall;
begin
Result := 0;
case uMsg of WM_CLOSE : PostMessage(hwnd, WM_QUIT, 0, 0); else
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
end;var
wcl : WNDCLASS;
hwnd : THandle;
Msg : tagMSG;
begin
wcl.hInstance := hInstance; //将hThisInst所指定的当前实例的句柄赋给hInstance。
wcl.lpszClassName := 'FirstWinMain'; //指向窗口类的名字
wcl.lpfnWndProc := @WindowFunc; //窗口函数的地址被赋给lpfnWndProc
wcl.style := 0; // default style
wcl.hIcon := 0; //定义标准图标
// wcl.hIconSm := 0;(呀,这个我忘了对应的Delphi里的小图标是什么去了)
wcl.hCursor := LoadCursor(hInstance,'IDC_ARROW'); //读取鼠标光标
wcl.lpszMenuName := nil; // no menu
wcl.cbClsExtra := 0; // no extra information needed
wcl.cbWndExtra := 0; // no extra information needed
wcl.hbrBackground :=COLOR_WINDOWFRAME; //框架所创建的背景颜色 // Register the window class.
if RegisterClass(wcl) = 0 then
Exit; //创建窗口
hwnd := CreateWindow(
'FirstWinMain', // name of window class
'Windows 98 Skeleton', //name of window
WS_OVERLAPPEDWINDOW, // window style - normal
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
0,
0,
hInstance,
nil
); if hwnd=0 then
Exit; // Display the window.
//显示窗口
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hWnd); // Create the message loop.
//消息循环
while GetMessage(msg, hwnd, 0, 0) do
begin
TranslateMessage(msg); // translate keyboard messages
DispatchMessage(msg); // return control to Windows 98
end; end.