About maximizing the forms into the task bar.

R

Ravindra

Hi all,
I am doing an desktop application in vb.net. For forms i have used the
property formborderstyle=none. So what happens when i minimize the form into
the task bar,and again right click on the form i could not the maximize or
minimize or restore. So please let me know how to do this.
 
M

Michael Hofer

Hi all,
I am doing an desktop application in vb.net. For forms i have used the
property formborderstyle=none. So what happens when i minimize the form into
the task bar,and again right click on the form i could not the maximize or
minimize or restore. So please let me know how to do this.

Your post leaves out a few details that might make it easier to help with
your problem:

- What language are your writing in?
- What version of .NET are targeting?

Based on what I've read, however, I'm going to assume, just to get you a
working answer, that you're doing VB.NET and targeting .NET 2.0.

There's a relatively straightforward "trick" to accomplish what you want to
do. Basically, the problem is that Windows doesn't display those commands
because the form doesn't have a border, because it doesn't think the window
is resizable. So you essentially need to tell Windows that the form *is*
resizable; but you only need to do so while it's minimized.

Here's one way to do it:

Protected Sub Form_ResizeBegin(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles Form.ResizeBegin

If WindowState = FormWindowState.Maximized Then
' We're about to minimize
FormBorderStyle = FormBorderStyle.Resizable
Else
' We're about to maximize or restore
FormBorderStyle = FormBorderStyle.None
End If

End Sub

(Please forgive any syntax errors. I'm typing this on my Mac, since my PC is
in the shop; I don't have the benefit of Visual Studio to develop a working
sample for you.)

Anyway, this should do the trick. Essentially, you're restoring the context
menu commands long enough for them to be present while the form appears in
the task bar, but not while it's spread across the screen.

If you're not coding this in .NET 2.0, you could put theoretically put the
same code in the Resize event handler for your form. (The Form_ResizeBegin
event is new to .NET 2.0, and you won't find it in .NET 1.0 or .NET 1.1.)

Please let me know how this works out for you, or if it's even close to
solving your problem. If it's not, I'd love to help you find a solution that
works for you.

Regards,

Michael A. Hofer
The Essential Geek: http://mikehofer.spaces.live.com
 
P

Purushotham

hai all,
i have tried with this code,if i want to set formBorderstyle to none when the window is maximized.it is not working for that part can u get me solution please..

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top