Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Align Center

Question posted by: pentahari (Member) on May 15th, 2008 10:47 AM
How to open the MDI Parent form in center to the MDI form.
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
jamesd0142's Avatar
jamesd0142
Needs Regular Fix
469 Posts
May 15th, 2008
12:28 PM
#2

Re: Align Center
In your version is there a property called:

"StartPossition" on the form?

if so choose centerparent

Reply
pentahari's Avatar
pentahari
Member
58 Posts
May 15th, 2008
02:45 PM
#3

Re: Align Center
Quote:
Originally Posted by jamesd0142
In your version is there a property called:

"StartPossition" on the form?

if so choose centerparent


I am using Visual basic 6.0

Reply
shuvo2k6's Avatar
shuvo2k6
Member
68 Posts
May 15th, 2008
03:05 PM
#4

Re: Align Center
Quote:
Originally Posted by pentahari
How to open the MDI Parent form in center to the MDI form.


u can try by changing this Property

"StartUpPosition"

i am not sure. OK, try.

Reply
pentahari's Avatar
pentahari
Member
58 Posts
May 15th, 2008
03:45 PM
#5

Re: Align Center
Quote:
Originally Posted by shuvo2k6
u can try by changing this Property

"StartUpPosition"

i am not sure. OK, try.


When I try to Change MDI Child Form's StartUpPosition Property to 1-Center Owner (or) 2-Center Screen (or) 3-Windows Default then "Invalid Property Value" Error Msg appear.

Thanks Advance

Reply
jamesd0142's Avatar
jamesd0142
Needs Regular Fix
469 Posts
May 15th, 2008
03:48 PM
#6

Re: Align Center
Im not sure in vb6, but why not make your own Code?

try somthing like

MDIChildForm.Top = mdiparent.Height - mdiparent.Height / 2
MDIChildForm.Left = mdiparent.Width - mdiparent.Width / 2

you can see where its goin..?

Also in case they are different in vb6;

Top = the position of the top of the mdi child form in the mdi parent form
Left = the position of the left of the mdi child form in the mdi parent form

Reply
shuvo2k6's Avatar
shuvo2k6
Member
68 Posts
May 15th, 2008
05:20 PM
#7

Re: Align Center
Quote:
Originally Posted by pentahari
When I try to Change MDI Child Form's StartUpPosition Property to 1-Center Owner (or) 2-Center Screen (or) 3-Windows Default then "Invalid Property Value" Error Msg appear.

Thanks Advance


chld.Top = (MDIForm.Height - chld.Height) / 2
chld.Left = (MDIForm.Width - chld.Width) / 2

Reply
pentahari's Avatar
pentahari
Member
58 Posts
May 16th, 2008
04:08 AM
#8

Re: Align Center
Quote:
Originally Posted by shuvo2k6
chld.Top = (MDIForm.Height - chld.Height) / 2
chld.Left = (MDIForm.Width - chld.Width) / 2


Its not working correctly.

Reply
pentahari's Avatar
pentahari
Member
58 Posts
May 16th, 2008
06:02 AM
#9

Re: Align Center
Private Sub mnulogin_Click()
CenterChild Mainform, Login
End Sub

Sub CenterChild(Parent As Form, Child As Form)
On Error Resume Next
Dim iTop As Integer
Dim iLeft As Integer

iTop =(Parent.Height - Child.Height) / 2)
iLeft = (Parent.Width - Child.Width) / 2)
Child.Move iLeft, iTop
End Sub


I find the Correct Coding for this question.

My mistake is don't insert Form.Move function

Reply
shuvo2k6's Avatar
shuvo2k6
Member
68 Posts
May 16th, 2008
04:16 PM
#10

Re: Align Center
Quote:
Originally Posted by pentahari
Private Sub mnulogin_Click()
CenterChild Mainform, Login
End Sub

Sub CenterChild(Parent As Form, Child As Form)
On Error Resume Next
Dim iTop As Integer
Dim iLeft As Integer

iTop =(Parent.Height - Child.Height) / 2)
iLeft = (Parent.Width - Child.Width) / 2)
Child.Move iLeft, iTop
End Sub


I find the Correct Coding for this question.

My mistake is don't insert Form.Move function


I cann't understand what is difference between This code and ur code:

Code: ( text )
  1. Private Sub Command1_Click()
  2. Load Child
  3. Child.Top = (Parent.Height - Child.Height) / 2
  4. Child.Left = (Parent.Width - Child.Width) / 2
  5. Child.Show
  6. End Sub


Thnx, good luck.

Reply
pentahari's Avatar
pentahari
Member
58 Posts
May 16th, 2008
05:04 PM
#11

Re: Align Center
Quote:
Originally Posted by shuvo2k6
I cann't understand what is difference between This code and ur code:

Code: ( text )
  1. Private Sub Command1_Click()
  2. Load Child
  3. Child.Top = (Parent.Height - Child.Height) / 2
  4. Child.Left = (Parent.Width - Child.Width) / 2
  5. Child.Show
  6. End Sub


Thnx, good luck.


Sorry i have the mistake, your code is very correctly and clearly.

Thank you very much for your reply.

Please give the reply for me. I am waiting for your reply.

Reply
shuvo2k6's Avatar
shuvo2k6
Member
68 Posts
May 17th, 2008
11:59 AM
#12

Re: Align Center
Quote:
Originally Posted by pentahari
Sorry i have the mistake, your code is very correctly and clearly.

Thank you very much for your reply.

Please give the reply for me. I am waiting for your reply.


Thnkx friend, Go ahead.........

Reply
Reply
Not the answer you were looking for? Post your question . . .
183,968 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Visual Basic Forum Contributors