How do I center child form in mdi form?

Posted on 1998-07-16
Last Modified: 2008-02-01
hi, I am trying to center mdi child form in the mdi parent form.
I had a centerform function written already, what events should I call from?
Right now I called the function from mousemove event. So every time I resize the form, I have to move the mouse on the form to center the form in mdi main form. Otherwise it will stay un-centered. I tried to call it from form_resize event, but It does not center the form when I move the border of the form. And there is no event called after_resize :(

So what should I do to call centerform function after I resize the form?

Thank you very much and have a nice day!

Question by:ny971181
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 1466013
frmChild.Move (mdiParent.ScaleWidth - frmChild.Width) / 2, (mdiParent.ScaleHeight - frmChild.Height) / 2


Expert Comment

ID: 1466014
Looks like this function goes in the MDIform_Resize with out any problems, I would move it out of the mousemove event if I were you.


Expert Comment

ID: 1466015
Ummm, why didn't ClifABBS code work?

Expert Comment

ID: 1466016
I'm guilty of one of my own pet peeves, people who don't read the question thoroughly!

ny971181 already had the centering code, s/he just wanted to know where to put it, which you did comment, and should answer.

Accepted Solution

wford earned 50 total points
ID: 1466017
ok well, I'll answer, but ny971181 said that the centre function was in the form resize event and didn't work, but i tryed it and it seemed to go quiet hapily, so ny971181 did it work?

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month7 days, 6 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question