Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form position different on different machine 1

Status
Not open for further replies.

jjschwartz

Technical User
Feb 3, 2004
23
US
I position many of my modal forms relative to the main form by setting their top and left properties relative to the main form.

modalform.left := mainform.left + 100;
modalform.top := mainform.top + 100;

That way, my modal forms are always in the same position relative to the main form regardess of where the user drags the main form.

All was well until, to my great surprise, I ran my application on a Windows XP machine. The application was developed on a Windows 2000 machine.

The modal forms are about 10 pixels too high !?!

Any insights into how this happens and what I can do to make my forms come out in the right place?

TIA

 
Can you perhaps test whether the same thing happens if the XP machine has it's display theme set to Classic (rather than XP). This should result in the window objects appearing Win2K style.

If changing this changes your form offset back to normal, it will give you something to start working on.
 
Excellent thought! Switching to classic view made the forms line up.

So now I'm left with understanding why and how to deal with it. How can I check which appearance is in effect via Delphi? Why do I have to? "If appearance = xp then move the forms down" seems like such a kludge and it suggests I don't really understand what's going on or that Delphi has a subtle bug.

In a related problem, my application's main form has a Window style property that is not_sizeable. If I change it to sizeable the 'child' forms are moved to the left 1, maybe 2, pixels. I'm using Delphi 3.

Any further thoughts?

TIA

 
I forgot one of the first rules of programming...when the program doesn't work right it's always the programmer's fault, not the compiler.

I believe, if the menu bar and/or title bar of a form in XP style are taller than the menu bar and/or title bar of a form in Classic style, then that could account for the problem. (I'm going to write some test code to check this.)

Any advice on how to best deal with this so the application will work on different platforms? Is there a better way to 'line up' forms? Is there a more reliable property than mainform.left that will give me the position of the client area? Is there a way to check which 'appearance is being used?

TIA
 
Is there any special need for the window to be exactly there, or should they just be 'tiled'?

HTH
TonHu
 
What about positioning yor modal window relative to the parent client space?

Code:
with MainForm do
  begin 
    ModalForm.Left := Left + (Width - ClientWidth) + 100;
    ModalForm.Top := Top + (Height - ClientHeight) + 100;
  end;

One of the differences between XP and old Win are the non client area sizes, one of the MS new ways of screwing up working code (the newest one is .NET, the oldest and widely used one is that "service pack" thing :).

buho (A).

 
(To TonHu) Yes the forms need to be exactly where I want them. Essentially, they're very graphical elements and I want it to look very uniform and pretty.

Thanks to Buho. His solution is an excellent one. I've also learned that GetSystemMetrics(SM_CYCAPTION) can get similar information.

I'm curious what he's referring to in 'the service pack' problem.
 
> I'm curious what he's referring to in 'the service pack' problem.

Only a joke. Some MS service packs used to broke everything around :).

buho (A).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top