Can't change the background color of windows which are inside another windowAPI-level Unicode GUI Native apps in C++ for Windows/Linux/MacChanging window background colourCannot make DragAcceptFiles work when using a dialog boxWindows::toolbar::NM_CUSTOMDRAW. Changing toolbar background colorTransparent cursor shows wrong color in DelphiCan't change background of windowHow to change background color of comboboxWINapi. Can't erase background of window with ellipseChange window's background color with button using winapiChanging background color of QWidget inside another Widget

Discworld quote about an "old couple" who having said everything to each other, can finally go about living their lives

Do home values typically rise and fall consistently across different price ranges?

Simple logic puzzle

On the geometric Hahn-Banach theorem

Translation of the Sator Square

Could you fall off a planet if it was being accelerated by engines?

Is there a way to convert blue ice back into packed ice?

Checkmate in 1 on a Tangled Board

If I were to build a J3 cub twice the size of the original using the same CG would it fly?

Put my student loan in parents’ second mortgage - help?

If I have the War Caster feat, can I use the Thorn Whip cantrip to stop an enemy caster from escaping using the Dimension Door spell?

On what to compliment someone with anorexia in order to improve their body image?

13th chords on guitar

Does turbulence make sky cities infeasible on Venus?

How can I open this door latch with the knobs removed?

Can European countries bypass the EU and make their own individual trade deal with the U.S.?

Have any large aeroplanes been landed — safely and without damage — in locations that they could not be flown away from?

Fully submerged water bath for stove top baking?

Should 私の be omitted?

How did they film the Invisible Man being invisible, in 1933?

How do I present a future free of gender stereotypes without being jarring or overpowering the narrative?

If two black hole event horizons overlap (touch) can they ever separate again?

Traversing Eurasia: A Cryptic Journey

How do I tell the reader that my character is autistic in Fantasy?



Can't change the background color of windows which are inside another window


API-level Unicode GUI Native apps in C++ for Windows/Linux/MacChanging window background colourCannot make DragAcceptFiles work when using a dialog boxWindows::toolbar::NM_CUSTOMDRAW. Changing toolbar background colorTransparent cursor shows wrong color in DelphiCan't change background of windowHow to change background color of comboboxWINapi. Can't erase background of window with ellipseChange window's background color with button using winapiChanging background color of QWidget inside another Widget






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to change the background color of a STATIC window, both - on load and change it on runtime. So far I have been able to change the color the following way:



 case WM_CTLCOLORSTATIC:

HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(200, 200, 20));
SetBkColor(hdcStatic, RGB(10, 10, 10));
SetBkMode(hdcStatic, TRANSPARENT);
return (INT_PTR)CreateSolidBrush(RGB(30, 30, 30));



Everything works fine and the background color gets changed, except for any STATIC windows, which are inside another static window:



HWND mainContainer = CreateWindowEx
(
0,
_TEXT("STATIC"),
"",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 500, 500,
hwnd,
NULL,
(HINSTANCE)GetWindowLong(hwnd, GWLP_HINSTANCE),
NULL
);

HWND subItem = CreateWindowEx
(
0,
_TEXT("STATIC"),
"SubItem",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 100, 100,
mainContainer,
NULL,
(HINSTANCE)GetWindowLong(mainContainer, GWLP_HINSTANCE),
NULL
);


In this case the mainContainer color gets changed, but not the background color for subItem. Any ideas why this is happening? Thank you!










share|improve this question






















  • Since the outer static is not marked CLIPCHILDREN, it is allowed to draw on top of its children, which includes erasing the background to a different color. (Note also that returning a CreateSolidBrush is a memory leak since nobody destroys that brush.)

    – Raymond Chen
    Mar 25 at 14:58












  • @RaymondChen thanks for the reply! My dwStyle has been set to "WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN" for the parentContainer, but still the same problem persists. Any more hints please? Thanks!

    – 0x29a
    Mar 25 at 15:08






  • 2





    Remember that the WM_CTLCOLORSTATIC message it sent to the static control's parent. In this case, subitem will send it to mainContainer. Are you handling the message in mainContainer's window procedure?

    – Raymond Chen
    Mar 25 at 16:47

















