General discussion

Locked

Question of VB

By darshan_makadia ·
i have developed a project in vb 6.0
it contains a one mdi form and other child forms.
on the mdi form there is a menu on which there is a button named new. on clicking on this new button a new child form is loaded. now, my question is can i getthe new child form which will be loading in the center of the screen and if yes how can i get it ?
pleaze help me with this question.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Question of VB

by Dushy_ant In reply to Question of VB

keep the startup position property of the form
as centerowner.

Collapse -

Question of VB

by darshan_makadia In reply to Question of VB

The question was auto-closed by TechRepublic

Collapse -

Question of VB

by sl-campbell In reply to Question of VB

Answer #1 is correct.

However,you can also add the below into the Form_Load event (Go to the Code window and select in the left DropDown box "Form" and in the right DropDown box "Load):

Me.Move (MDI.ScaleWidth - Me.Width)\2, (MDI.ScaleHeight -Me.Height)\2

Note: change MDI to the name of the parent MDI form.

Aside from that, you can have the form open to the maximum size by adding the folowing code to that same event:

Me.Move 0, 0, MDI.ScaleWidth, MDI.ScaleHeight

You would NOTdo both of the above - just one or the other.

Using the properties window as mentioned in answer #1 is good as a default.
But, I prefer doing it in code, and not just in the form load event, but creating a sub proccedure that positions all of myforms the way that I want. This sub always gets called when the form is loaded in case I forget to set the properties in the property window or make some other mistake.
Also, a sub like this gives you the ability of creating a persistent condition - If the user prefers to have the child window in a certain size and position, you can save the settings to the registry and, when the form is loaded again the form is positioned and sized to settings that the user last used.

If you are interestedin the code for this, post a comment to your QUESTION and I will post as a comment to my answer the needed code.

Collapse -

Question of VB

by darshan_makadia In reply to Question of VB

The question was auto-closed by TechRepublic

Collapse -

Question of VB

by darshan_makadia In reply to Question of VB

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums