tags:

views:

27

answers:

2

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 anything and it didn't draw a line. ComComponent.DockStyle = DockStyle.Fill

A: 

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.

Arseny
Yes, it has its own Paint message. I placed my code to it but no effect =\
nik
A: 

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

erikkallen
I have a property called CtlBackColor. I can set it's value to Transparent but it doesn't change anything.
nik