Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force create handle for Control

I'm currently creating a silent print module. The current control I'm using is, it's making sure that the control handle is already created (IsHandleCreated). I did everything to cheat this with no luck at all.

Do you have ideas in mind on how can I create a handle for the control without displaying any in the screen?

like image 634
Marc Vitalis Avatar asked Nov 27 '09 10:11

Marc Vitalis


3 Answers

You have to access the Handle property (put the result in a dummy variable or something). Look in Reflector; it forces handle creation.

like image 125
wj32 Avatar answered Oct 16 '22 17:10

wj32


Try to overload CreateParams property getter. In it clear the WS_VISIBLE flag.

like image 42
denisenkom Avatar answered Oct 16 '22 16:10

denisenkom


I had the same problem with some other controls and used the Control.CreateControl() method:

private void CheckForExistingHandle(Control control)
{
    if (!control.IsHandleCreated)
        control.CreateControl();
}

But i don't know how it works with a print module.

like image 34
Oliver Avatar answered Oct 16 '22 17:10

Oliver