0















I want to change the background color of a STATIC window, both - on load and change it on runtime. So far I have been able to change the color the following way:



 case WM_CTLCOLORSTATIC:

HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(200, 200, 20));
SetBkColor(hdcStatic, RGB(10, 10, 10));
SetBkMode(hdcStatic, TRANSPARENT);
return (INT_PTR)CreateSolidBrush(RGB(30, 30, 30));



Everything works fine and the background color gets changed, except for any STATIC windows, which are inside another static window:



HWND mainContainer = CreateWindowEx
(
0,
_TEXT("STATIC"),
"",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 500, 500,
hwnd,
NULL,
(HINSTANCE)GetWindowLong(hwnd, GWLP_HINSTANCE),
NULL
);

HWND subItem = CreateWindowEx
(
0,
_TEXT("STATIC"),
"SubItem",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 100, 100,
mainContainer,
NULL,
(HINSTANCE)GetWindowLong(mainContainer, GWLP_HINSTANCE),
NULL
);


In this case the mainContainer color gets changed, but not the background color for subItem. Any ideas why this is happening? Thank you!










share|improve this question






















  • Since the outer static is not marked CLIPCHILDREN, it is allowed to draw on top of its children, which includes erasing the background to a different color. (Note also that returning a CreateSolidBrush is a memory leak since nobody destroys that brush.)

    – Raymond Chen
    Mar 25 at 14:58












  • @RaymondChen thanks for the reply! My dwStyle has been set to "WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN" for the parentContainer, but still the same problem persists. Any more hints please? Thanks!

    – 0x29a
    Mar 25 at 15:08






  • 2





    Remember that the WM_CTLCOLORSTATIC message it sent to the static control's parent. In this case, subitem will send it to mainContainer. Are you handling the message in mainContainer's window procedure?

    – Raymond Chen
    Mar 25 at 16:47













0












0








0


1






I want to change the background color of a STATIC window, both - on load and change it on runtime. So far I have been able to change the color the following way:



 case WM_CTLCOLORSTATIC:

HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(200, 200, 20));
SetBkColor(hdcStatic, RGB(10, 10, 10));
SetBkMode(hdcStatic, TRANSPARENT);
return (INT_PTR)CreateSolidBrush(RGB(30, 30, 30));



Everything works fine and the background color gets changed, except for any STATIC windows, which are inside another static window:



HWND mainContainer = CreateWindowEx
(
0,
_TEXT("STATIC"),
"",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 500, 500,
hwnd,
NULL,
(HINSTANCE)GetWindowLong(hwnd, GWLP_HINSTANCE),
NULL
);

HWND subItem = CreateWindowEx
(
0,
_TEXT("STATIC"),
"SubItem",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 100, 100,
mainContainer,
NULL,
(HINSTANCE)GetWindowLong(mainContainer, GWLP_HINSTANCE),
NULL
);


In this case the mainContainer color gets changed, but not the background color for subItem. Any ideas why this is happening? Thank you!










share|improve this question














I want to change the background color of a STATIC window, both - on load and change it on runtime. So far I have been able to change the color the following way:



 case WM_CTLCOLORSTATIC:

HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(200, 200, 20));
SetBkColor(hdcStatic, RGB(10, 10, 10));
SetBkMode(hdcStatic, TRANSPARENT);
return (INT_PTR)CreateSolidBrush(RGB(30, 30, 30));



Everything works fine and the background color gets changed, except for any STATIC windows, which are inside another static window:



HWND mainContainer = CreateWindowEx
(
0,
_TEXT("STATIC"),
"",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 500, 500,
hwnd,
NULL,
(HINSTANCE)GetWindowLong(hwnd, GWLP_HINSTANCE),
NULL
);

HWND subItem = CreateWindowEx
(
0,
_TEXT("STATIC"),
"SubItem",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_SOLID,
10, 10, 100, 100,
mainContainer,
NULL,
(HINSTANCE)GetWindowLong(mainContainer, GWLP_HINSTANCE),
NULL
);


In this case the mainContainer color gets changed, but not the background color for subItem. Any ideas why this is happening? Thank you!







c++ winapi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 14:48









