How do I Paint a Control without adding it to Controls?

  • Thread starter Thread starter Kent Rollins
  • Start date Start date
K

Kent Rollins

I am trying to cause a custom Control to paint while that Control is
not a member of Form.Controls. I prefer not to add it to Controls
because I am basically adding functioanlity to the forms designer and
if I add it to the Controls collection, I will have to add a lot of
special handling logic elsewhere in the app to work around the one
special control.

My preference is to create the special Control as a child of the Form
and forward paint messages to it thru any mechanism. I have tried
calling Control.Refresh(), Control.Invalidate(), and Control.Updte()
in the Form.Paint() method, but none of those work if the Control is
not in Controls. If I add the Control to Controls, it works
automatically as it should.

Any pointers on how to get it to paint without adding it to Controls?

Thanks
Kent
 
Kent,

Controls are child windows and if you don't add them eventually on a form
(toplevel window) I don't think you can display them at all in order to
paint them.
Am I missing something?

In win32 you cannot create a child window without specifying its parent. In
..NET this is possible because the framwork uses one special form called
WindowsFormsParkingWindow. All controls that don't have set parent are
children of this window.
 
Back
Top