RRUZ / vcl-styles-utils

Extend and improve the Delphi VCL Styles
https://theroadtodelphi.wordpress.com/
329 stars 115 forks source link

Messagedlg bad visual with Alexandria ? #292

Closed lchris789 closed 1 year ago

lchris789 commented 2 years ago

I have a strange issue with delphi Alexandria.

Create a blank vcl themed project with any theme active. Lets say "Windows10"

add these units to the mais project dpr file Vcl.Themes, Vcl.Styles, Vcl.Styles.Utils.SysControls, Vcl.Styles.ColorTabs, Vcl.Styles.UxTheme, Vcl.Styles.Utils.Menus, // Vcl.Styles.Utils.Forms, // Vcl.Styles.Utils.StdCtrls, // Vcl.Styles.Utils.ComCtrls, Vcl.Styles.Utils.ScreenTips,

and this event in the main form

procedure TForm1.FormClick(Sender: TObject); begin MessageDlg('Hello, This is a messagedlg box size exemple', mtWarning, [mbOK, mbCancel], 0); end;

run it and clic to see the messagebox size is OK

Now uncomment one of the 3 uses lines above

run it again and clic to see the messagebox size is wroongly enlarged !

???? I could not find why this happens.

please help

can someone reproduce this ?

I guess this has something to do with the needed use of DwmGetWindowAttribute in windows versions above 6

in Vcl.Styles.Utils.SysStyleHook function TSysControl.GetWinRect: TRect; is using only Winapi.Windows.GetClientRect(Handle, Result); and this is not enought because shadow is included in the size and needs to be removed

I'm still far from solving this ! where is DwmGetWindowAttribute even declared in delphi ?? EDIT : found in Winapi.DwmApi.pas

Hmm ..; DwmGetWindowAttribute returns the same size

Could it be that the messagedlg form size is correct but everything inside is wrongly drawn ?

My head is overheating, I need the help of a real ingeneer who likes puzzles.

DinuruSeniya commented 2 years ago

@lchris789 Ok so here's the thing. From Delphi 10.4 upwards, there is native VCL Style support for MessageDlgs so this issue occurs due to a conflict when vcl-styles-utils tries to 're-theme' the already themed dialog. However, file open/save dialogs still need to be themed with vcl-styles-utils. Is there a way to disable vcl-styles-utlils for only MessageDlgs? @RRUZ

RRUZ commented 1 year ago

I have fixed this Alexandria issue, please pull and Retest.

lchris789 commented 1 year ago

Thank you !!! I will try Good weekend !