L
Lloyd Dupont
I have a Form initialized like that:
//--
public DragingForm()
{
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.ContainerControl, false);
SetStyle(ControlStyles.Selectable, false);
SetStyle(ControlStyles.StandardClick, false);
SetStyle(ControlStyles.StandardDoubleClick, false);
SetStyle(ControlStyles.UserMouse, false);
SetStyle(ControlStyles.SupportsTransparentBackColor, false);
SetStyle(ControlStyles.CacheText, false);
TopMost = true;
ShowInTaskbar = false;
FormBorderStyle = FormBorderStyle.None;
Opacity = 0.6;
Size = new Size(100, 20);
}
//--
When I want to display it I call the following:
//--
public void StartTracking(Control c)
{
TakeSnapshot(c, new Rectangle(0, 0, c.Width, c.Height));
CreateControl();
MoveToMouse();
SetBoundsCore(0, 0, c.Width, c.Height, BoundsSpecified.Size);
Show();
tracking = true;
//Size = c.Size;
//Tracking = true;
}
public void MoveToMouse()
{
Location = new Point(Control.MousePosition.X + offsetX, Control.MousePosition.Y + offsetY);
}
//--
However, for some reason, it always start with its DefaultSize in location {100, 100}
How could this be?
How could I ensure it is at the desired location with the desired size?
On a final note, it's displayed in a MouseMoved event handler, maybe that has some side effect?
//--
public DragingForm()
{
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.ContainerControl, false);
SetStyle(ControlStyles.Selectable, false);
SetStyle(ControlStyles.StandardClick, false);
SetStyle(ControlStyles.StandardDoubleClick, false);
SetStyle(ControlStyles.UserMouse, false);
SetStyle(ControlStyles.SupportsTransparentBackColor, false);
SetStyle(ControlStyles.CacheText, false);
TopMost = true;
ShowInTaskbar = false;
FormBorderStyle = FormBorderStyle.None;
Opacity = 0.6;
Size = new Size(100, 20);
}
//--
When I want to display it I call the following:
//--
public void StartTracking(Control c)
{
TakeSnapshot(c, new Rectangle(0, 0, c.Width, c.Height));
CreateControl();
MoveToMouse();
SetBoundsCore(0, 0, c.Width, c.Height, BoundsSpecified.Size);
Show();
tracking = true;
//Size = c.Size;
//Tracking = true;
}
public void MoveToMouse()
{
Location = new Point(Control.MousePosition.X + offsetX, Control.MousePosition.Y + offsetY);
}
//--
However, for some reason, it always start with its DefaultSize in location {100, 100}
How could this be?
How could I ensure it is at the desired location with the desired size?
On a final note, it's displayed in a MouseMoved event handler, maybe that has some side effect?