Jump to content
  • Advertisement
Sign in to follow this  
Rodaxoleaux

Updating a Window after sending WM_PAINT

This topic is 2639 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
The GetDC & ReleaseDC procedures let you paint where&when ever you want,

So, you are not restricted to paint|repaint only when WM_PAINT messages occur.
You can use some sort of timer mechanism ( &| other event triggers ) to update your view.

Share this post


Link to post
Share on other sites
I have no clue what you're talking about...

Maybe you should describe what you are doing, and optimally post your code?

Share this post


Link to post
Share on other sites
Basically, I'm creating a sort-of terminal window with user input for typing commands, etc. the current user-inputted data is stored in a string, and the string is drawn to the window as so in the message handling function:
LRESULT CALLBACK Messages(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
switch (Msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;

case WM_HOTKEY:
WindowState = !WindowState;
ToChangeWindow = true;
break;

case WM_PAINT:

hDC = GetDC(hwnd);
SetBkMode(hDC,TRANSPARENT);
SetTextColor(hDC,RGB(255,255,255));
TextOut(hDC,10,30,(LPSTR)currentCommand.c_str(),currentCommand.length());
ReleaseDC(hwnd,hDC);

break;

default:
return DefWindowProc(hwnd, Msg, wParam, lParam);
}

return 0;
}


I can type it just fine and it will output what I want, but when I delete a character from the string (Backspace), it deletes a character fine, but it doesn't update the window and instead draws behind the already outputted text.

Share this post


Link to post
Share on other sites
Didn't know that it just leaves the background. Thanks but it still produces the same result after changing to OPAQUE and setting the background color. What else could cause it? It always seems to work if I hide and reshow the window whenever backspace is pressed but... that seems rather inefficient..

Share this post


Link to post
Share on other sites
I tried sending WM_ERASEBKGND and using FillRect() but that doesn't help. Although honestly, since this is my first time working with Win32, I thought it did it itself.

case WM_PAINT:

hDC = GetDC(hwnd);
SetBkMode(hDC,OPAQUE);
SetBkColor(hDC,RGB(253, 208, 23));
SetTextColor(hDC,RGB(255,255,255));
TextOut(hDC,10,30,(LPSTR)currentCommand.c_str(),currentCommand.length());
ReleaseDC(hwnd,hDC);

RECT r;
GetWindowRect(hwnd,&r);

FillRect(hDC,&r,orangish);

break;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!