Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
F5F5F5 - 24 Oct 2007 15:02 GMT
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;
               }
           }
...
...
...
Morten Wennevik [C# MVP] - 24 Oct 2007 15:30 GMT
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.

Signature

Happy coding!
Morten Wennevik [C# MVP]

F5F5F5 - 24 Oct 2007 15:48 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.