0x29a0x29a

14910 bronze badges




14910 bronze badges












  • Since the outer static is not marked CLIPCHILDREN, it is allowed to draw on top of its children, which includes erasing the background to a different color. (Note also that returning a CreateSolidBrush is a memory leak since nobody destroys that brush.)

    – Raymond Chen
    Mar 25 at 14:58












  • @RaymondChen thanks for the reply! My dwStyle has been set to "WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN" for the parentContainer, but still the same problem persists. Any more hints please? Thanks!

    – 0x29a
    Mar 25 at 15:08






  • 2





    Remember that the WM_CTLCOLORSTATIC message it sent to the static control's parent. In this case, subitem will send it to mainContainer. Are you handling the message in mainContainer's window procedure?

    – Raymond Chen
    Mar 25 at 16:47

















  • Since the outer static is not marked CLIPCHILDREN, it is allowed to draw on top of its children, which includes erasing the background to a different color. (Note also that returning a CreateSolidBrush is a memory leak since nobody destroys that brush.)

    – Raymond Chen
    Mar 25 at 14:58












  • @RaymondChen thanks for the reply! My dwStyle has been set to "WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN" for the parentContainer, but still the same problem persists. Any more hints please? Thanks!

    – 0x29a
    Mar 25 at 15:08






  • 2





    Remember that the WM_CTLCOLORSTATIC message it sent to the static control's parent. In this case, subitem will send it to mainContainer. Are you handling the message in mainContainer's window procedure?

    – Raymond Chen
    Mar 25 at 16:47
















Since the outer static is not marked CLIPCHILDREN, it is allowed to draw on top of its children, which includes erasing the background to a different color. (Note also that returning a CreateSolidBrush is a memory leak since nobody destroys that brush.)

– Raymond Chen
Mar 25 at 14:58






Since the outer static is not marked CLIPCHILDREN, it is allowed to draw on top of its children, which includes erasing the background to a different color. (Note also that returning a CreateSolidBrush is a memory leak since nobody destroys that brush.)

– Raymond Chen
Mar 25 at 14:58














@RaymondChen thanks for the reply! My dwStyle has been set to "WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN" for the parentContainer, but still the same problem persists. Any more hints please? Thanks!

– 0x29a
Mar 25 at 15:08





@RaymondChen thanks for the reply! My dwStyle has been set to "WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN" for the parentContainer, but still the same problem persists. Any more hints please? Thanks!

– 0x29a
Mar 25 at 15:08




2




2





Remember that the WM_CTLCOLORSTATIC message it sent to the static control's parent. In this case, subitem will send it to mainContainer. Are you handling the message in mainContainer's window procedure?

– Raymond Chen
Mar 25 at 16:47





Remember that the WM_CTLCOLORSTATIC message it sent to the static control's parent. In this case, subitem will send it to mainContainer. Are you handling the message in mainContainer's window procedure?

– Raymond Chen
Mar 25 at 16:47












1 Answer
1






active

oldest

votes


















1














The message WM_CTLCOLORSTATIC will be sent only to the parent window, but not parent's parent window.



According to About Static Controls :




The window procedure for the predefined static control window class
performs default processing for all messages that the static control
procedure does not process.




The WM_CTLCOLORSTATIC is not in the list that it process. So The predefined window procedure will passes the message to DefWindowProc for default processing.



