New patch
(setColor not work yet, but I think with this patch we don't lost time to setup PixelPerInch )


Darek
Index: lcl/forms.pp
===================================================================
--- lcl/forms.pp        (wersja 8136)
+++ lcl/forms.pp        (kopia robocza)
@@ -394,6 +394,7 @@
     procedure CloseModal;
     procedure DoCreate;
     procedure DoDestroy;
+    function  GetPixelsPerInch:LongInt;
     procedure IconChanged(Sender: TObject);
     function IsKeyPreviewStored: boolean;
     procedure SetActive(AValue: Boolean);
@@ -536,7 +537,7 @@
     property OnShow: TNotifyEvent read FOnShow write FOnShow;
     property OnWindowStateChange: TNotifyEvent
                          read fOnWindowStateChange write fOnWindowStateChange;
-    property PixelsPerInch: Longint read FPixelsPerInch write FPixelsPerInch 
stored False;
+    property PixelsPerInch: Longint read GetPixelsPerInch write FPixelsPerInch 
stored False default -1;
     property Position: TPosition read FPosition write SetPosition default 
poDesigned;
     property RestoredLeft: integer read FRestoredLeft;
     property RestoredTop: integer read FRestoredTop;
Index: lcl/include/customform.inc
===================================================================
--- lcl/include/customform.inc  (wersja 8136)
+++ lcl/include/customform.inc  (kopia robocza)
@@ -1610,14 +1610,50 @@

   Creates the interface object.
  
------------------------------------------------------------------------------}
-procedure TCustomForm.CreateWnd;
+function tCustomForm.GetPixelsPerInch:LongInt;
 var
   DC: HDC;
   ParentForm: TCustomForm;
+
 begin
+
+  if fPixelsPerInch=-1 then begin
+    if Parent<>nil then begin
+      ParentForm:=GetParentForm(Self);
+      if ParentForm<>nil then begin
+        FPixelsPerInch:=ParentForm.PixelsPerInch;
+        result:=fPixelsPerInch;
+      end;
+    end;
+
+    if result<0 then begin
+      if HandleAllocated then begin
+        DC:=GetDC(Handle);
+        FPixelsPerInch:=GetDeviceCaps(DC,LOGPIXELSX);
+        ReleaseDC(Handle,DC);
+        result:=fPixelsPerInch;
+
+      end else begin
+       result:=Screen.PixelsPerInch;
+      end;
+    end;
+  end else result:=fPixelsPerInch;
+
+end;
+
+
+procedure TCustomForm.CreateWnd;
+//var
+//  DC: HDC;
+//  ParentForm: TCustomForm;
+begin
   //DebugLn('TCustomForm.CreateWnd START ',ClassName);
   FFormState:=FFormState-[fsBorderStyleChanged,fsFormStyleChanged];
   inherited CreateWnd;
+  if Parent=nil then begin
+        TWSCustomFormClass(WidgetSetClass).SetIcon(Self, GetIconHandle);
+  end;
+  (*

   if Parent=nil then begin
     TWSCustomFormClass(WidgetSetClass).SetIcon(Self, GetIconHandle);
@@ -1630,6 +1666,7 @@
       FPixelsPerInch:=ParentForm.PixelsPerInch;
     end;
   end;
+  *)

   Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded');
   if FMenu <> nil then

Reply via email to