How do I make a Windows Form with a height of less than 34 pixels?

G

Guest

I have the following code as part of a method of producing in-line tooltips.
It appears to work except that the form with the tooltip can never be less
than 34 pixels high or 124 wide. Not the 15 or so pixels pixels high that I
want it to be.

Please can someone tell me how to shrink my over-sized window.

TIA.

....
....
....
private class ToolTipWindow : System.Windows.Forms.Form
{
private string _tip = String.Empty;
private Rectangle _screenRectangle;

public ToolTipWindow(Rectangle screenRectangle, string tip, Font
font)
{
_tip = tip;
_screenRectangle = screenRectangle;

Size s = TextRenderer.MeasureText(tip, font);

Font = font;
FormBorderStyle = FormBorderStyle.FixedSingle;
ControlBox = false;
MinimizeBox = false;
MaximizeBox = false;
this.MinimumSize = new Size(1, 1);
this.StartPosition = FormStartPosition.Manual;
Location = screenRectangle.Location;
this.Size = new Size(s.Width +2, s.Height + 2);
}

protected override CreateParams CreateParams
{
get
{
const int CS_DROPSHADOW = 0x00020000;
CreateParams cp = base.CreateParams;
cp.ClassStyle |= CS_DROPSHADOW;
return cp;
}
}
....
....
....
 
M

Morten Wennevik [C# MVP]

Hi,

If you remove the border (FormBorderStyle.None) you should be able to shrink it further.
Of course, you would then have to draw borders and headers yourself.
Note. There may be limitations if you put controls onto the form, in which case you may have to custom draw that content as well.
 
G

Guest

Thank you very much, Morten.

I changed this:
FormBorderStyle = FormBorderStyle.FixedSingle;
to this:
FormBorderStyle = FormBorderStyle.None;

and it suddenly shrank from 34 pixels high to 15 pixels high. Also, (less
importantly to me) it fixed the width too.

I am very grateful.

Alan
 
Top