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

  • SEARCH
  • Home
  • 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 7779915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:46:24+00:00 2026-06-01T18:46:24+00:00

In my attempt to create my own win32 wrapper I have come across this

  • 0

In my attempt to create my own win32 wrapper I have come across this problem.
Whenever I resize my window the background doesn’t get redrawn ( http://i44.tinypic.com/23k855.png white is supposed to be the background but when I make the window smaller it goes black)

Part of my class:

void Register(  tstring _className,
                    tstring _menuName,
                    WNDPROC w32proc,
                    tstring hIcon,
                    HICON hIconSmall,
                    LPCTSTR hCursor,
                    HBRUSH hBrush=(HBRUSH)GetStockObject(WHITE_BRUSH),
                    UINT windowStyle = CS_HREDRAW | CS_VREDRAW,
                    int classExtraBytes=NULL,
                    int windowExtraBytes=NULL
                    )
    {
        className = _className; 
        menuName = _menuName;

        wcex.cbSize         = sizeof(WNDCLASSEX);
        wcex.style          = windowStyle;
        wcex.lpfnWndProc    = w32proc;
        wcex.cbClsExtra     = classExtraBytes;
        wcex.cbWndExtra     = windowExtraBytes;
        wcex.hInstance      = this->hInst;
        wcex.hIcon          = LoadIcon(this->hInst,hIcon.c_str());
        wcex.hCursor        = LoadCursor(NULL,hCursor);
        wcex.hbrBackground  = hBrush;
        wcex.lpszMenuName   = this->menuName.c_str();
        wcex.lpszClassName  = this->className.c_str();
        wcex.hIconSm        = hIconSmall;

        RegisterClassEx(&wcex);
    }

    bool Create(tstring _windowTitle,
                DWORD windowStyle,
                int width=CW_USEDEFAULT,
                int height=CW_USEDEFAULT,
                int xPos=CW_USEDEFAULT,
                int yPos=CW_USEDEFAULT,
                HWND parent=NULL,
                LPVOID lpParam=NULL,
                HMENU menu=NULL
                )
        {
        windowTitle = _windowTitle;

        handle = CreateWindow(this->className.c_str(), this->windowTitle.c_str(), windowStyle,
                             xPos, yPos, width, height, parent, menu, this->hInst, lpParam);
        if (!this->handle)
            return false;

        Show();
        return true;
    }

    bool Show(int cmd=SW_SHOWNORMAL)
    {
        if( !ShowWindow(this->handle, cmd) || !UpdateWindow(this->handle) )
            return false;
        return true;
    }

my window proc:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

and how I’m using everything:

mainwin = new Window(hInstance);
mainwin->Register(TEXT("test"),TEXT("test"),WndProc,TEXT("small.ico"),NULL,IDC_ARROW,NULL,NULL,NULL);
mainwin->Create(TEXT("test window"),WS_OVERLAPPEDWINDOW );
mainwin->Show(nCmdShow);
while(mainwin->GetMsg() > 0)
    mainwin->TranslateDispatchMsg();

Some help would be very much appreciated 🙂

ps: I also tried handling WM_PAIN,WM_SIZE,WM_SIZING messages to call UpdateWindow and/or ShowWindow with no success

  • 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-06-01T18:46:27+00:00Added an answer on June 1, 2026 at 6:46 pm

    You are passing NULL to the hBrush parameter of Register. That’s why the background is not redrawn when you resize.

    I suspect you intended to make use of your optional parameters and calling it like this:

    mainwin->Register(TEXT("test"), TEXT("test"), WndProc, TEXT("small.ico"),
        NULL, IDC_ARROW);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found only one attempt to create such compiler - http://sourceforge.net/projects/xsltc/ . But this
This is my first attempt to create a GUI in MATLAB. I haven't been
I'm trying to create a simple threading procedure (granted this is my first attempt
I've decided to take the advice in this question: create-excel-chart-programmatically-in-php and NOT attempt to
this is my first attemp to create a frontController and I've come over some
My problem is this: I want to create a grails domain instance, defining the
I have this set of codes to create a simple before and after image
I am trying to create my own HTML element that looks like this: The
I made my first attempt here to create my own webpage.. But what can
I have a Django SaaS app with users who create their own Jinja2 templates

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.