Question Transparent Panel disappears when clicking

mbz

New member
Joined
Nov 9, 2016
Messages
1
Programming Experience
1-3
Hey guys,

I've got a big problem, which many people seems to have:


I'm developing a WinForms application which contains a PDF editor. The class containing the AciveXControl is called PdfControl.
The PdfControl has a child which is called DrawPanel. Well, the DrawPanel is a transparent panel. On this panel the user can add
a comment (as you can see below)


right.PNG


To provide the transparency, I override the CreateParams and WndProc as follows:


C#:
    protected override CreateParams CreateParams
    {
        get
        {
            var cp = base.CreateParams;
            cp.ExStyle |= 0x00000020; //WM_EX_TRANSPARENT
            return cp;
        }
    }
    
    protected override void WndProc(ref Message m)
    {
        switch (m.Msg)
        {
            case 0x84: //WM_NCHITTEST
                m.Result = (IntPtr) HTTRANSPARENT;
                break;


            case 0x0014: // WM_ERASEBKGND
                m.Result = (IntPtr)1;
                break;


            default:
                base.WndProc(ref m);
                break;
        }
    }


Everything is working fine for now. The problem is, when clicking into the Comment (which actually is a Control containing
a RichTextBox, a panel and two buttons) the comment - well, the whole DrawPanel - disappears.
But not for real: the curosr is still there, and if the mouse hovers into that region where the Comment supposed to be, the buttons
are redrawn and visible again.


wrong_after_mouseover.PNG

This is, how it should look like:

right_editmode.PNG

When scrolling, the Comment is redrawn and appears constantly - except a kind of flicker during the scroll.


The solution you can find all over the internet when searching for that problem


C#:
SetStyle(ControlStyles.DoubleBuffer
            | ControlStyles.AllPaintingInWmPaint
            | ControlStyles.ResizeRedraw
            | ControlStyles.UserPaint, 
            | ControlStyles.SupportsTransparentBackColor
            true);


doesn't work neither.
Hope, you've got a solution for me.


Thanks
mbz
 

Latest posts

Back
Top Bottom