If we want to use SendMessage or PostMessage, we have to supply a window
handle to the 2 function. The most common way of using pattern is
TWinControl descendant.
W := TWinControl_Descendant.Create(nil);
W.Parent := Application.MainForm;
PostMessage(W.Handle, 10000, 0, 0);
W must have parent set else the handle won't be allocated. I just
wondering if we can declare a handle to a TObject descendant and
allocate a handle to it without setting the parent. Is that possible to
do so?
--
Best regards,
Chau Chee Yang
E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting
IBX does this in the SQLMonitor code look at the TIBCustomSQLMonitor class in
IBSQLMonitor.pas. The create allocates a windows handle, the destroy cleans it
up, and MonitorWndProc processes the messages.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
> I just wondering if we can declare a handle to a TObject
> descendant and allocate a handle to it without setting the
> parent. Is that possible to do so?
You can use the VCL's AllocateHWnd() function to create a hidden HWND that
has a class method assigned as its window procedure. Some of the VCL's own
non-visual components, such as TTimer, use this technique.
Gambit
> Hi,
>
> If we want to use SendMessage or PostMessage, we have to supply a
> window handle to the 2 function. The most common way of using
> pattern is TWinControl descendant.
>
> W := TWinControl_Descendant.Create(nil);
> W.Parent := Application.MainForm;
> PostMessage(W.Handle, 10000, 0, 0);
>
> W must have parent set else the handle won't be allocated. I just
> wondering if we can declare a handle to a TObject descendant and
> allocate a handle to it without setting the parent. Is that possible
> to do so?
Look at the AllocateHwnd and DeallocateHwnd functions from the Classes
unit. Just make sure you pass any messages you do not process from the
message handler function you provide to DefWindowProc. The two
functions are not thread-safe, by the way.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com