I know how to make a window a certian shape and dissable the title bar but how do you allow it to be moved in the same way as a normal window.
Like lets say i make a window that is shaped like a cd and it has no titlebar
but i would like to click anywhere on the cd and move it on the screen

Creating a shape for a window
RStanton
zapacila89
I am going to try this when i get a chance, but what does the PointToScreen command do
and i guess i really dont need to know based on shape just if i can click anywhere on the window and drag it around
ScrappyDoo
public Point PointToScreen(Point p);
Parameters
p The client coordinate Point to convert.
Return Value
A Point that represents the converted Point, p, in screen coordinates.
// as to the reverse:
public Point PointToClient(Point p);
Parameters
p The screen coordinate Point to convert.
Return Value
A Point that represents the converted Point, p, in client coordinates.
I hope the PTB's enable reversible drawing in Graphics, so that these conversions are not neccessairy. It is just the controls are drawn in coordinates relative to their parents, while DrawReversibleLine(..) uses screen coordinates. Always a headache of figuring out exactly the what is what and the who is who in these kind of cases. Setting breakpoint and note the different values the event parameter holds, and some puzzling on what to use, you'll probably get thing 'stable' the way you want.
strumbling around through the help system is always helpfull to figure thing out, many a sample is in the MSDN help. (also available on line)
Kingsley Tagbo
ShimonSim
srii
Note that the code was "ad hock" and therefore "not tested", perhaps you need method <strong>PointToScreen(..)</strong> to stabilize your windows eratic behaviour by converting client coordinates to screen coordinates. As said experiment somewhat with it, somewhere along these lines it ought to work (in debugmode you might figure out what the exact values are, these might give you a clue how to stabilize your windows behaviour)
Paulo Aboim Pinto
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication2
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private bool mouseDown = false;
private int xOffset = 0;
private int yOffset = 0;
public Form1()
{
InitializeComponent();
MouseDown +=new MouseEventHandler(Form1_MouseDown);
MouseUp +=new MouseEventHandler(Form1_MouseUp);
MouseMove +=new MouseEventHandler(Form1_MouseMove);
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
xOffset = e.X;
yOffset = e.Y;
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if(mouseDown)
{
this.Left = e.X + Left - xOffset;
this.Top = e.Y + Top - yOffset;
}
}
}
}
Obble
what can i use to make this work correctly
here is what i have so far
Dim winx, winy, msx, msy As Integer
Private Sub frmNPCalc_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
winx = window.X
winy = window.Y
msx = e.X
msy = e.Y
End Sub
Private Sub frmNPCalc_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
window.X = winx + e.X - msx
window.Y = winy + e.Y - msy
End Sub
Regis St-Gelais
dabro
Set the Form.FormBorderStyle to None.
Set Form.TransparencyKey to something you're not going to use in the form eg bright red. Then set the Form.BackColor to be the same.
Add an Image Control that is a big circle (with the outside colour set to bright Red - or maybe transparent - not tried this yet).
Send this image to the back (Send to Back).
Add your controls on top of the circle.
Moving the circle - not so sure (sorry!)
I've used this technique and it works (its a work round)
Put a very thin Panel horizontally across the top of your form.
Make it invisible (bright red).
Use the Panels Mouse.Enter event to set the Form.FormBorderStyle = Fixed (or other) and also enable the timer (see below).
Add a Timer that lasts for 2 seconds. When the timer event fires set the Form.FormBorderStyle to None.
The effect is that you have a circle with controls on it and no form border. When the mouse goes near (over) the top of the invisible form (ie goes over the long thin Panel) then form border appears (allowing form to be moved, minimised etc). After 2 seconds the form border disappears leaving the circle again.
Hope that helps.
Chiz.
sou1_pure
window.MouseDown += new MouseEventHandler(OnMouseDown);
window.MouseMove += new MouseEventHandler(OnMouseMove);
to the handlers:
int winx,winy,msx,msy;
private void OnMouseDown(object sender,MouseEventArgs e)
{
winx = window.X;
winy = window.Y;
msx = e.X;
msy = e.Y;
}
private void OnMouseMove(object sender,MouseEventArgs e)
{
window.X = winx + e.X - msx;
window.Y = winy + e.Y - msy;
}
or something simular (note the above I coded at hock, but something along these lines ought to work I think)