Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Moving picturebox in c# problems
New Posts  All Forums:Forum Nav:

Moving picturebox in c# problems

post #1 of 3
Thread Starter 
I have a form with a picture as its background.

Then I have a picture box with a GIF in it and its background set to transparent, to show the form background instead of white.

Whenever I move the picture box (using key capture) it will disappear until I stop pressing the move key (moves it by 25 pixels each time).

How can I prevent it from fading away while its moving?

edit: if I set the background of the image to a "color" instead of transparent, it moves like normal, but I want it to be transparent...
Code:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
                case (Keys.A):
                    ship.Left -= 25;
                    break;
                case (Keys.D):
                    ship.Left += 25;
                    break;
                case (Keys.S):
                    ship.Top += 25;
                    break;
                case (Keys.W):
                    ship.Top -= 25;
                    break;
            }
            return true;
        }

Edited by kennyparker1337 - 2/4/12 at 3:42pm
post #2 of 3
Sounds like you may have to force a redraw of your picture box in each case of your switch statement.
Daily
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 2600K @ 4.8GHz, 1.4V Maximus IV Extreme GTX 560 DCII TOP 4x4GB Kingston HyperX 1866MHz CL11 
Hard DriveHard DriveCoolingCooling
Kingston HyperX 3K 120GB Samsung 640GB Thermochill PA120.2 Jingway DB-1 Pump 
CoolingCoolingOSMonitor
2x Kaze Jyuni 1900RPM EK Supreme HF Copper plexi Arch Linux x64 Acer X223HQ 1920x1080 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX750 Modded Corsair Carbide 500R Logitech M500 
  hide details  
Reply
Daily
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 2600K @ 4.8GHz, 1.4V Maximus IV Extreme GTX 560 DCII TOP 4x4GB Kingston HyperX 1866MHz CL11 
Hard DriveHard DriveCoolingCooling
Kingston HyperX 3K 120GB Samsung 640GB Thermochill PA120.2 Jingway DB-1 Pump 
CoolingCoolingOSMonitor
2x Kaze Jyuni 1900RPM EK Supreme HF Copper plexi Arch Linux x64 Acer X223HQ 1920x1080 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX750 Modded Corsair Carbide 500R Logitech M500 
  hide details  
Reply
post #3 of 3
Thread Starter 
Quote:
Originally Posted by ARandomOWl View Post

Sounds like you may have to force a redraw of your picture box in each case of your switch statement.

Thanks!
Code:
switch
{
//code
}
ship.Refresh();
return true;
}

Fixed it. It also won't do that if I use the mouse to move it:
Code:
private void move_Tick(object sender, EventArgs e)
{
  ship.Left = Cursor.Position.X;
  ship.Top = Cursor.Position.Y;
}
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Moving picturebox in c# problems