It doesn't draw above com-component
I have a graphical com-component from our vendor. I placed it in main form and want to draw above it. But MainForm_paint doesn't draw above that component. Is there any way to paint above that component ?
C#, WinForms, 2.0
code:
void MainForm_Paint(object sender, PaintEventArgs e)
{
using (SolidBrush b2 = new SolidBrush(Color.Red))
{
e.Graphics.FillRectangle(b2, this.ClientRectangle);
}
Pen pen = new Pen(Color.Black, 2.0f);
e.Graphics.DrawLine(pen, 0, 0, 100, 100);
pen.Dispose();
}
It didn't fill anyth开发者_如何学Going and it didn't draw a line. ComComponent.DockStyle = DockStyle.Fill
you cannot draw above the component. ActiveX has its own Paint message. if Paint event is visible in your container(winform) you may override it.
If you can set the control's background to transparent, do that. Otherwise, it might be possible to subclass the control's window and ignore WM_ERASEBKGND (or whatever it's called).
Or if you know exactly where you want to paint, you can place a non-rectangular window above the ActiveX control.
Edit: Added last suggestion
精彩评论