Discussion:
Height of Taskbar
(too old to reply)
knut Peters
2006-02-20 13:42:08 UTC
Permalink
Hallo NG!
I try to center a Child - from within a MDIForm, using the following code:
GetWorkArea nLeft, nTop, nWidth, nHeight

pLeft = (nWidth - 9450) \ 2

pTop = (nHeight - 7005) \ 2

However, this fails in Windows XP if the Taskbar is visible. So I should
like to adjust the top - position of the Childform by deducting the height
of the taskbar from the area on the top between the MDIForm and the
Childform

Which Api does this job?

Or do you know any alternative to solve the problem?



Thanks in advance,

Knut
Rick Rothstein [MVP - Visual Basic]
2006-02-20 17:55:32 UTC
Permalink
Post by knut Peters
GetWorkArea nLeft, nTop, nWidth, nHeight
pLeft = (nWidth - 9450) \ 2
pTop = (nHeight - 7005) \ 2
However, this fails in Windows XP if the Taskbar is visible. So I should
like to adjust the top - position of the Childform by deducting the height
of the taskbar from the area on the top between the MDIForm and the
Childform
I'm confused. First off, what does 9450 and 7005 refer to? Next, where do
you want the Child centered at? On the MDIForm or the Screen? If the Screen,
why??? If the MDIForm, why does the Windows XP Taskbar cause you any
problem? Or did you mean the TitleBar/MenuBar area of the MDIForm when you
said TaskBar? Can you clarify this for us?

Rick
knut Peters
2006-02-21 08:56:02 UTC
Permalink
Thanks for the reply!
Starting the program a MDI-Form fills the screen.
The programm consists of different applications, which might use forms of
different size. One application uses child forms (9450 x 7005), however
other applications are external programs (*.exe) and called only when
required.
All forms should by shown in a central position within the MDI - Form. Of
course it would be possible to show the same directly on the screen.
However, a unique appearance of the complete package is preferred.

After the receipt of your reply I checked again the program. Please
apologize. You are correct not the Taskbar is the culprit but the titlebar /
menuebar, because the MDI-Form menuebar shows the commands of the subforms.

Do you have any proposal to solve the problem?
Thanks in advance and regards
Knut
Post by Rick Rothstein [MVP - Visual Basic]
I'm confused. First off, what does 9450 and 7005 refer to? Next, where do
you want the Child centered at? On the MDIForm or the Screen? If the Screen,
why??? If the MDIForm, why does the Windows XP Taskbar cause you any
problem? Or did you mean the TitleBar/MenuBar area of the MDIForm when you
said TaskBar? Can you clarify this for us?
Rick
Ken Halter
2006-02-21 17:40:18 UTC
Permalink
Post by knut Peters
Thanks for the reply!
Starting the program a MDI-Form fills the screen.
The programm consists of different applications, which might use forms of
different size. One application uses child forms (9450 x 7005), however
Butting into the thread, mid-way, one suggestion... get rid of those numbers
that are hard-coded in twips. If a user has their system fonts set to
anything other than "Small", you'll have to rework the form. Small fonts
give 15 twips per pixel, Large gives 12 twips per pixel, Custom gives ???
twips per pixel. Your controls will start dropping off the lower right side
of the screen if you're not careful.
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
Rick Rothstein [MVP - Visual Basic]
2006-02-21 18:07:56 UTC
Permalink
Post by knut Peters
Starting the program a MDI-Form fills the screen.
The programm consists of different applications, which might use forms of
different size. One application uses child forms (9450 x 7005), however
other applications are external programs (*.exe) and called only when
required.
All forms should by shown in a central position within the MDI - Form. Of
course it would be possible to show the same directly on the screen.
However, a unique appearance of the complete package is preferred.
After the receipt of your reply I checked again the program. Please
apologize. You are correct not the Taskbar is the culprit but the titlebar /
menuebar, because the MDI-Form menuebar shows the commands of the subforms.
Do you have any proposal to solve the problem?
I'm not sure of the top of my head what to tell you for the external
programs, but you can center any CHILD form within the MDIForm by putting
this code in the CHILD form's Form_Load event...

Me.Move (MDIForm1.ScaleWidth - Me.Width) / 2, _
(MDIForm1.ScaleHeight - Me.Height) / 2

You should be able to center any non-CHILD windows within your same project
using this code in the form's Form_Load event (provided the MDIForm is
already displayed)...

Dim Border As Long
Dim MenuHeight As Long
With MDIForm1
Border = (.Width - .ScaleWidth) / 2
MenuHeight = .Height - .ScaleHeight - Border
Me.Move .Left + Border + (.ScaleWidth - Me.Width) / 2, _
.Top + MenuHeight + (.ScaleHeight - Me.Height) / 2
End With

Rick
Rick Rothstein [MVP - Visual Basic]
2006-02-21 18:19:02 UTC
Permalink
Post by Rick Rothstein [MVP - Visual Basic]
Dim MenuHeight As Long
Misleading variable name.. perhaps TitleBarMenuHeight would have been
better.

Rick
Michael C
2006-02-21 00:16:36 UTC
Permalink
Post by knut Peters
Hallo NG!
GetWorkArea nLeft, nTop, nWidth, nHeight
pLeft = (nWidth - 9450) \ 2
pTop = (nHeight - 7005) \ 2
However, this fails in Windows XP if the Taskbar is visible. So I should
like to adjust the top - position of the Childform by deducting the height
of the taskbar from the area on the top between the MDIForm and the
Childform
Which Api does this job?
Or do you know any alternative to solve the problem?
Why not just use the ScaleWidth and Height of the mdi form?

BTW, it looks like you're hard coding the size of the form above. This is
bad practice, you should use Form.Width and Height.

Michael
knut Peters
2006-02-22 07:52:18 UTC
Permalink
Thanks to all of you, in particular to you Rick!
Now I have a starting point for dwelling deeper into the problems related to
the use of forms.

There is one more point which I do not really understand:

The design of the form is stipulated in its load event.
Me.Width = 123
Me.Height = 123...

The form is shown by Me.Show
and disappears with its visible = False

The design of the form stays in the memory until it is unloaded. So, when is
the Active-Form event used?

When a form is unloaded is it really neccessary to set the form = nothing?

Regards
Knut

Loading...