PDA

View Full Version : Move a borderless Form



Chris
05-15-2008, 03:36 PM
lol i like border less forms better sometimes and i was bored
im still learning Csharp also.



public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

public Form1()
{
InitializeComponent();
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
}





void Form1_MouseMove(object sender, MouseEventArgs e)
{


ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);


}

virus7799
05-15-2008, 03:46 PM
lol i like border less forms better sometimes and i was bored
im still learning Csharp also.



public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

public Form1()
{
InitializeComponent();
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
}





void Form1_MouseMove(object sender, MouseEventArgs e)
{

if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);

}
}


How would I make a movable Menu in D3D? Any ideas would help.

Chris
05-15-2008, 03:51 PM
yea its really not that hard
this is off my head so change it a bit to make it work right.



POINT Cursor;
GetCursorPos(&Cursor);

if (GetAsyncKeyState(VK_LBUTTON) && Cursor.x >= Menu[1].x && Cursor.x <= Menu[1].x + Menu[1].w && Cursor.y >= Menu[1].y && Cursor.y <= Menu[1].y + Menu[1].h)
{
Menu[1].x = Cursor.x;
Menu[1].y = Cursor.y;
}



checks if it anywher ein the menu and when u click left mouse it moves it just edit it to work better