Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-06

Windows test program

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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.

Reply by email

Paul Breneman
to Carsten Bager

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

Reply by email

Flávio Etrusco
to Carsten Bager: Hi I have this test program. It compiles and runs (shows) under Delphi (5.0). I can…
Carsten Bager wrote 9 lines
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

Reply by email

Ludo Brands
to Carsten Bager: Hi I have this test program. It compiles and runs (shows) under Delphi (5.0). I can…

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

Show quoted text 142 lines
-----Message d'origine----- De : 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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Ludo Brands
to 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

Show quoted text 168 lines
-----Message d'origine----- De : De la part de Ludo Brands Envoyé : jeudi 23 juin 2011 19:35 À : ; '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 : > 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 - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Carsten Bager
to Ludo Brands

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

Show quoted text 180 lines
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 : > De la part > de Ludo Brands > Envoyé : jeudi 23 juin 2011 19:35 > À : ; '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 : > > 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 - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Ludo Brands
to Carsten Bager

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

Show quoted text 207 lines
-----Message d'origine----- De : 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 : > > De la part > > de Ludo Brands > > Envoyé : jeudi 23 juin 2011 19:35 > > À : ; '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 : > > > 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 - > > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Carsten Bager
to Ludo Brands

That did the trick.
Carsten

Show quoted text 218 lines
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 : > 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 : > > > De la part > > > de Ludo Brands > > > Envoyé : jeudi 23 juin 2011 19:35 > > > À : ; '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 : > > > > 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 - > > > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > > > > > > _______________________________________________ > > > fpc-pascal maillist - > > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk

Reply by email