You are here:

C++/change win color

Advertisement


Question
I would like to know, how to change the background-color of a window (known by a HWND) of another win23-application!?
(the window belongs to an other app, not my app!)

Example for changing of the text of a window:
::SetWindowText(hwnd, "text");

Hint:
SetClassLong(hwnd, GCL_HBRBACKGROUND, hbrush);
doesn't work because of 'access denied' GetLastError().

OS: win-xp
compiler: visual studio

Answer
I've never had to do this but I think the problem is the hbrush is allocated in one process and SetClassLong applies it to a window in another process.  This is a pretty obscure requirement and request - I don't know anyone who would have done this kind of task.  I might suggest you look into one of the MicroSoft support lists and see if anyone there knows if this is possible, and if it is, how.

Sorry to not be much help on this one.

Bill

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bill A

Expertise

I can answer questions about C++, programming algorithms, Windows programming in MFC (which is C++). I cannot answer questions about STL (templates) and I have no experience with Linux. I do enjoy reviewing code and critiquing it or finding problems in it. I will also gladly show better algorithms or methods if you want to take advantage of that.

Experience

I've developed a commercial embedded C compiler/assembler and IDE with debugger toolset, of which the IDE and debugger are written in C++. I work in the industry writing high tech embedded programs and Windows programs to communicate with the embedded devices.

Publications
Book: Embedded Systems Design using the Rabbit 3000 Microprocessor Authored Chapter 10 in its entirety.

Education/Credentials
BS Computer Engineering

©2016 About.com. All rights reserved.