I want do something like that:
I have form with pictures, when I click on ones, I want to display new window with this picture (it must be only picture, without some toolbox or border). Continuing I want to be able move this window (when I press button on mouse and move mouse, this window must move with my cursor, when I up button window won’t move when I move mouse).
I do it like that:
make new window form, remove toolbar, border, add pictureBox, add method on mouseDown, mouseUp and mouseMove. Code for method:
private void FormZdjecie_MouseDown( object sender, MouseEventArgs e ) {
buttonUp = false;
previous = e.Location;
}
private void pictureBox1_MouseUp( object sender, MouseEventArgs e ) {
buttonUp = true;
}
private void pictureBox1_MouseMove( object sender, MouseEventArgs e ) {
if ( !buttonUp ) {
Point diff = new Point();
diff.X = e.X - previous.X;
diff.Y = e.Y - previous.Y;
this.Location = new Point( this.Location.X + diff.X, this.Location.Y + diff.Y );
previous = e.Location;
}
}
I work, but it very slow refresh. How do it to work like windows form (when I move normal windows form it look fine), but my method look badly ;p Any idea how to make it?
You need to use the WinAPI. See here.