RE : [fpc-pascal] Windows test program

2011-06-24 Thread Carsten Bager
That did the trick.
Carsten

> MSDN states that the first ShowWindow is ignored if a STARTUPINFO is
> provided.
>
> winhello.pp has
> ShowWindow(hWindow, CmdShow);
> ShowWindow(hWindow, SW_SHOW);
> This is the difference with your test program.
>
> Ludo
>
> > -Message d'origine-
> > De : fpc-pascal-boun...@lists.freepascal.org
> > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part
> > de Carsten Bager
> > Envoyé : vendredi 24 juin 2011 08:53
> > À : FPC-Pascal users discussions
> > Objet : RE : [fpc-pascal] Windows test program
> >
> >
> > Thanks for the help.
> > I tried the winhello.pp. It works OK.
> > I can still not get my program to show from the command line
> > (do not use gdb), but now I
> > have something to work on (it shows OK from explorer).
> > Regards Carsten
> >
> > > OK. Found the problem. The program runs ok from the
> > explorer but not
> > > from inside lazarus. That's where the difference in process
> > > STARTUPINFO structure comes from. Actually it is gdb that passes on
> > > the SW_HIDE in STARTUPINFO. Running the program from the
> > command line
> > > is fine but doesn't show anything when lauched from gdb.
> > >
> > > Ludo
> > >
> > > > -Message d'origine-
> > > > De : fpc-pascal-boun...@lists.freepascal.org
> > > > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part
> > > > de Ludo Brands
> > > > Envoyé : jeudi 23 juin 2011 19:35
> > > > À : cars...@beas.dk; 'FPC-Pascal users discussions'
> > > > Objet : RE : [fpc-pascal] Windows test program
> > > >
> > > >
> > > > The problem is in the line
> > > > ShowWindow(Window, CmdShow);
> > > > CmdShow is SW_HIDE (0) with fpc and SW_RESTORE (9) in Delphi.
> > > > CmdShow is a variable that is initialised in system.pp from
> > > > the process STARTUPINFO structure. Don't know why fpc starts
> > > > the process with SW_HIDE.
> > > > Change the line to
> > > > ShowWindow(Window, SW_RESTORE);
> > > > and the window will display;
> > > >
> > > > Ludo
> > > >
> > > > > -Message d'origine-
> > > > > De : fpc-pascal-boun...@lists.freepascal.org
> > > > > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part
> > > > > de Carsten Bager
> > > > > Envoyé : jeudi 23 juin 2011 17:36
> > > > > À : FPC-Pascal users discussions
> > > > > Objet : [fpc-pascal] Windows test program
> > > > >
> > > > >
> > > > > 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';
> > > > >   

RE : RE : [fpc-pascal] Windows test program

2011-06-24 Thread Ludo Brands
MSDN states that the first ShowWindow is ignored if a STARTUPINFO is
provided. 

winhello.pp has
ShowWindow(hWindow, CmdShow);
ShowWindow(hWindow, SW_SHOW);
This is the difference with your test program.

Ludo

> -Message d'origine-
> De : fpc-pascal-boun...@lists.freepascal.org 
> [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part 
> de Carsten Bager
> Envoyé : vendredi 24 juin 2011 08:53
> À : FPC-Pascal users discussions
> Objet : RE : [fpc-pascal] Windows test program
> 
> 
> Thanks for the help.
> I tried the winhello.pp. It works OK.
> I can still not get my program to show from the command line 
> (do not use gdb), but now I 
> have something to work on (it shows OK from explorer).
> Regards Carsten
> 
> > OK. Found the problem. The program runs ok from the 
> explorer but not 
> > from inside lazarus. That's where the difference in process 
> > STARTUPINFO structure comes from. Actually it is gdb that passes on 
> > the SW_HIDE in STARTUPINFO. Running the program from the 
> command line 
> > is fine but doesn't show anything when lauched from gdb.
> > 
> > Ludo
> > 
> > > -Message d'origine-
> > > De : fpc-pascal-boun...@lists.freepascal.org
> > > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part 
> > > de Ludo Brands
> > > Envoyé : jeudi 23 juin 2011 19:35
> > > À : cars...@beas.dk; 'FPC-Pascal users discussions'
> > > Objet : RE : [fpc-pascal] Windows test program
> > > 
> > > 
> > > The problem is in the line
> > > ShowWindow(Window, CmdShow);
> > > CmdShow is SW_HIDE (0) with fpc and SW_RESTORE (9) in Delphi. 
> > > CmdShow is a variable that is initialised in system.pp from 
> > > the process STARTUPINFO structure. Don't know why fpc starts 
> > > the process with SW_HIDE.  
> > > Change the line to 
> > > ShowWindow(Window, SW_RESTORE);
> > > and the window will display;
> > > 
> > > Ludo
> > > 
> > > > -Message d'origine-
> > > > De : fpc-pascal-boun...@lists.freepascal.org
> > > > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part
> > > > de Carsten Bager
> > > > Envoyé : jeudi 23 juin 2011 17:36
> > > > À : FPC-Pascal users discussions
> > > > Objet : [fpc-pascal] Windows test program
> > > > 
> > > > 
> > > > 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):Lon

