Windows Develop Bookmark and Share   
 index > Windows Forms General > pannel
 

pannel

hi,

i want to modify my form what i want is in my application there shold be a pannel at left side and tree view shold be in side of that and i can move the pannel when i want

thanks

elby
  • Moved byeryangMSFTWednesday, September 23, 2009 2:26 AM (From:.NET Base Class Library)
  •  
Elby Paul  Tuesday, September 22, 2009 5:59 AM
Hello Elby,

The following code can let you move control smoothly in run time. Please take a look.
public partial class Form1 : Form
{
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.panel1.MouseDown += new MouseEventHandler(panel1_MouseDown);
}

void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(this.panel1.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}
}
The example shows how to call win32 api “SendMessage�and “ReleaseCapture�to move the panel1 control. If you have anything unclear, please feel free to tell me.

Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Wednesday, September 23, 2009 8:07 AM
Elby,

there is no build-in mechanism for moving contols on forms. you need to do this yourself, possibly with handling mouse-down/up/move messages (events).

WM_HOPETHISHELPS
-thomas woelfer
http://www.die.de/blog
thomas_woelfer  Tuesday, September 22, 2009 9:07 AM
Hello Elby,

The following code can let you move control smoothly in run time. Please take a look.
public partial class Form1 : Form
{
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.panel1.MouseDown += new MouseEventHandler(panel1_MouseDown);
}

void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(this.panel1.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}
}
The example shows how to call win32 api “SendMessage�and “ReleaseCapture�to move the panel1 control. If you have anything unclear, please feel free to tell me.

Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Wednesday, September 23, 2009 8:07 AM

You can use google to search for other answers

Custom Search

More Threads

• Keyboard cues problem
• is there a richtextbox which behaves likes textarea control in html
• Calendar Control 11.0 and adding control to a date?
• Is there any event associated with sorting in Datagrid
• Adding Dictionary type list to CheckedListBox
• Dumb Question - Clearing Form.Icon
• I want to access data from another Computer through internate.
• Need Help about user control
• Send a PAGEDOWN message to DataGrid (.NET 1.1) using a PageDown Key, but DataGrid does not have input focus.
• New to .NET and UIP Application Block