Delphi 7 forms, anchors not working in Vista

后端 未结 6 810
失恋的感觉
失恋的感觉 2020-12-30 06:08

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, akT

6条回答
  •  情歌与酒
    2020-12-30 07:03

    It looks this is pretty old question, anyway here's the only one solution for this problem in the Universe : Use the old style Windows programming sizing method using API trapping WM_SIZE and WM_SIZING, that's the infalible one and will function in every Windows you'll know.

    Of course this means you have to use mainly GetClientRect() to determine witdhs and heights and then resize controls based on such values, sure that may sound like trying to ignite a spaceship but it's the best.

    Otherwise you could do something more practical and quickly in a resizing procedure like :

    Control1.Left := Control2.Left + (buttonControl.Width div 2) - (buttonControl3.Width div 2);
    //for example widths
    Control4.Width    := (Control.Width * 4) + (Control.Left * 8) + 54 ;
    

    I do that kind of coding and functions in just all Windows no matter wich version it would be.

    You only need some values on the screen resolution for reference doing something like this :

    iCXSCREEN := GetSystemMetrics(SM_CXSCREEN);
    iCYSCREEN := GetSystemMetrics(SM_CYSCREEN);
    
        if ((iCXSCREEN = 1280) and (iCYSCREEN = 720)) or  ((iCXSCREEN = 1280) and (iCYSCREEN = 700)) or ((iCXSCREEN = 1280) and (iCYSCREEN = 600)) then begin
    
    // blah blah
    
    end;
    

    Hope helps someone else!

    Cheers!

提交回复
热议问题