flat assembler
Message board for the users of flat assembler.
Index
> Windows > Tab control background color |
Author |
|
fasm14 14 Aug 2021, 11:35
Hello! I've been trying to figure out how to change a tab control's background color; it doesn't have any messages that can be sent to it to change it and so the background with the required color needs to be drawn manually; I found some solutions on the Internet (like this one: http://web.archive.org/web/20190119111408/http://www.glennslayden.com/code/win32/tab-control-background-brush) but they seem complicated and I'm not good enough with C to translate them into asm; I was wondering if there's an easier way to do this, by changing the default background color or something similar? I tried SetSysColors with COLOR_BTNFACE (and some other ones) but it changed the color for the entire system and the tab control wasn't even affected...
|
|||
14 Aug 2021, 11:35 |
|
bitRAKE 14 Aug 2021, 18:44
This looks like a good answer:
http://www.equestionanswers.com/vcpp/background-color-edit-static.php ...but no tab control. https://social.msdn.microsoft.com/Forums/en-US/44bf30c8-ca7b-483f-9c8f-8aafcffd389e/picking-up-the-background-of-a-tab-control-in-a-dialog?forum=vcgeneral Owner-drawn tabs seem overkill just to change the color. (AHK example) Looking at Notepad++ source code it looks like subclassing and painting the background by handling WM_ERASEBKGND might be sufficient. |
|||
14 Aug 2021, 18:44 |
|
bitRAKE 16 Aug 2021, 08:40
Handling WM_ERASEBKGND definitely doesn't work - in fact the WM_PAINT for the tab control completely covers the client area, so anything done in WM_ERASEBKGND is over-written.
I did log the messages for the tab control and there is no WM_CTLCOLOR* type message or internal "hacky-way" to set the color that I could see. Looks like owner-drawn control is the only way.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||||||||||
16 Aug 2021, 08:40 |
|
fasm14 17 Aug 2021, 16:07
I tried replacing just WM_ERASEBKGND at first, but then the new background only occasionally appeared after I dragged the window off screen (also the tabs themselves stopped working); I tried to do something similar to the posted example by first calling the original WM_PAINT then recolouring the background, but it didn't work either... Originally I was trying to make the background have the default form color, and apparently just setting the TCS_OWNERDRAWFIXED style makes the background have that exact color; now all I need to do is put static text controls where the tabs are supposed to be (their layout and boundaries are still drawn). Thanks a lot, bitRAKE and macomics!
|
|||
17 Aug 2021, 16:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.