Jump to content
Keesver

ApplyStyleLookup is repeatetly called after a DPI change when using TDateEdit

Recommended Posts

ApplyStyleLookup should be called only once when a control is about to be painted. However, when a TDateEdit control is put on a form and the application is moved to a second monitor with a different DPI, ApplyStyleLookup is called every time the drop down of the date editor is opened. The same happens with a TComboBox control. See test application.

 

We will create a bug report for this at Embarcadero, but maybe someone knows a fix or workaround?

 

Thanks

ApplyStyleLookup.zip

Share this post


Link to post

This problem has more side effects than expected, after moving a form to a screen with different DPI, the whole form will be re-styled every time a drop down is opened. We filled a report for it:

https://embt.atlassian.net/servicedesk/customer/portal/1/RSS-824?sda_source=notification-email

 

Workaround, copy file FMX.Platform.Win to your project then update this method:

 

function TWinWindowHandle.GetScale: Single;
begin
  if not SameValue(FForcedScale, 0, TEpsilon.Scale) then
    Result := FForcedScale
  else if not SameValue(FCurrentScale, 0, TEpsilon.Scale) then
    Result := FCurrentScale

  // Add these lines, this will force the scale of the popup control to be the same as the scale of the parent
  else if (Form <> nil) and (Form.FormStyle = TFormStyle.Popup) and (Form.ParentForm <> nil) then
    Result := Form.ParentForm.Handle.Scale
  else
    Result := GetWndScale(FWnd);

  FCurrentScale := Result;
end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×