Pelles C forum

C language => Windows questions => Topic started by: czerny on February 01, 2015, 08:18:13 PM

Title: windowless controls
Post by: czerny on February 01, 2015, 08:18:13 PM
I have read the following article:
http://blogs.msdn.com/b/oldnewthing/archive/2005/02/11/371042.aspx (http://blogs.msdn.com/b/oldnewthing/archive/2005/02/11/371042.aspx)
Had never heared from windowless controls before.

Has anybody any experiences with such controls? A little example? Are these always ActiveX controls (I can not find anything other)?
Has the parent window of such a control to be somehow special?
Title: Re: windowless controls
Post by: frankie on February 01, 2015, 08:57:07 PM
See this (https://msdn.microsoft.com/en-us/library/windows/desktop/ms679701(v=vs.85).aspx).
And this (https://msdn.microsoft.com/en-us/library/windows/desktop/hh437319(v=vs.85).aspx) for usage hints.
Title: Re: windowless controls
Post by: czerny on February 02, 2015, 12:10:54 PM
This looks very complicated!
Are there any examples in the net of an ActiveX control written in C?
Title: Re: windowless controls
Post by: frankie on February 02, 2015, 01:36:17 PM
Yes, it looks and ... it is  ;D
I'm joking, this controls use the OLE/COM interfaces. Good samples are on Codeproject from Jeff Glatt, here (http://forum.pellesc.de/index.php?topic=5332.0) there is a port of that examples that I used to test my typelib generator (you may need it to create headers from Activix or OLE/COM controls).
The same is used by PellesC IDE to show web pages, and in the Mctrl library to show html pages and other.
Title: Re: windowless controls
Post by: czerny on February 02, 2015, 03:33:06 PM
Thanks for the above link. I have not known this thread of you. I will study it in the next days!

But, if I have understood it right, these all are examples, how to use such controls and not, how to write them. Right?
Title: Re: windowless controls
Post by: frankie on February 02, 2015, 04:17:16 PM
If you read articles from Jeff Glatt on Codeproject he will drive you to write some basic COM in C, but it is a nosense to use C to develop COM apps...
As poor man windowless control you can code all of your control asking to the user to give you a valid window handle were to show your control. Then subclassing the window you can intercept the messaging and use that window as one created by you. Not an ActiveX nor a COM, but works...  ;)
Title: Re: windowless controls
Post by: czerny on February 02, 2015, 05:59:39 PM
I have read that one of the main causes why such windowless controls are used is/was to save window handles.
I can think of complex controls, which have lots of child controls. But this is a special situation in which all these child controls share the same parent. The parent could seen as a container window which place his window handle to the childs disposal. There would be some houskeeping but no COM.
Title: Re: windowless controls
Post by: DMac on February 02, 2015, 07:51:30 PM
My Property Grid (http://forum.pellesc.de/index.php?topic=3175.0)[^ (http://forum.pellesc.de/index.php?topic=3175.0 target=_blank title="New Window")] makes use of only two child handles and DrawFrameControl() for all of the various control options.  At any given time there are either either 0, 1 or 2 child handles in existence no matter the number of properties in the grid.  The same goes for the Simple grid (http://forum.pellesc.de/index.php?topic=5833.0)
[^ (http://forum.pellesc.de/index.php?topic=5833.0 target=_blank title="New Window")].  It is possible to minimize child handles without COM by being creative and Grid styled parent controls lend themselves to this kind of thing.
Title: Re: windowless controls
Post by: czerny on February 02, 2015, 08:07:52 PM
This is a good example. A web page is an other example.
The container window should be able to calculate which child is responsible for a mouse click. Such a calculation could be simple, in a grid for example, or more difficult like in the case from a web page. Maybe a 2-d-tree is usefull to calculate this quickly.