Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Änderung der Schriftgröße durch OS verhindern (https://www.delphipraxis.net/138893-aenderung-der-schriftgroesse-durch-os-verhindern.html)

erich.wanker 19. Aug 2009 13:20


Änderung der Schriftgröße durch OS verhindern
 
Hallo,

Ich hab ein Programm auf meinem PC erstellt..
WinXP, Desktop, deutsch, 2048*1024, 32bit, 96 dpi

Wenn ich nun das programm auf einem anderen PC ausführe..
Windows7, Notebook, engl, 1900*700 16bit, Schriftgröße 120%

dann ist mein GUI total verschoben.. manche Buttons sind nicht mehr auf dem Form, manche halb von Panels verdeckt..

ich hab eigentlich extra für diese Fälle:

Delphi-Quellcode:
procedure RescaleWindow(Form: TForm);
var dc : hdc;
var dpi : Integer;
begin
 // get the device context of the screen
 dc := GetDC(0);
 try
   // read the logical dpi
   dpi := GetDeviceCaps(dc, LOGPIXELSX);
   // if the dpi is larger than what it was designed for
   if (dpi > 96) then
   begin
     // scale it to the right size again
     Form.ScaleBy(96, dpi);
   end;
   // and force a redraw of the window
   Form.Refresh;
 finally
   // in every case, free the device context
   ReleaseDC(0, dc);
 end;
end;
eingebaut - hilft aber nix..

Hat jemand eine idee - wie ich dem Betriebssystem beibringen kann, die Schriftart und größe meiner Anwendung auf 96 dpi zu lassen und Componenten nicht zu verschieben...?


Weiters hab ich versucht, eine Berechnung zu verwenden - hilft aber auch nix..

Delphi-Quellcode:
procedure RescaleWindow(Form: TForm) ;
var ScreenWidth, ScreenHeight: LongInt;
begin

   Form.Scaled := True;
   Form.AutoScroll := False;
   Form.Position := poScreenCenter;
   Form.Font.Name := 'Calibri';
   if (Screen.Width <> ScreenWidth) then begin
     Form.Height :=
         LongInt(Form.Height) * LongInt(Screen.Height)
         div ScreenHeight;
     Form.Width :=
         LongInt(Form.Width) * LongInt(Screen.Width)
         div ScreenWidth;
     Form.ScaleBy(Screen.Width,ScreenWidth) ;
   end;
end;

Vielen Dank

Erich


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz