After some investigation, it appears that the font is not set on the hdc before the DrawThemeText function is executed.
While using the MS Detours library can resolve this, there doesn't seem to be any other solution suitable for an official bug fix.
Code: Select all
Import "Detours.lib"
DetourTransactionBegin.l()
DetourTransactionCommit.l()
DetourUpdateThread.l(hThread)
DetourAttach.l(*ppPointer, pDetour)
DetourDetach.l(*ppPointer, pDetour)
EndImport
Import "uxtheme.lib"
DrawThemeText.l(hTheme, hdc, iPartId.l, iStateId.l, *pszText, cchText.l, dwTextFlags.l, dwTextFlags2.l, *pRect.RECT)
EndImport
Prototype.l ptDrawThemeText(hTheme, hdc, iPartId.l, iStateId.l, *pszText, cchText.l, dwTextFlags.l, dwTextFlags2.l, *pRect.RECT)
Global DrawThemeText__.ptDrawThemeText = @DrawThemeText()
#BP_GROUPBOX = 4
#GBS_NORMAL = 1
#GBS_DISABLED = 2
Procedure.l My_DrawThemeText(hTheme, hdc, iPartId.l, iStateId.l, *pszText, cchText.l, dwTextFlags.l, dwTextFlags2.l, *pRect.RECT)
Protected Result.l
Protected hWnd, hFont, hOldFont
If iPartId = #BP_GROUPBOX
hWnd = WindowFromDC_(hdc)
If hWnd
hFont = SendMessage_(hWnd, #WM_GETFONT, 0, 0)
If hFont
hOldFont = SelectObject_(hdc, hFont)
EndIf
Result = DrawThemeText__(hTheme, hdc, iPartId, iStateId, *pszText, cchText, dwTextFlags, dwTextFlags2, *pRect)
If hOldFont
SelectObject_(hdc, hOldFont)
EndIf
ProcedureReturn Result
EndIf
EndIf
ProcedureReturn DrawThemeText__(hTheme, hdc, iPartId, iStateId, *pszText, cchText, dwTextFlags, dwTextFlags2, *pRect)
EndProcedure
If DetourTransactionBegin() = #NO_ERROR
If DetourUpdateThread(GetCurrentThread_()) = #NO_ERROR
If DrawThemeText__
If DetourAttach(@DrawThemeText__, @My_DrawThemeText()) <> #NO_ERROR
Debug "DetourAttach Error: DrawThemeText"
Else
Debug "DetourAttach OK: DrawThemeText"
EndIf
EndIf
DetourTransactionCommit()
EndIf
EndIf
If OpenWindow(0, 0, 0, 500, 220, "FrameContainer Font Text", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;LoadFont(0, "Segoe UI", 12, #PB_Font_Italic)
;SetGadgetFont(#PB_Default, FontID(0))
FrameGadget(0, 20, 60, 200, 120, "FrameContainer_0", #PB_Frame_Container)
CloseGadgetList()
FrameGadget(1, 240, 20, 240, 180, "FrameContainer_1", #PB_Frame_Container)
FrameGadget(2, 20, 40, 200, 120, "FrameContainer_2", #PB_Frame_Container)
TextGadget(3, 10, 30, 180, 80, "The FrameContainer Font Text is not displayed properly if the FrameContainer is inside a Framecontainer !")
SetGadgetColor(3, #PB_Gadget_FrontColor, RGB(255, 0, 0))
CloseGadgetList()
CloseGadgetList()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
If DetourTransactionBegin() = #NO_ERROR
If DetourUpdateThread(GetCurrentThread_()) = #NO_ERROR
If DrawThemeText__
If DetourDetach(@DrawThemeText__, @My_DrawThemeText()) <> #NO_ERROR
Debug "DetourDetach Error: DrawThemeText"
Else
Debug "DetourDetach OK: DrawThemeText"
EndIf
EndIf
DetourTransactionCommit()
EndIf
EndIf