(We really don't often put a static window inside another static window. This is not a common operation. So you should reset the parent window of subItem to hwnd.)






share|improve this answer























  • Thanks for the reply! Could you please tell me if I wanted to add scrollbar to the container, should I simply use scrollbar control without any container and handle the "cropping" manually? Thanks!

    – 0x29a
    Mar 26 at 9:11











  • Add the WS_VSCROLL | WS_HSCROLL to dwStyle?

    – Drake Wu - MSFT
    Mar 26 at 14:23










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55340480%2fcant-change-the-background-color-of-windows-which-are-inside-another-window%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The message WM_CTLCOLORSTATIC will be sent only to the parent window, but not parent's parent window.



According to About Static Controls :




The window procedure for the predefined static control window class
performs default processing for all messages that the static control
procedure does not process.




The WM_CTLCOLORSTATIC is not in the list that it process. So The predefined window procedure will passes the message to DefWindowProc for default processing.



(We really don't often put a static window inside another static window. This is not a common operation. So you should reset the parent window of subItem to hwnd.)






share|improve this answer























  • Thanks for the reply! Could you please tell me if I wanted to add scrollbar to the container, should I simply use scrollbar control without any container and handle the "cropping" manually? Thanks!

    – 0x29a
    Mar 26 at 9:11











  • Add the WS_VSCROLL | WS_HSCROLL to dwStyle?

    – Drake Wu - MSFT
    Mar 26 at 14:23















1














The message WM_CTLCOLORSTATIC will be sent only to the parent window, but not parent's parent window.



According to About Static Controls :




The window procedure for the predefined static control window class
performs default processing for all messages that the static control
procedure does not process.




The WM_CTLCOLORSTATIC is not in the list that it process. So The predefined window procedure will passes the message to DefWindowProc for default processing.



(We really don't often put a static window inside another static window. This is not a common operation. So you should reset the parent window of subItem to hwnd.)






share|improve this answer























  • Thanks for the reply! Could you please tell me if I wanted to add scrollbar to the container, should I simply use scrollbar control without any container and handle the "cropping" manually? Thanks!

    – 0x29a
    Mar 26 at 9:11











  • Add the WS_VSCROLL | WS_HSCROLL to dwStyle?

    – Drake Wu - MSFT
    Mar 26 at 14:23













1












1








1







The message WM_CTLCOLORSTATIC will be sent only to the parent window, but not parent's parent window.



According to About Static Controls :




The window procedure for the predefined static control window class
performs default processing for all messages that the static control
procedure does not process.




The WM_CTLCOLORSTATIC is not in the list that it process. So The predefined window procedure will passes the message to DefWindowProc for default processing.



(We really don't often put a static window inside another static window. This is not a common operation. So you should reset the parent window of subItem to hwnd.)






share|improve this answer













The message WM_CTLCOLORSTATIC will be sent only to the parent window, but not parent's parent window.



According to About Static Controls :




The window procedure for the predefined static control window class
performs default processing for all messages that the static control
procedure does not process.




The WM_CTLCOLORSTATIC is not in the list that it process. So The predefined window procedure will passes the message to DefWindowProc for default processing.



(We really don't often put a static window inside another static window. This is not a common operation. So you should reset the parent window of subItem to hwnd.)







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 8:16









Drake Wu - MSFTDrake Wu - MSFT

1,7251 gold badge2 silver badges10 bronze badges




1,7251 gold badge2 silver badges10 bronze badges












  • Thanks for the reply! Could you please tell me if I wanted to add scrollbar to the container, should I simply use scrollbar control without any container and handle the "cropping" manually? Thanks!

    – 0x29a
    Mar 26 at 9:11











  • Add the WS_VSCROLL | WS_HSCROLL to dwStyle?

    – Drake Wu - MSFT
    Mar 26 at 14:23

















  • Thanks for the reply! Could you please tell me if I wanted to add scrollbar to the container, should I simply use scrollbar control without any container and handle the "cropping" manually? Thanks!

    – 0x29a
    Mar 26 at 9:11











  • Add the WS_VSCROLL | WS_HSCROLL to dwStyle?

    – Drake Wu - MSFT
    Mar 26 at 14:23
















Thanks for the reply! Could you please tell me if I wanted to add scrollbar to the container, should I simply use scrollbar control without any container and handle the "cropping" manually? Thanks!

– 0x29a
Mar 26 at 9:11





Thanks for the reply! Could you please tell me if I wanted to add scrollbar to the container, should I simply use scrollbar control without any container and handle the "cropping" manually? Thanks!

– 0x29a
Mar 26 at 9:11













Add the WS_VSCROLL | WS_HSCROLL to dwStyle?

– Drake Wu - MSFT
Mar 26 at 14:23





Add the WS_VSCROLL | WS_HSCROLL to dwStyle?

– Drake Wu - MSFT
Mar 26 at 14:23








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55340480%2fcant-change-the-background-color-of-windows-which-are-inside-another-window%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?