Avoid a crash if GdiPlus is not initialized #309
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 !)
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.
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.