#Windows.h help with WM_PAINT

22 messages · Page 1 of 1 (latest)

ivory harbor
#

language is c, im having trouble with the `WM_PAINT.
case WM_PAINT:
{
PAINTSTRUCT ps;

        HDC hdc = BeginPaint(hwnd, &ps);
        FillRect(hdc, &ps.rcPaint, (COLOR_WINDOW+1));

        RECT r1 = mr(0, 0, 1000, 1000);
        FillRect(hdc, &r1, (HBRUSH) RGB(255, 0, 0));
        EndPaint(hwnd, &ps);
    }

`
im trying to get it to draw a red rectangle but i dont see it.

`if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
MSG msg;
ZeroMemory(&msg, sizeof(MSG));
while (GetMessage(&msg, NULL, 0, 0) > 0)
{

    TranslateMessage(&msg);
    DispatchMessage(&msg);
}

}`
msg system^

the window shows, WM PAINT is called, but FILLRECT is where it seems to not do anything so i think i might of typed it out wrong?

either way idk what to do

native plumeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

ivory harbor
#

Windows.h help with WM_PAINT

native plumeBOT
#
How to Format Code on Discord
Markup

```cpp
int main() {}
```

Result
int main() {}
rain mural
#

that might be what you are missing

#

or no, that might be reverse ;)

#

that may cause wm_paint to be called, long time since I played with win api

#

it doesn't seem you can use RGB as HBRUSH

#

i.e. that you would need to create brush first

#

(I'm looking into windows api docs live, so I may be talking bs)

#

but I would try to use CreateSolidBrush first in your app, saving the handle, and then using that hande for FillRect

ivory harbor
#

i do remember trying createsolidbrush

#

also what is invalidaterect

#

also would it be FillRect(hdc, &r1, createsolidbrush...); and how would i add the color to create solid brush?

rain mural
#

no, you would rather create brush once

#

outside of WM_PAINT

#

and then use it here

ivory harbor
#

interesting ill try that

#

thank you so much

native plumeBOT
#

@ivory harbor Has your question been resolved? If so, type !solved :)

ivory harbor
#

!solved