Force create handle for Control

﹥>﹥吖頭↗ 提交于 2019-12-01 15:55:07
denisenkom

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

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

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.

NthDeveloper

I solved this annoying handle creation problem by settings the WS_VISIBLE of CreationParams. You may either override the CreationParams property of Control or call the CreateHandle method with appropriate CreateParams instance. See the link

Calling private method CreateHandle will do the work.

MethodInfo ch = frm.GetType().GetMethod("CreateHandle", BindingFlags.NonPublic | BindingFlags.Instance);
ch.Invoke(frm, new object[0]);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!