Centering child form in mdi window 
Author Message
 Centering child form in mdi window

Hi There,

If this is in the wrong group, please inform me and I will
repost to the corrct one.

I am developing a simple MDI app in VB6, and have a splash
screen that loads on start of the application.  I am
trying to set the position to be centreowner, but whenever
I try to change the property from Normal - I get a message
stating "invalid property value".

Any advice on what I'm doing wrong (i am an amateur I'm
afraid to admit!!) will be gratefully received!!

TYIA



Sat, 12 Feb 2005 22:35:35 GMT  
 Centering child form in mdi window
Child forms can be set to Manual only (as you've found)... but, since it's a
"splash screen", there's really no reason to make it an MDI child. If you
set MDIChild = False, you can use the other startup positions.

Here's a simple test.. I just added a new form and renamed it to
frmSplash... it worked with both Center Owner and Center Screen (preferred)
'===========
Private Sub MDIForm_Load()
   Dim t As Single

   frmSplash.Show vbModeless, Me

   t = Timer + 2 '2 sec
   Do While Timer < t
      DoEvents
   Loop

   Unload frmSplash
   Set frmSplash = Nothing
End Sub
'===========

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com - http://www.vbsight.com/MultiColumn.htm
New Tabbed Dialog http://www.vbsight.com/TBGDialogCTL.htm


Quote:
> Hi There,

> If this is in the wrong group, please inform me and I will
> repost to the corrct one.

> I am developing a simple MDI app in VB6, and have a splash
> screen that loads on start of the application.  I am
> trying to set the position to be centreowner, but whenever
> I try to change the property from Normal - I get a message
> stating "invalid property value".

> Any advice on what I'm doing wrong (i am an amateur I'm
> afraid to admit!!) will be gratefully received!!

> TYIA



Sat, 12 Feb 2005 23:08:39 GMT  
 Centering child form in mdi window
Heres some code to center a MDI child form;

Public Sub Centerchild(Parent As Form, Child As Form)

'Type: Public Sub
'Name: CenterChild
'Purpose: Center a child form within an MDI form
'Limitations: none
'Author: Veign
'Arguments: Parent is the MDI parent form, Child is the child form to center
'Return Value:
'Useage: Centerchild(myMDIForm, myChildForm)
'Notes:

Dim iTop As Integer
Dim iLeft As Integer

If Parent.WindowState = vbMinimized Then Exit Sub
    iTop = ((Parent.ScaleHeight - Child.Height) \ 2)
    iLeft = ((Parent.ScaleWidth - Child.Width) \ 2)
    Child.Move iLeft, iTop

End Sub

What Ken said is true, since its a splash screen theres no need for making
it a child form but I posted the code anyway...

--
Veign
www.veign.com
NEW ActiveX Control - Jeweled Style Buttons
www.veign.com/download_activex.html#jwldbutn
Code Samples & Sample Projects
http://www.veign.com/information/application/info_app.html
Submit Your Best Code (you keep the rights)
http://www.veign.com/information/application/code_submit.html
---------

Quote:
> Hi There,

> If this is in the wrong group, please inform me and I will
> repost to the corrct one.

> I am developing a simple MDI app in VB6, and have a splash
> screen that loads on start of the application.  I am
> trying to set the position to be centreowner, but whenever
> I try to change the property from Normal - I get a message
> stating "invalid property value".

> Any advice on what I'm doing wrong (i am an amateur I'm
> afraid to admit!!) will be gratefully received!!

> TYIA



Sat, 12 Feb 2005 23:27:35 GMT  
 Centering child form in mdi window


Quote:
>Hi There,

>If this is in the wrong group, please inform me and I will
>repost to the corrct one.

>I am developing a simple MDI app in VB6, and have a splash
>screen that loads on start of the application.  I am
>trying to set the position to be centreowner, but whenever
>I try to change the property from Normal - I get a message
>stating "invalid property value".

>Any advice on what I'm doing wrong (i am an amateur I'm
>afraid to admit!!) will be gratefully received!!

>TYIA

The easiest way is to make the splash form a top level window owned by
the MDI parent.  You can then just center the form over the MDI parent
using the following....

  With frmMDIParent
    Move .Left + ((.Width \ 2) - (frmSplash.Width \ 2)), .Top +
((.Height \ 2) - (frmSplash.Height \ 2))
  End With

To make the splash form owned by the MDI parent, see the description
of the second param to the Show statement in your VB help file.

HTH,
Bryan
____________________________________________________________
New Vision Software            "When the going gets weird,"
Bryan Stafford                   "the weird turn pro."

Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas



Sat, 12 Feb 2005 23:33:14 GMT  
 Centering child form in mdi window

released on Tue, 27 Aug 2002 07:35:35 -0700 bearing the
following fruit:

Quote:
>Hi There,

>If this is in the wrong group, please inform me and I will
>repost to the corrct one.

>I am developing a simple MDI app in VB6, and have a splash
>screen that loads on start of the application.  I am
>trying to set the position to be centreowner, but whenever
>I try to change the property from Normal - I get a message
>stating "invalid property value".

From the help file

StartUpPosition Property

Returns or sets a value specifying the position of an object
when it first appears. Not available at run time.

Quote:
>Any advice on what I'm doing wrong (i am an amateur I'm
>afraid to admit!!) will be gratefully received!!

Since a splash screen is usually displayed before any other
forms then it seems strange that it would be centered based
on a form. Seems to me it should be centered in relation to
the screen.

I do all me centering in code and never ever use
StartUpPosition.

J

--

On the door of a music library: Bach in a minuet.  (Syman Hirsch)



Sat, 12 Feb 2005 23:02:48 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Centering a child form in an MDI Window

2. Center an MDI Child in MDI form

3. Q: Form activate Fires On Non Child MDI Forms But Only Once On Child Mdi Forms

4. MDI Child Form Centering

5. Centering MDI Child Form

6. center a child form in a MDI

7. Centering child form in MDI

8. Q: Centering an MDI Child Form

9. Center MDI Child Form

10. How to center the MDI Child form when it is loaded

11. Newbie Question - Center MDI child form

12. How to center MDI child form

 

 
Powered by phpBB® Forum Software