How do I mimic MSN Live Messenger Form Style  
Author Message
Ancalagon





PostPosted: Visual C# Express Edition, How do I mimic MSN Live Messenger Form Style Top

Hi, anyone does know jhow can I mimic the MSN Live Messenger Form style. Specifically, I want to make applications without menubar but I want to be able to move them (like MSN when you "Hide the Menu Bar") I know that I can use Form Border = none But if by doing so I am unable to move the forma and I want to do that. I can add my own Minimize, Maximize and close Buttons but I can't move my form through the screen

I do not care much about the look and feel, what I really want to do is hde the menubar like in the image below and be able to move the window.

If you can't see the image (I culdn't) then here it is: http://www.hide-link.com/


Visual Studio Express Editions20  
 
 
Paul Domag





PostPosted: Visual C# Express Edition, How do I mimic MSN Live Messenger Form Style Top

Hi,

You'll need to use several API's to achieve this:

//API functions to move the form
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

And in your mouse down event of the form:

public void Form1_MouseDown(object sender, MouseEventArgs e)
{
//If the left mouse is pressed, release form for movement
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}

cheers,

Paul June A. Domag



 
 
wizkid1





PostPosted: Visual C# Express Edition, How do I mimic MSN Live Messenger Form Style Top

Here is some simple code you can use that I figured out!

protected override void WndProc(ref Message m)
{
base.WndProc(ref m);

int WM_NCHITTEST = 0x84;
if (m.Msg == WM_NCHITTEST)
{
int HTCLIENT = 1;
int HTCAPTION = 2;
if (m.Result.ToInt32() == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
}
}