Hi Experts!
Is is possible to set the color of the title for a GroupBox without doing something like 'owner draw? Been wracking my brain and burning up the keyboard trying things.
See circled item in the attachment. I can change the font and language, no problem, but can't seem to change the color for this box's title. In my dark mode one can't read it :(
Any help appreciated ...even if it is "no it can't be done" :)
Thanks,
John Z
So same problem as here:
How do I set the font and color for a group box caption using Win32 (https://stackoverflow.com/questions/1737108/how-do-i-set-the-font-and-color-for-a-group-box-caption-using-win32)
Thanks TimoVJL,
Maybe so but I can set font, text and size, just not color. That site is blocked for me at the present time, I might try a VPN to it later.
John Z
Thanks TimoVJL
Quote from: TimoVJL on January 13, 2024, 09:58:22 AM
So same problem as here:
How do I set the font and color for a group box caption using Win32 (https://stackoverflow.com/questions/1737108/how-do-i-set-the-font-and-color-for-a-group-box-caption-using-win32)
I finally got in! Yes, looks like my issue and a possible way to solve it without owner draw but not mentioned directly. I'll let you know.
Appreciate the help!
John Z
It is possible to change the background of the Group text but changing its text color eludes me.
Here is the BCX code that produces the app in the screenshot.
If you want the generated C/C++ code, download the translator:
https://bcxbasiccoders.com/smf/index.php?topic=990.0
GUI "Form1", PIXELS
CONST Grp1_Style = WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP|BS_GROUPBOX
CONST Grp1_ExtStyle = 0
ENUM
ID_Grp1
END ENUM
GLOBAL Form1 AS HWND
GLOBAL hGrp1 AS CONTROL
SUB FORMLOAD()
Form1 = BCX_FORM("Form1", 0, 0, 463, 316)
hGrp1 = BCX_GROUP("Group", Form1, ID_Grp1, 22, 25, 281, 190, Grp1_Style, Grp1_ExtStyle)
CENTER(Form1)
SHOW(Form1)
END SUB
BEGIN EVENTS
SELECT CASE CBMSG
'***********************************************************************
CASE WM_CTLCOLORSTATIC
'***********************************************************************
SELECT CASE (HWND) CBLPARAM
CASE hGrp1 : FUNCTION = BCX_SETCOLOR(RGB(255, 0, 0), RGB(200, 255, 200))
END SELECT
END SELECT
END EVENTS
Thanks MrBcx for looking into this. I've downloaded your incredible program twice now hopefully soon I'll actually use it. I'll have to shift my brain though out of Quick Basic and MS VB versions 0-5 ;D
Thanks TimoVJL for the article link. it help lead me to this 1 second fix....which was not in the article but I recall using elsewhere.
SetWindowTheme(GetDlgItem(gHWND, OptionBox1), L"", L"");// override manifest theme
Does not affect other controls so no loss of anything else.
John Z
SetWindowTheme(GetDlgItem(gHWND, OptionBox1), L"", NULL);
This disables Visual Theme support for the specified handle since Windows XP. You might want to pass NULL to the last parameter if using a empty string to disable visual styles.
Hi WiiLF23,
Yes, it then allows one to set the text color...without needing owner draw.
No major change to the group box appearance so still looks the same.
proto is -
HRESULT SetWindowTheme(
[in] HWND hwnd,
[in] LPCWSTR pszSubAppName,
[in] LPCWSTR pszSubIdList
);
From MS:
QuoteWhen pszSubAppName and pszSubIdList are NULL, the theme manager removes the previously applied associations. You can prevent visual styles from being applied to a specified window by specifying an empty string, (L" "), which does not match any section entries.
So NULL removes while L"" inhibits application as I read it. In my case both would be OK, maybe NULL is preferred in some situations though.
John Z
Quote from: John Z on January 16, 2024, 11:38:14 PM
Hi WiiLF23,
Yes, it then allows one to set the text color...without needing owner draw.
No major change to the group box appearance so still looks the same.
proto is -
HRESULT SetWindowTheme(
[in] HWND hwnd,
[in] LPCWSTR pszSubAppName,
[in] LPCWSTR pszSubIdList
);
From MS:
QuoteWhen pszSubAppName and pszSubIdList are NULL, the theme manager removes the previously applied associations. You can prevent visual styles from being applied to a specified window by specifying an empty string, (L" "), which does not match any section entries.
So NULL removes while L"" inhibits application as I read it. In my case both would be OK, maybe NULL is preferred in some situations though.
John Z
Interesting. I never located that documentation but it is all confirmed. I think NULL is just "best practice", same way I assign all static non-numeric primitives to NULL. I dont think it is necessary, but more preferred means of initialization. It's become a habit indeed.
Quote from: John Z on January 16, 2024, 11:38:14 PM
In my case both would be OK, maybe NULL is preferred in some situations though.
Turns out NULL was not OK and it didn't work, just to be correcting
myself.
Also in an offline Controls API help file I created, I found:
QuoteTurning Off Visual Styles
You can turn off visual styles for a control or for all controls in a window by calling the **SetWindowTheme** function as follows:
SetWindowTheme(hwnd, L" ", L" "); In the previous example, hwnd is the handle of the window in which to disable visual styles. After the call, the control renders without visual styles.
The controls api file is from on-line GitHub documentation but converted to html and converted to controls.chm for offline (mostly) access. The 'mostly' is because the GitHub docs were not complete.
Here is the link if you want to grab it:
https://sourceforge.net/projects/windows-controls-api-docs/
John Z