Click here to Skip to main content
15,891,708 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: VS 2002 and VS 2003 at the same time… Pin
toxcct13-Jun-05 1:10
toxcct13-Jun-05 1:10 
GeneralRe: VS 2002 and VS 2003 at the same time… Pin
anderslundsgard13-Jun-05 3:06
anderslundsgard13-Jun-05 3:06 
GeneralGetting rid of lag with pictureBox Pin
pcxboy11-Jun-05 19:00
pcxboy11-Jun-05 19:00 
GeneralRe: Getting rid of lag with pictureBox Pin
Robert Rohde11-Jun-05 20:42
Robert Rohde11-Jun-05 20:42 
GeneralRe: Getting rid of lag with pictureBox Pin
pcxboy11-Jun-05 20:50
pcxboy11-Jun-05 20:50 
GeneralRe: Getting rid of lag with pictureBox Pin
Robert Rohde11-Jun-05 21:16
Robert Rohde11-Jun-05 21:16 
GeneralRe: Getting rid of lag with pictureBox Pin
pcxboy12-Jun-05 0:31
pcxboy12-Jun-05 0:31 
GeneralRe: Getting rid of lag with pictureBox Pin
Robert Rohde12-Jun-05 1:02
Robert Rohde12-Jun-05 1:02 
No I meant overriding the OnPaint method of the form (but that shouldn't make a difference). I made a simple text which work fine for me (when the image is very big it slows down). Probably it helps you:
public class Form1 : System.Windows.Forms.Form
{
	private Point _curPos = new Point(0, 0);
	private Image _image;

	public Form1()
	{
		base.KeyPress += new KeyPressEventHandler(Form1_KeyPress);
		SetStyle(ControlStyles.UserPaint, true);
		SetStyle(ControlStyles.AllPaintingInWmPaint, true);
		SetStyle(ControlStyles.DoubleBuffer, true);
		_image = new Bitmap("C:\\test2.jpg");
	}

	private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
	{
		switch (e.KeyChar)
		{
			case 'w': _curPos.Y -= 5; break;
			case 's': _curPos.Y += 5; break;
			case 'a': _curPos.X -= 5; break;
			case 'd': _curPos.X += 5; break;
		}
		Invalidate();
	}

	protected override void OnPaint(PaintEventArgs e)
	{
		base.OnPaint (e);
		e.Graphics.DrawImageUnscaled(_image, _curPos);
	}
}


Note that I'm calling the Invalidate method instead of Refresh. This is always better because the Refresh will repaint the form immediatly while Invalidate will wait until there is time to do so. If you have much more other things on your form it would also be a good idea to give a Rectangle into the form which specifies which particular region should be repainted.
GeneralImplementing Access Levels Pin
tinkis11-Jun-05 8:45
tinkis11-Jun-05 8:45 
GeneralApplication has generated an exception that could not be handled Pin
xeric10-Jun-05 18:25
xeric10-Jun-05 18:25 
GeneralRe: Application has generated an exception that could not be handled Pin
mav.northwind10-Jun-05 21:06
mav.northwind10-Jun-05 21:06 
GeneralRe: Application has generated an exception that could not be handled Pin
xeric11-Jun-05 2:49
xeric11-Jun-05 2:49 
Generala problem in mirrored listview Pin
AbuMosaab10-Jun-05 12:43
AbuMosaab10-Jun-05 12:43 
GeneralEvent handling on remoting classes Pin
Anonymous10-Jun-05 12:29
Anonymous10-Jun-05 12:29 
GeneralRe: Event handling on remoting classes Pin
S. Senthil Kumar10-Jun-05 22:00
S. Senthil Kumar10-Jun-05 22:00 
GeneralRe: Event handling on remoting classes Pin
Anonymous11-Jun-05 14:07
Anonymous11-Jun-05 14:07 
GeneralRe: Event handling on remoting classes Pin
Anonymous11-Jun-05 14:26
Anonymous11-Jun-05 14:26 
GeneralWrapper class for SqlConnection Pin
Hamlet_h10-Jun-05 4:00
Hamlet_h10-Jun-05 4:00 
GeneralRe: Wrapper class for SqlConnection Pin
Dave Kreskowiak10-Jun-05 4:17
mveDave Kreskowiak10-Jun-05 4:17 
GeneralRe: Wrapper class for SqlConnection Pin
Not Active10-Jun-05 9:31
mentorNot Active10-Jun-05 9:31 
GeneralCheck permissions Pin
cyonite10-Jun-05 2:55
cyonite10-Jun-05 2:55 
GeneralCustom Editor for TreeView Nodes!!!☺ Pin
sharaabi10-Jun-05 2:11
sharaabi10-Jun-05 2:11 
Generalshell extension (windows explorer ) Pin
Anonymous8-Jun-05 23:56
Anonymous8-Jun-05 23:56 
GeneralProject settings - output Pin
john john mackey8-Jun-05 14:46
john john mackey8-Jun-05 14:46 
GeneralVS .NET Installer crashing from CustomActionData Pin
lukemc8-Jun-05 8:43
lukemc8-Jun-05 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.