Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 999437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:21:07+00:00 2026-05-16T07:21:07+00:00

I’m trying to change the background color of a program I did NOT write.

  • 0

I’m trying to change the background color of a program I did NOT write.

Looking at it with Spy++ I can see that the main class is “ThunderRT6FormDC”. One of its children has the class “ThunderRT6Frame”. Inside ThunderRT6Frame there are a bunch of ThunderRT6CommandButtons.

I want to change the background color behind the buttons. I tried doing this by changing the color of the ThunderRT6Frame window, but I can’t get it to work. Any ideas?

This is what I tried first:

HWND hwndCnt = FindWindow("ThunderRT6FormDC", NULL);
HWND hwndCntFrame = FindWindowEx(hwndCnt, NULL, "ThunderRT6Frame", NULL);

SetClassLong(hwndCnt, GCL_HBRBACKGROUND, (LONG)CreateSolidBrush(RGB(220,220,255)));
InvalidateRect(hwndCnt, 0, TRUE);
SetClassLong(hwndCntFrame, GCL_HBRBACKGROUND, (LONG)CreateSolidBrush(RGB(220,220,255)));
InvalidateRect(hwndCntFrame, 0, TRUE);

No visible changes came out of that, so I moved on to injecting a dll and subclass WM_PAINT:

PAINTSTRUCT ps;
HDC hdcPaint = BeginPaint(Hwnd, &ps);
SetBkColor(hdcPaint, RGB(255,0,0));

HPEN pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0));

HPEN hOldPen = (HPEN)SelectObject(hdcPaint, pen);
HBRUSH hOldBrush = (HBRUSH)SelectObject(hdcPaint, brush);

RoundRect(hdcPaint, 1, 1, 100, 100, 10, 10);

SelectObject(hdcPaint, hOldPen);
SelectObject(hdcPaint, hOldBrush);

DeleteObject(pen);
DeleteObject(brush);

EndPaint(Hwnd, &ps);

return 0;

I have WM_PAINT subclassed for both ThunderRT6FormDC and ThunderRT6Frame but no red rectangle is drawn that I can see.

What am I doing wrong? What else do I need to try?

PS. The window class names in the program I’m trying to change indicates that it is a VB6 program, if that’s any help.

EDIT:

I tried adding the following to both window procedures

case WM_ERASEBKGND:
{
    HDC hdcPaint = (HDC)wParam;
    SetBkColor(hdcPaint, RGB(255,0,0));

    HPEN pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
    HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0));

    HPEN hOldPen = (HPEN)SelectObject(hdcPaint, pen);
    HBRUSH hOldBrush = (HBRUSH)SelectObject(hdcPaint, brush);

    RoundRect(hdcPaint, 1, 1, 100, 100, 10, 10);

    SelectObject(hdcPaint, hOldPen);
    SelectObject(hdcPaint, hOldBrush);

    DeleteObject(pen);
    DeleteObject(brush);

    return TRUE;
}

But I get no visible results

EDIT 2:

Putting MessageBoxes in the different WM_* cases I can see the rectangles being painted and even after I have closed all the message boxes the rectangles are left on the screen. But if I don’t have any message boxes at all I can’t see the rectangles.

So I’m guessing something is redrawing the windows after I have painted on them. What is doing this redrawing, and where?

EDIT 3:

Cleaning up my code and keeping just WM_PAINT for the ThunderRT6Form window made it work. This is what WM_PAINT looks like now:

case WM_PAINT:
{
    PAINTSTRUCT ps;
    HDC hdcPaint = BeginPaint(Hwnd, &ps);
    HBRUSH brush = CreateSolidBrush(RGB(255, 255, 255));

    RECT r;
    GetClientRect(Hwnd, &r);
    FillRect(hdcPaint, &r, brush);

    DeleteObject(brush);
    EndPaint(Hwnd, &ps);

    return 0;
}

EDIT 4:

I never did find out exactly why the rectangles wouldn’t show up in my first tries. But it was some error in my code somewhere.

This is what I did: First I added message boxes to make sure all code was getting called. That made the rectangles appear. Then I fiddled around a bit with where I had the message boxes (only for the Form, only for the Frame, only for WM_PAINT etc). And I always got the rectangle. Then I removed all the message boxes, and sure enough, the rectangles went away too. So I added some message boxes back in and started cleaning up my code. Some of this “clean up” fixed my error, because after that I could remove all message boxes and still be able to paint on the background.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:21:08+00:00Added an answer on May 16, 2026 at 7:21 am

    You might see some success if you handle the WM_ERASEBKGND message similarly to the way you handle WM_PAINT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.