[fpc-pascal] Windows test program
Ludo Brands
ludo.brands at free.fr
Thu Jun 23 19:42:13 CEST 2011
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-bounces at lists.freepascal.org
> [mailto:fpc-pascal-bounces at lists.freepascal.org] De la part
> de Ludo Brands
> Envoyé : jeudi 23 juin 2011 19:35
> À : carsten at 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-bounces at lists.freepascal.org
> > [mailto:fpc-pascal-bounces at 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 at lists.freepascal.org
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> >
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list