Solved

Form refuses to center

Posted on 2002-06-22
9
211 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
9 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 38

Expert Comment

by:PaulHews
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Expert Comment

by:dhammond-ku
Comment Utility
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
Comment Utility
Is the form embedded in some other object (ocx maybe). That could cause problems when centering.
0
 
LVL 1

Expert Comment

by:kodiakbear
Comment Utility
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
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now