Recent

Author Topic: Where is AllocateHwnd?  (Read 19592 times)

Guest

  • Guest
Where is AllocateHwnd?
« on: March 09, 2004, 11:48:27 pm »
I use AllocateHwnd in order to get a window handle to pass windows messages in a lot of my components, but I can't find this function in the classes unit.
  I don't care about cross platform compliance at this point.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2519
Where is AllocateHwnd?
« Reply #1 on: March 10, 2004, 03:27:47 pm »
What's wrong with TWincontrol.Handle ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Anonymous

  • Guest
Where is AllocateHwnd?
« Reply #2 on: September 02, 2005, 06:44:29 am »
I need this method also. I need a invisible window to receive message and use my custom WindProc to process my custom-defined messages, if I use TWinControl.Handle, I must create a new class inherits from TWinControl, then override WndProc()method, that's need much more work.

So I still think methods like AllocateHwnd() and DeallocateHwnd() are needed!

Phil H.

  • Guest
AllocateHWnd
« Reply #3 on: September 02, 2005, 04:21:22 pm »
Quote from: "Anonymous"
I need this method also. I need a invisible window to receive message and use my custom WindProc to process my custom-defined messages, if I use TWinControl.Handle, I must create a new class inherits from TWinControl, then override WndProc()method, that's need much more work.

So I still think methods like AllocateHwnd() and DeallocateHwnd() are needed!


Yes, they are needed. I posted this as bug 4249 on 2005-08-03 with FPC since in Delphi these functions are part of the Classes unit, which appears to be FPC's responsibility, not LCL's.

For now, what I'm doing is just using the AllocateHWnd/DeallocateHWnd code from Delphi 7's Classes.pas in porting my components. I hope that in time they become available cross-platform in FPC's Classes unit.

mattias

  • Administrator
  • Full Member
  • *
  • Posts: 172
    • http://www.lazarus.freepascal.org
RE: AllocateHWnd
« Reply #4 on: September 02, 2005, 11:27:56 pm »
I took a look at the Delphi implmentation and it looks very winapi specific.
Can you tell, define in a platform independent way, what AllocateHwnd does?
Then maybe non windows people can help to implement it. And if it is possible on all platforms it will be added to the LCL.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2519
RE: AllocateHWnd
« Reply #5 on: September 05, 2005, 02:10:34 pm »
AllocateHwnd is a Delphi "utility" for the windows way of IPC.
External apps and sometimes also in one app, one needs a Window to send messages to.
Since IMO this way of communication is primarly defined by those external apps, there is IMO no way to make such generic and platform independent and usefull at the same time.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Phil H.

  • Guest
Re: RE: AllocateHWnd
« Reply #6 on: September 21, 2005, 11:56:18 pm »
Quote from: "Marc"
AllocateHwnd is a Delphi "utility" for the windows way of IPC.
External apps and sometimes also in one app, one needs a Window to send messages to.
Since IMO this way of communication is primarly defined by those external apps, there is IMO no way to make such generic and platform independent and usefull at the same time.


Both Delphi's TTimer control and Orpheus' TOvcTimer controls use AllocateHWnd to create their windows since they are non-visual controls. Borland created equivalent AllocateHWnd and DeallocateHWnd functions for Kylix in its WinUtils.pas unit so it should be possible to do the same for Lazarus. Without these functions (and related MakeObjectInstance and FreeObjectInstance functions), it might be impossible to port Orpheus to Lazarus.

Thanks.

-Phil

skywriter

  • New Member
  • *
  • Posts: 28
RE: Re: RE: AllocateHWnd
« Reply #7 on: September 29, 2007, 03:45:13 pm »
I think you should not escape from "non-crossplatform" functions because it may limit Lazarus's usability significanly. Even in those approaches where cross-platform-ness could be achieved by combination of several platform-depended ways.
See "Synaser" for example: they use platform-depenent implementaion of functions which are available for use on different platforms.

Curt Carpenter

  • Full Member
  • ***
  • Posts: 130
Re: Where is AllocateHwnd?
« Reply #8 on: August 23, 2011, 05:46:47 am »
This is a very old thread -- but for future reference by anyone who may try to use AllocateHwnd or DeallocateHwnd in the future:

In Lazarus 0.9.30, the source for these two procedures is in the fpc  subdirectory at  ..\source\rtl\win32\classes.pp then
classesh.inc.

The procedures are there in the code -- but they are only stubs that do nothing except generate a Runerror(217) message.
Hence code that uses these procedures will compile alright -- but will fail at runtime with that error message.

 

TinyPortal © 2005-2018