RRUZ / vcl-styles-utils

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

Avoid a crash if GdiPlus is not initialized #309

Open WeberAndre opened 11 months ago

WeberAndre commented 11 months ago

1) If GdiPlus is not initialized in GetIcon a GDI Plus exception is raised. If this happends inside a detour function this leads to a serious crash of the whole application.

2) Fix DrawStyleParentBackgroundEx wrong portion of background used DrawStyleParentBackgroundEx used the coordinates of the parentwindow (LPoint) to copy from LBuffer device context, thats wrong to copy from the bitmap dc the source position must be 0, 0. For the WM_ERASEBKGND you must change the Origin of the bitmap devicecontext so that the right part of the background is painted into to bitmap.

(DrawStyleParentBackground may be removed later, because its complete wrong and doesn't paint anything to DC !)

3) For Menus with OwnerDraw we don't get a ItemText, this is also the case for the history drop down of the FileOpen / FileSave dialog. This patch tries to delegate ownerdraw back to the owner windows of the menu - in case of the file dialogs it works.

4) Detour_UxTheme_GetThemeColor: Reorganized code instead that every TMT_TEXTCOLOR is answered with clWindowText. First give a try to each case if this doesn't set the pColor to something different as clNone - stay at clWindowText. For VSCLASS_MENU we get ask for the TMT_TEXTCOLOR and for the TMT_FILLCOLOR of the same state.

Replaced calls to DrawStyleParentBackground with DrawStyleParentBackgroundEx after fixing it. -> this also fixes drawing issues with TButton in Designmode.

UxTheme_Button: Reverted the drawing on a temporary bitmap with a simple transparent color - because the fill and transparentcolor clBtnFace is also the color used of some style to draw the button surface .. which becomes in that case transparent and not visible. If the button itself has rounded corners - these are drawn with semitransparency in the StyleService - so if a temporary bitmap is used it must be set to pf32bit with AlphaFormat instead of a transparent color. After replacing not working DrawStyleParentBackGround with my modifed DrawStyleParentBackgroundEx it seems to work.