Solved

Form refuses to center

Posted on 2002-06-22
9
216 Views
Last Modified: 2010-05-02
We have large program with at least 30 forms that except one display properly in the center of the screen when asked.  This one, and only one (naturally one most used) is errant.  It always jumps up to the top of the screen.  Most annoying.  Have tried all manner of options in properties, nothing seems to work.  There must be something different in this one, but can't find any difference between this and others. It works OK when maximized.  

Thanks in advance?
0
Comment
Question by:forrestx
[X]
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
9 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7100923
I assume that you have the StartUpPosition property of the "errant" for set to 2-CenterScreen ?

Is ther any code in the Form_Load event that would change the StartUp position?

Arthur Wood

0
 
LVL 38

Accepted Solution

by:
PaulHews earned 100 total points
ID: 7101041
If as arthur suggests the Startup Position property is set to Center Screen, then it is being changed in the code somewhere...

Do a search in the entire project code for:

<name of form>.Move
and
<name of form>.Top

Also look in the form code for:
Me.Move
Me.Top


This might find where it is being moved.  If that doesn't find it (it might be referenced by a different variable) Go to the debug menu, add a watch, for expression, enter <name of form>.Top and check the option that says break when value changes.  Change the procedure to (All Procedures) and change the module to (All Modules). Then run your program and it will break whenever the value changes.
0
 

Expert Comment

by:dhammond-ku
ID: 7101407
Hi forrestx,

Here is code that you should work to center the form on the screen, no matter what is happening with the CenterScreen property. You could either put it in the Form_Load procedure, or after the code in which the form is loaded:

FormName.Left = (Screen.Width - FormName.Width) / 2
FormName.Top = (Screen.Height - FormName.Height) / 2
FormName.Show

Hope that helps...

Danny Hammond
hammond@ku.edu
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 38

Expert Comment

by:PaulHews
ID: 7101606
dhammond-ku, I notice you are new here.

The etiquette in this topic area (as in most topic areas here at EE is to comment rather than answer.

Also, if there is code in Form_Resize that sets the top and left properties of the form, your code is going to be as useless as the StartUpPosition property.
0
 

Expert Comment

by:dhammond-ku
ID: 7102602
Thanks for the tip about comments...I hadn't actually realized that there was a difference at first (It was VERY late at night when I signed up).

Danny
hammond@ku.edu
0
 
LVL 1

Expert Comment

by:alaplume
ID: 7212050
Is the form embedded in some other object (ocx maybe). That could cause problems when centering.
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7522851
Dear dhammond-ku
I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See: <http://www.experts-exchange.com/jsp/communityNews.jsp>
Paragraph: Site Update for Wednesday, November 06, 2002

By this rejection the Asker will be notified by mail and hopefully he will take his responsibility to finalize the question or post an additional comment.
The Asker sees a button beside every post which says "Accept This Comment As Answer" (including rejected answers) -- so if he/she thinks yours is the best, you'll be awarded the points and the grade.

EXPERTS: I will return in seven days to close this question.
Please leave your thoughts and recommendations here

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Thanks !

kodiakbear
Experts Exchange Moderator
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7923784
Hi forrestx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept PaulHews's comment(s) as an answer.

forrestx, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7968481
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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