陷
陷队之士
Unregistered / Unconfirmed
GUEST, unregistred user!
program HelloWin;
{ Standard Windows API application written in Object Pascal. }
uses
Windows,
messages,
MMSystem;
const
AppName : pChar = 'HelloWin';
function WindowProc(Window: HWnd
AMessage, WParam, LParam: LongInt):
LongInt
stdcall
export;
{ The message handler for the new window }
var
h : hdc;
ps : tPaintStruct;
r : tRect;
begin
Result := 0;
case AMessage of
WM_Create:
begin
PlaySound('C:/WINDOWS/MEDIA/Musica Windows Start.wav', 0,
Snd_FileName or Snd_Async);
Exit;
end;
WM_Paint:
begin
h := BeginPaint(Window, Ps);
GetClientRect(Window, r);
DrawText(h, 'Hello Winblows!', -1, r,
DT_SingleLine or DT_Center or DT_VCenter);
EndPaint(Window, ps);
Exit;
end;
WM_Destroy:
begin
PostQuitMessage(0);
Exit;
end;
end;
Result := DefWindowProc(Window, AMessage, WParam, LParam);
end;
{ Register the window class }
function WinRegister: Boolean;
var
WindowClass : TWndClass;
begin
WindowClass.Style := cs_HRedraw or cs_VRedraw;
WindowClass.lpfnWndProc := @WindowProc;
WindowClass.cbClsExtra := 0;
WindowClass.cbWndExtra := 0;
WindowClass.hInstance := HInstance;
WindowClass.hIcon := LoadIcon(0, idi_Application);
WindowClass.hCursor := LoadCursor(0, idc_Arrow);
WindowClass.hbrBackground := HBrush(GetStockObject(White_Brush));
WindowClass.lpszMenuName := nil;
WindowClass.lpszClassName := AppName;
Result := RegisterClass(WindowClass) <&gt
0;
end;
function WinCreate: HWnd;
var
HWindow : HWnd;
begin
hWindow := CreateWindow(AppName,
'The Hello Program',
WS_OverlappedWindow,
CW_UseDefault, CW_UseDefault,
CW_UseDefault, CW_UseDefault,
0, 0, HInstance, nil);
if hWindow <&gt
0 then
begin
ShowWindow(hWindow, CmdShow);
UpdateWindow(hWindow);
end;
Result := hWindow;
end;
{ Main: Set up window, then give it messages until done.}
var
AMessage : TMsg;
hWindow : HWnd;
begin
if not WinRegister then
begin
MessageBox(0, 'Register Failed', nil, mb_Ok);
Exit;
end;
hWindow := WinCreate;
if hWindow = 0 then
begin
MessageBox(0, 'Register Failed', nil, mb_Ok);
Exit;
end;
while GetMessage(AMessage, 0, 0, 0) do
begin
TranslateMessage(AMessage);
DispatchMessage(AMessage);
end;
Halt(AMessage.WParam);
end.
{ Standard Windows API application written in Object Pascal. }
uses
Windows,
messages,
MMSystem;
const
AppName : pChar = 'HelloWin';
function WindowProc(Window: HWnd
AMessage, WParam, LParam: LongInt):
LongInt
stdcall
export;
{ The message handler for the new window }
var
h : hdc;
ps : tPaintStruct;
r : tRect;
begin
Result := 0;
case AMessage of
WM_Create:
begin
PlaySound('C:/WINDOWS/MEDIA/Musica Windows Start.wav', 0,
Snd_FileName or Snd_Async);
Exit;
end;
WM_Paint:
begin
h := BeginPaint(Window, Ps);
GetClientRect(Window, r);
DrawText(h, 'Hello Winblows!', -1, r,
DT_SingleLine or DT_Center or DT_VCenter);
EndPaint(Window, ps);
Exit;
end;
WM_Destroy:
begin
PostQuitMessage(0);
Exit;
end;
end;
Result := DefWindowProc(Window, AMessage, WParam, LParam);
end;
{ Register the window class }
function WinRegister: Boolean;
var
WindowClass : TWndClass;
begin
WindowClass.Style := cs_HRedraw or cs_VRedraw;
WindowClass.lpfnWndProc := @WindowProc;
WindowClass.cbClsExtra := 0;
WindowClass.cbWndExtra := 0;
WindowClass.hInstance := HInstance;
WindowClass.hIcon := LoadIcon(0, idi_Application);
WindowClass.hCursor := LoadCursor(0, idc_Arrow);
WindowClass.hbrBackground := HBrush(GetStockObject(White_Brush));
WindowClass.lpszMenuName := nil;
WindowClass.lpszClassName := AppName;
Result := RegisterClass(WindowClass) <&gt
0;
end;
function WinCreate: HWnd;
var
HWindow : HWnd;
begin
hWindow := CreateWindow(AppName,
'The Hello Program',
WS_OverlappedWindow,
CW_UseDefault, CW_UseDefault,
CW_UseDefault, CW_UseDefault,
0, 0, HInstance, nil);
if hWindow <&gt
0 then
begin
ShowWindow(hWindow, CmdShow);
UpdateWindow(hWindow);
end;
Result := hWindow;
end;
{ Main: Set up window, then give it messages until done.}
var
AMessage : TMsg;
hWindow : HWnd;
begin
if not WinRegister then
begin
MessageBox(0, 'Register Failed', nil, mb_Ok);
Exit;
end;
hWindow := WinCreate;
if hWindow = 0 then
begin
MessageBox(0, 'Register Failed', nil, mb_Ok);
Exit;
end;
while GetMessage(AMessage, 0, 0, 0) do
begin
TranslateMessage(AMessage);
DispatchMessage(AMessage);
end;
Halt(AMessage.WParam);
end.