Making a winform form owner drawable
I have a form that I am attempting to override the WndProc subroutine on. I am using GetDCEx to get a DC handle to my form. According to Microsoft's documentation on using GetDCEx, my form must have the CS_OWNDC or the C开发者_运维技巧S_PARENTDC flag set my window class in order to use GetDCEx. According to Spy++, my window does not have these class attributes. My question is, how can I assign CS_OWNDC or make the form owner-drawable so I can use GetDCEx in my program? I am using C#, by the way.
I think you should override CreateParams
in your code like this:
/// <summary>
/// Overrides the control's class style parameters.
/// </summary>
protected override CreateParams CreateParams
{
get
{
Int32 CS_VREDRAW = 0x1;
Int32 CS_HREDRAW = 0x2;
Int32 CS_OWNDC = 0x20;
CreateParams cp = base.CreateParams;
cp.ClassStyle = cp.ClassStyle | CS_VREDRAW | CS_HREDRAW | CS_OWNDC | ...;
return cp;
}
}
精彩评论