RE : [fpc-pascal] Windows test program

2011-06-23 Thread Carsten Bager
Thanks for the help.
I tried the winhello.pp. It works OK.
I can still not get my program to show from the command line (do not use gdb), 
but now I
have something to work on (it shows OK from explorer).
Regards Carsten

> OK. Found the problem. The program runs ok from the explorer but not from
> inside lazarus. That's where the difference in process STARTUPINFO structure
> comes from. Actually it is gdb that passes on the SW_HIDE in STARTUPINFO.
> Running the program from the command line is fine but doesn't show anything
> when lauched from gdb.
>
> Ludo
>
> > -Message d'origine-
> > De : fpc-pascal-boun...@lists.freepascal.org
> > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part
> > de Ludo Brands
> > Envoyé : jeudi 23 juin 2011 19:35
> > À : cars...@beas.dk; 'FPC-Pascal users discussions'
> > Objet : RE : [fpc-pascal] Windows test program
> >
> >
> > The problem is in the line
> > ShowWindow(Window, CmdShow);
> > CmdShow is SW_HIDE (0) with fpc and SW_RESTORE (9) in Delphi.
> > CmdShow is a variable that is initialised in system.pp from
> > the process STARTUPINFO structure. Don't know why fpc starts
> > the process with SW_HIDE.
> > Change the line to
> > ShowWindow(Window, SW_RESTORE);
> > and the window will display;
> >
> > Ludo
> >
> > > -Message d'origine-
> > > De : fpc-pascal-boun...@lists.freepascal.org
> > > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part
> > > de Carsten Bager
> > > Envoyé : jeudi 23 juin 2011 17:36
> > > À : FPC-Pascal users discussions
> > > Objet : [fpc-pascal] Windows test program
> > >
> > >
> > > 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);
> 

RE : RE : [fpc-pascal] Windows test program

2011-06-23 Thread Ludo Brands
OK. Found the problem. The program runs ok from the explorer but not from
inside lazarus. That's where the difference in process STARTUPINFO structure
comes from. Actually it is gdb that passes on the SW_HIDE in STARTUPINFO.
Running the program from the command line is fine but doesn't show anything
when lauched from gdb.

Ludo

> -Message d'origine-
> De : fpc-pascal-boun...@lists.freepascal.org 
> [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part 
> de Ludo Brands
> Envoyé : jeudi 23 juin 2011 19:35
> À : cars...@beas.dk; 'FPC-Pascal users discussions'
> Objet : RE : [fpc-pascal] Windows test program
> 
> 
> The problem is in the line 
> ShowWindow(Window, CmdShow);
> CmdShow is SW_HIDE (0) with fpc and SW_RESTORE (9) in Delphi. 
> CmdShow is a variable that is initialised in system.pp from 
> the process STARTUPINFO structure. Don't know why fpc starts 
> the process with SW_HIDE.  
> Change the line to 
> ShowWindow(Window, SW_RESTORE);
> and the window will display;
> 
> Ludo
> 
> > -Message d'origine-
> > De : fpc-pascal-boun...@lists.freepascal.org
> > [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part 
> > de Carsten Bager
> > Envoyé : jeudi 23 juin 2011 17:36
> > À : FPC-Pascal users discussions
> > Objet : [fpc-pascal] Windows test program
> > 
> > 
> > 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

RE : [fpc-pascal] Windows test program

2011-06-23 Thread Ludo Brands
The problem is in the line 
ShowWindow(Window, CmdShow);
CmdShow is SW_HIDE (0) with fpc and SW_RESTORE (9) in Delphi. CmdShow is a
variable that is initialised in system.pp from the process STARTUPINFO
structure. Don't know why fpc starts the process with SW_HIDE.  
Change the line to 
ShowWindow(Window, SW_RESTORE);
and the window will display;

Ludo

> -Message d'origine-
> De : fpc-pascal-boun...@lists.freepascal.org 
> [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part 
> de Carsten Bager
> Envoyé : jeudi 23 juin 2011 17:36
> À : FPC-Pascal users discussions
> Objet : [fpc-pascal] Windows test program
> 
> 
> 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.
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows test program

2011-06-23 Thread Flávio Etrusco
On Thu, Jun 23, 2011 at 12:35 PM, Carsten Bager  wrote:
> 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
>

The program didn't show anything but an empty window, but worked
without a problem otherwise (after a commented out the .res so I could
compile). Windows 7 32-bit here. FPC 2.4.4 too.

-Flávio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows test program

2011-06-23 Thread Paul Breneman

Carsten,


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.


FPC has a WinHello.pp program in the demos folder that is similar to the 
program you posted.  You might give it a test.


Paul
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Windows test program

2011-06-23 Thread Carsten Bager
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.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal