[fpc-pascal] Windows test program
Carsten Bager
carsten at beas.dk
Thu Jun 23 17:35:33 CEST 2011
Hi
I have this test program. It compiles and runs (shows) under Delphi (5.0).
I can compile (and run it) it under FPC (2.4.4) but it does not show anything. I can see it in
the Windows Job list -> Processes but not under Programmes.
Anybody have a hint.
Regards
Carsten
C:\FPC\2.4.4\bin\i386-win32\fpc -WG generic.dpr
Free Pascal Compiler version 2.4.4 [2011/04/23] for i386
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Win32 for i386
Compiling generic.dpr
Compiling resource generic.or
Linking generic.exe
106 lines compiled, 0.9 sec , 26992 bytes code, 1688 bytes data
{************************************************}
{ }
{ Demo program }
{ Copyright (c) 1991, 2007 by CodeGear }
{ }
{************************************************}
{ "Generic" Windows application written in Turbo Pascal }
program Generic;
{$R GENERIC.RES}
uses Messages,Windows;
const
SAppName = 'Generic';
SAboutBox = 'AboutBox';
SWindowName = 'Turbo Pascal Generic';
IDOK = 1;
ID_OK = IDOK;
IDCANCEL = 2;
ID_CANCEL = IDCANCEL;
const
idm_About = 100;
function About(Dialog: HWnd; Message:LongWord; WParam,LParam: Longint):LongInt;
stdcall;
begin
About := ord(True);
case Message of
wm_InitDialog:
Exit;
wm_Command:
if (WParam = id_Ok) or (WParam = id_Cancel) then
begin
EndDialog(Dialog, 1);
Exit;
end;
end;
About := ord(False);
end;
function WindowProc(Window: HWnd; Message:longword; WParam,LParam: Longint):
Longint; stdcall;
begin
WindowProc := 0;
case Message of
wm_Command:
if WParam = idm_About then
begin
DialogBox(HInstance, SAboutBox, Window, @About);
Exit;
end;
wm_Destroy:
begin
PostQuitMessage(0);
Exit;
end;
end;
WindowProc := DefWindowProc(Window, Message, WParam, LParam);
end;
var
WindowClass: TWndClass = (
style: 0;
lpfnWndProc: @WindowProc;
cbClsExtra: 0;
cbWndExtra: 0;
hInstance: 0;
hIcon: 0;
hCursor: 0;
hbrBackground: COLOR_WINDOW;
lpszMenuName: SAppName;
lpszClassName: SAppName);
procedure WinMain;
var
Window: HWnd;
Message: TMsg;
begin
{ Register the window class }
WindowClass.hInstance := HInstance;
WindowClass.hIcon := LoadIcon(0, idi_Application);
WindowClass.hCursor := LoadCursor(0, idc_Arrow);
if Windows.RegisterClass(WindowClass) = 0 then
Halt(1);
{ Create and show the window }
Window := CreateWindow(SAppName, SWindowName,
ws_OverlappedWindow,cw_UseDefault,cw_UseDefault, 320, 240,
0, 0, HInstance, nil);
ShowWindow(Window, CmdShow);
UpdateWindow(Window);
{ and crank up a message loop }
while GetMessage(Message, 0, 0, 0) do
begin
TranslateMessage(Message);
DispatchMessage(Message);
end;
Halt(Message.wParam);
end;
begin
WinMain;
end.
More information about the fpc-pascal
mailing list