By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Align Center

pentahari
P: 60
How to open the MDI Parent form in center to the MDI form.
May 15 '08 #1
Share this Question
Share on Google+
11 Replies


jamesd0142
100+
P: 469
In your version is there a property called:

"StartPossition" on the form?

if so choose centerparent
May 15 '08 #2

pentahari
P: 60
In your version is there a property called:

"StartPossition" on the form?

if so choose centerparent
I am using Visual basic 6.0
May 15 '08 #3

P: 68
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.
May 15 '08 #4

pentahari
P: 60
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
May 15 '08 #5

jamesd0142
100+
P: 469
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
May 15 '08 #6

P: 68
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
May 15 '08 #7

pentahari
P: 60
chld.Top = (MDIForm.Height - chld.Height) / 2
chld.Left = (MDIForm.Width - chld.Width) / 2
Its not working correctly.
May 16 '08 #8

pentahari
P: 60
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
May 16 '08 #9

P: 68
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:

Expand|Select|Wrap|Line Numbers
  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
  7.  
Thnx, good luck.
May 16 '08 #10

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

Expand|Select|Wrap|Line Numbers
  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
  7.  
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.
May 16 '08 #11

P: 68
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.........
May 17 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.