views:

304

answers:

4

Hi to all,

I have a transparent panel, which I have put on another panel, the problem occurs by moving the transparent panel. Because it holds the image part of bottom panel. The transparent panel is refreshed only by minimize and maximize the form window. The control.Refresh or control.Invalidate does not work ...

How I can move an image with true display behind ?

this question is related to http://stackoverflow.com/questions/1234999/transparency-problem-by-overlapped-pictureboxs-at-c

A: 

Have you tried calling Invalidate on your Form?

-- Edit

Is the OnPaint method being called after you move your smaller objects?

-- Edit #2

I would say to get the result you want you need to override the OnPaint method of your form and draw everything yourself. Alternatively, now might be a good time to start learning WPF.

Filmund
A: 

Yes I have it does not work... Main purpose was, to add small objects on an image and make them moveable. So this objects [graphics like rectangle, circle or some symbols] can be moved by user, too. The problem is, this objects are png's or gif's some part of them are transparent. The problem occurs by movement... Transparent get the part of bottom image and move with that together.

Cmptrb
A: 

No, by movement I change only MyControl.Left and MyControl.Top properties. I have done something by form_load : panel1.Invalidate and during movement MyControl.refresh() is called:

    void tpb_MouseMove(object sender, MouseEventArgs e)
    {
        if (ismoving)
        {
            tpb.Left += (e.X - dx);
            tpb.Top += (e.Y - dy);
            pictureBox1.Invalidate(); 
            tpb.Refresh();    // tpb is here MyControl
        }
    }

This works, but MyControl is moving like a ghost. If the mouse movement is fast, MyControl get invisible for a short time, get visible by stop or during movement does it appears not continuously.

If I would not call refresh, myControl get completely invisible.

Cmptrb
A: 

I know WPF is a better solution, but Wpf is not suitable for my whole project.

    protected override void OnPaint(PaintEventArgs pe)
    {
         if(Image != null)
            pe.Graphics.DrawImage(Image, 40, 40);
    }

do you mean something like that ? During movement this method is called... [cause of using refresh ...]

By debugging I have released that refresh method is invoking OnPaint method non-stop... That's why MyControls appears like in a time period.

The problem is always transparency to show an image is ok, to move it smoothly without any problem is really easy. Hard part is, the images has transparent part, which should show what's behind, but they did not do it. Until the form is minimized and maximized, or the worse case is on running

Cmptrb