Sign in Join

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

Mailing lists / lazarus / 2009-01

Error when create a main window

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Carlos German Tejero

Hi, i'm using lazarus v0.9.27 r18334 i386-win32-win32/win64 and fpc 2.2.3 on a WindowsXP64.
I try to port a delphi program to lazarus/fpc, but when create then main window, the program raise an exception.
The exception raise in Win32WSControls unit:

....
      {$ifdef WindowsUnicodeSupport}
      if UnicodeEnabledOS then
        Window := CreateWindowExW(FlagsEx,
PWideChar(WideString(pClassName)),      //<<<--- Return 0
          PWideChar(Utf8Decode(WindowTitle)), Flags,
          Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil)
      else
        Window := CreateWindowEx(FlagsEx, pClassName,
          PChar(Utf8ToAnsi(WindowTitle)), Flags,
          Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil);
      {$else}
        Window := CreateWindowEx(FlagsEx, pClassName,
          PChar(WindowTitle), Flags,
          Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil);
      {$endif}
      if Window = 0 then
      begin
        raise exception.create('failed to create win32 control, error:
'+IntToStr(GetLastError()));  //<<<-- Raise then exception
      end;
...

The attached file "error.txt" is a backtrace.

Any help or suggestion are welcome!!!!
Sorry my null english.

Carlos Germ?n Tejero -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090119/7c7f7a92/attachment-0001.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: error.txt Url: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090119/7c7f7a92/attachment-0001.txt

Reply by email

Vincent Snijders
to Carlos German Tejero

2009/1/20 Carlos German Tejero :

Show quoted text 34 lines
Hi, i'm using lazarus v0.9.27 r18334 i386-win32-win32/win64 and fpc 2.2.3 on a WindowsXP64. I try to port a delphi program to lazarus/fpc, but when create then main window, the program raise an exception. The exception raise in Win32WSControls unit: .... {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then Window := CreateWindowExW(FlagsEx, PWideChar(WideString(pClassName)), //<<<--- Return 0 PWideChar(Utf8Decode(WindowTitle)), Flags, Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil) else Window := CreateWindowEx(FlagsEx, pClassName, PChar(Utf8ToAnsi(WindowTitle)), Flags, Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil); {$else} Window := CreateWindowEx(FlagsEx, pClassName, PChar(WindowTitle), Flags, Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil); {$endif} if Window = 0 then begin raise exception.create('failed to create win32 control, error: '+IntToStr(GetLastError())); //<<<-- Raise then exception end; ... The attached file "error.txt" is a backtrace. Any help or suggestion are welcome!!!! Sorry my null english.

If you continue to run it, what is the exception message (or the GetLastError)?

Vincent

Reply by email

Carlos German Tejero
to Vincent Snijders

failed to create win32 control, error: 1407

2009/1/20 Vincent Snijders

Show quoted text 46 lines
2009/1/20 Carlos German Tejero : > Hi, i'm using lazarus v0.9.27 r18334 i386-win32-win32/win64 and fpc 2.2.3 on > a WindowsXP64. > I try to port a delphi program to lazarus/fpc, but when create then main > window, the program raise an exception. > The exception raise in Win32WSControls unit: > > .... > {$ifdef WindowsUnicodeSupport} > if UnicodeEnabledOS then > Window := CreateWindowExW(FlagsEx, > PWideChar(WideString(pClassName)), //<<<--- Return 0 > PWideChar(Utf8Decode(WindowTitle)), Flags, > Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil) > else > Window := CreateWindowEx(FlagsEx, pClassName, > PChar(Utf8ToAnsi(WindowTitle)), Flags, > Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil); > {$else} > Window := CreateWindowEx(FlagsEx, pClassName, > PChar(WindowTitle), Flags, > Left, Top, Width, Height, Parent, MenuHandle, HInstance, nil); > {$endif} > > if Window = 0 then > begin > raise exception.create('failed to create win32 control, error: > '+IntToStr(GetLastError())); //<<<-- Raise then exception > end; > ... > > The attached file "error.txt" is a backtrace. > > Any help or suggestion are welcome!!!! > Sorry my null english. If you continue to run it, what is the exception message (or the GetLastError)? Vincent _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Carlos Germ?n Tejero -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090120/0fb4808c/attachment.html

Reply by email

Vincent Snijders
to Carlos German Tejero

2009/1/20 Carlos German Tejero :

Show quoted text 5 lines
failed to create win32 control, error: 1407 > If you continue to run it, what is the exception message (or the > GetLastError)? >

This means:
ERROR_CANNOT_FIND_WND_CLASS
1407
0x57F
Cannot find window class.

Does your lpr call Application.Initialize before it calls Application.CreateForm?

Vincent

Reply by email

Carlos German Tejero
to Vincent Snijders

NO, Application.Initialize is never called!!!

Thanks Vincent, this is a very old delphi 3 program that i want port.

Thanks again!!!!

2009/1/20 Vincent Snijders

Show quoted text 22 lines
2009/1/20 Carlos German Tejero : > failed to create win32 control, error: 1407 > >> If you continue to run it, what is the exception message (or the >> GetLastError)? >> This means: ERROR_CANNOT_FIND_WND_CLASS 1407 0x57F Cannot find window class. Does your lpr call Application.Initialize before it calls Application.CreateForm? Vincent _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Carlos Germ?n Tejero -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090120/6af1e686/attachment.html

Reply by email

Vincent Snijders
to Carlos German Tejero

2009/1/20 Carlos German Tejero :

Show quoted text 6 lines
NO, Application.Initialize is never called!!! Thanks Vincent, this is a very old delphi 3 program that i want port. Thanks again!!!!

You are not the first. Googling for lazarus error 1407 gives among others: http:/msg18921.html

Vincent

Reply by email