views:

78

answers:

2

Hi All,

I've been doing this for years. But now it's just not working.

private void Form1_Deactivate(object sender, EventArgs e)
        {
            this.Size = new Size(30, 29);
            txt.Visible = false;
            lbl.Visible = false;
        }

The form just does not change Width. But, as above, the 3 controls DO become invisible.

Any suggestions?

+5  A: 

Windows have an absolute minimum width of 134 pixels (at least on Windows 7)

To circumvent this minimum, you can set FormBorderStyle to FixedToolWindow or SizableToolWindow. (Or handle Windows messages)

SLaks
You've got to be kidding me. That is the stupidest thing I've heard. Great. Windows just keeps on getting better! NOT!
lucifer
But thanks for the answer. Will accept in 8mins.
lucifer
@j-t-s: If you want an extremely narrow form, you need to paint your own chrome. This is a feature, not a bug – such narrow forms are not user-friendly.
SLaks
Yeah, I wasn't suggesting it was a bug; merely pointing out how much I dislike the feature. I am usingFormBorderStyl.None; because I have my own "skin". But thank you, I will see what I can do. :)
lucifer
@j-t-s what do you want to do with a window 30px wide anyway? I'm sure theres a much better way of accomplishing whatever it is your trying...
Simon Fox
@Simon Fox; I have a "strip" (my app), which sits nicely just above the taskbar. Then when the user cliks outside of the form (hence the deactivate method), the width of the form is minimized to 30px, to avoid clutter on the desktop. The only thing visible when the form is 30px wide is a magnifying glass, and upon hovering over it, the form will then expand to its full size.
lucifer
A: 

First set the FormBorderStyle to SizableToolWindow then set your own value.

Johnny