Open Form Maximzed and ShowDialog with Task Bar?

P

Pieter

Hi,

I have some very specific needs, and I am not able to find a nice solution.
What I need is:
- when the user makes a choice in the Menu, the Form of his choice must
open, but:
- this Form must open Maximized
- and the user shouldn't be able to see the 'Main application' until he
closed this Form!

At first sight I tried it with MyNewForm.ShowDialog(Me).
The problem is that when MyNewForm.WindowState = Maximized, it opens before
the Task Bar! Which I don't want it to do!

I could open it WindowState = norma, and adjust it's Width en Height to the
screen-size, but that gives me another problem: When a Form is not
Maximized, the user can do a drag and drop with the Form, and replace it, so
a part of it won't be anymore on the Screen. This is behaviuo that I don't
want...

I know that my demands are maybe a little to demanding, but the problem is
that this application is for people who aren't mentally at the level we
would like them to have, so it needs to be really basic and exactly like
this so they can't get confused (which they do now :-( ).

Thanks a lot in advance,

Pieter
 
N

necroph

mhhh i am missing my first answer. Ok let's do it a second time ;)

Maybe you can explain what you mean with:

when MyNewForm.WindowState = Maximized, it opens before
the Task Bar! Which I don't want it to do!

I tried to understand that, but i cannot get it.
 
J

Jevon

This would be easier with a bit more code, but why not just Hide the current
form, and display the new one as per normal?

E.g.:
Me.Hide()
MyNewForm.WindowState = Maximized
MyNewForm.Show()

You will of course need to show the parent form (Me above) when MyNewForm is
closed.

Jevon
 
P

Pieter

Hehe ok I didn't explain it very good. what I meant was: If you open a Form
as ShowDialog, and it is maximzed, it will take the whole screen, also where
the Taskbar (the thing at the bottom of the screen with the Start-button
etc) is normally shown... A normal Form that is maximized will take the
whole screen, except the taskbar at the bottom of the screen.

So the summary:
MyNewForm.WindowState = Maximized
MyNewForm.ShowDialog(Me)
-> The height of MyNewform will be = Screen.Height

if you do instead:
MyNewForm.WindowState = Maximized
MyNewForm.Show
-> The height of MyNewform will be = Screen.Height -
TheHeightOfTheTaskbar :) -> it's this that I want :)
 
N

necroph

Hi Pieter,

can you just explain what you mean with: The problem is that when
MyNewForm.WindowState = Maximized, it opens before
the Task Bar!
I tried to understand that but i cannot get it.
 
N

necroph

I just had the same problem, when i wanted to write a screenSaver. The
property i was looking for is FormBorderStyle. Set it to 'none' and the
user has no chance to move it. Set TopMost = true and the user cannot
even use alt+tab to switch between applications. Of course you has to
create a 'Closebutton' (OnClick: me.close) because FormBorderStyle =
none hides the complete windowcontrolls and just shows your form.
Otherwise i have othrt little solutions in my mind like setting
policies in the reg.
 
A

Armin Zingler

Pieter said:
Hehe ok I didn't explain it very good. what I meant was: If you open
a Form as ShowDialog, and it is maximzed, it will take the whole
screen, also where the Taskbar (the thing at the bottom of the
screen with the Start-button etc) is normally shown... A normal Form
that is maximized will take the whole screen, except the taskbar at
the bottom of the screen.

So the summary:
MyNewForm.WindowState = Maximized
MyNewForm.ShowDialog(Me)
-> The height of MyNewform will be = Screen.Height

if you do instead:
MyNewForm.WindowState = Maximized
MyNewForm.Show
-> The height of MyNewform will be = Screen.Height -
TheHeightOfTheTaskbar :) -> it's this that I want :)


It's the "working area" you are looking for. :)

I can't repro this. If I show the form modally and maximized, it only covers
the working area, not the whole screen. This happens with or without passing
'Me' to ShowDialog. (both, Framework 1.1 and 2.0)


Armin
 
N

necroph

I recognized that i was wrong. But I tested:

MyNewForm.WindowState = Maximized
MyNewForm.Showdialog()

but the taskbar is normaly shown. The 'MyNewForm' is not hiding the
taskbar.
 
C

Cor Ligthert [MVP]

Pieter,

You know that it is hard not to write what I want to write.
I don't find it right in this case.

:)

Can you try those?
\\\
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2
frm.MaximizeBox = False
frm.WindowState = FormWindowState.Maximized
frm.ShowInTaskbar = False
frm.ShowDialog(Me)
End Sub
End Class
///

\\\
Public Class Form2
Protected Overrides ReadOnly _
Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ClassStyle = &H8
Return cp
End Get
End Property
End Class
///

'The last part with thanks to Mick Doherty, he made this for a non closing
window.

I hope this helps,

Cor
 
P

Pieter

See the answer of Armin Zingler: It doesn't show the Form in the workign
Area, but on the whole Screen :)
 
P

Pieter

Not too bad your solution, thanks! :)

And indeed It works like that, but I forgot to mention one thing:
MaximizeBox = False of the form, because user shouldn't be able to resize
it...
 

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