I have a user control that pops up much like intelisense in visual studio to
display a range of navigable options when a key combo is pressed within a
textbox. I have called the user control within the parent form and
programmatically called it using the following code within the parent form.
MyUserControl control1 = new MyUserControl;
control1.BorderStyle = BorderStyle.FixedSingle;
this.Controls.Add(control1);
control1.Focus();
control1.BringToFront();
control1.Show();
How do I go about making my new popup control resizeable?
the only options I have under BorderStyle is FixedSingle and Fixed3D.
thanks
skoya
Hi,
What is the base class for your control? It seems not to be UserControl However this is not important because control's doesn't support sizable Form2 f2 = new Form2(); The key here is setting f2.TopLevel to *false*. When do that the form The problem here is with the 3D look of the form. This cannot be controlled Next solution that came up in my mind is to override CreateParams property So the solution is to use thin (non resizable) border and process the The following is sample control that inherits from panel and can be resized. class SizablePanel: Panel private const int WM_NCHITTEST = 0x0084; public SizablePanel() protected override void WndProc(ref Message m) if(m.Msg == WM_NCHITTEST) } } } What is the base class for your control? It seems not to be UserControl However this is not important because control's doesn't support sizable Form2 f2 = new Form2(); The key here is setting f2.TopLevel to *false*. When do that the form The problem here is with the 3D look of the form. This cannot be controlled Next solution that came up in my mind is to override CreateParams property So the solution is to use thin (non resizable) border and process the The following is sample control that inherits from panel and can be resized. class SizablePanel: Panel private const int WM_NCHITTEST = 0x0084; public SizablePanel() protected override void WndProc(ref Message m) if(m.Msg == WM_NCHITTEST) } } } HTH Stoitcho Goutsev (100) [C# MVP]
> Hi,
> I have a user control that pops up much like intelisense in visual studio > MyUserControl control1 = new MyUserControl; > How do I go about making my new popup control resizeable? > the only options I have under BorderStyle is FixedSingle and Fixed3D. > thanks
- Hide quoted text -
|
Thats superb it turns out that I only need HTRIGHTBOTTOM for now...
Also the code works with UserControl class also not just Panel. thanks a lot for your help. private const int WM_NCHITTEST = 0x0084; private const int HTBOTTOM = 15; private const int HTBOTTOMRIGHT = 17; private const int HTRIGHT = 11; protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == WM_NCHITTEST) { Point pos = new Point((int)m.LParam); pos = this.PointToClient(pos); //if (pos.Y > this.Height - 10) // m.Result = new IntPtr(HTBOTTOM); if (pos.X > this.Width - 10 && pos.Y > this.Height - 10) { m.Result = new IntPtr(HTBOTTOMRIGHT); return;
}
// if (pos.X > this.Width - 10)
// m.Result = new IntPtr(HTRIGHT);
}
"Stoitcho Goutsev (100) [
C# MVP]" <1
...@100.com> wrote in message
} news:epC1sjT8FHA.1248@TK2MSFTNGP14.phx.gbl...
> Hi,
> What is the base class for your control? It seems not to be UserControl > However this is not important because control's doesn't support sizable > Form2 f2 = new Form2(); > The key here is setting f2.TopLevel to *false*. When do that the form > The problem here is with the 3D look of the form. This cannot be > Next solution that came up in my mind is to override CreateParams property > So the solution is to use thin (non resizable) border and process the > The following is sample control that inherits from panel and can be > class SizablePanel: Panel > private const int WM_NCHITTEST = 0x0084; > public SizablePanel() > protected override void WndProc(ref Message m) > if(m.Msg == WM_NCHITTEST) > } > } > } > What is the base class for your control? It seems not to be UserControl > However this is not important because control's doesn't support sizable > Form2 f2 = new Form2(); > The key here is setting f2.TopLevel to *false*. When do that the form > The problem here is with the 3D look of the form. This cannot be > Next solution that came up in my mind is to override CreateParams property > So the solution is to use thin (non resizable) border and process the > The following is sample control that inherits from panel and can be > class SizablePanel: Panel > private const int WM_NCHITTEST = 0x0084; > public SizablePanel() > protected override void WndProc(ref Message m) > if(m.Msg == WM_NCHITTEST) > } > } > } > HTH > Stoitcho Goutsev (100) [C# MVP] >> I have a user control that pops up much like intelisense in visual studio >> MyUserControl control1 = new MyUserControl; >> How do I go about making my new popup control resizeable? >> the only options I have under BorderStyle is FixedSingle and Fixed3D. >> thanks
- Hide quoted text -
|
It is going to work with any control because it exploits windows message
that is common for all windows. I just used a panel because it has this BorderStyle property. I don't see the UserControl to expose such a property. Nevertheless, border can be added (theoretically) to any control via overriding CreateParams property. -- |