Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi 7 forms, anchors not working in Vista

The software is built on Delphi 7.

On my XP machine, the form resizes as I expect. However, on two Vista machines, I have components with anchors set to [akLeft, akTop, akRight, akBottom], but when I resize the form, the components don't stretch with the form, leaving blank spaces on the right and bottom edge. On the XP machine, the components correctly stretch with the form.

So, it seems like the Vista machine is ignoring the anchor property. Any ideas what's causing this and how to fix it?

Important update (François):
We had the same problem with our D2007 application and on all x64 windows.
Andreas' answer was indeed the fix. So it is not D7 nor Vista related.

like image 292
Robo Avatar asked Aug 31 '09 00:08

Robo


3 Answers

Maybe it is related to the "Windows Kernel stack overflow" problem that occurs if your control has many parents. And if you run it on a 64 bit system the kernel stack overflow happens much faster. (more about this here: http://news.jrsoftware.org/news/toolbar2000/msg07779.html)

On Embarcadero's CodeCentral is a workaround for this bug (which is also copied almost 1:1 into the Delphi 2009 VCL): http://cc.embarcadero.com/Item/25646

like image 104
Andreas Hausladen Avatar answered Nov 07 '22 13:11

Andreas Hausladen


It might be because of the transparent frame which is shown by Vista. (In order to give different windows same transparent appearance.

Try using "Align" (alClient) instead of anchors. Since you are using all anchors, that makes more sense.

like image 2
Hemant Avatar answered Nov 07 '22 13:11

Hemant


Before anchors were introduced in Delphi 4, we resized components dynamically to achieve the same effect. You can easily move/adjust the components in the form's onresize event.

Setting the form's doublebuffered property to true may reduce flicker, by buffering the paint method. I recall we used to have to implement that ourselves, too!

like image 2
Argalatyr Avatar answered Nov 07 '22 12:11

Argalatyr