Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

peter86

The window isn´t repainted immediately

This topic is 6017 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

The window isn´t repainted until I move the dialogbox that i have, when I´ve pressed redraw. Anyone know why?
     
// In DialogProc() 

case IDREDRAW:
{
	char cText[256];
	HWND hWndRed, hWndGreen, hWndBlue;

	hWndRed		= GetDlgItem(hWndDlg, IDC_RED);
	hWndGreen	= GetDlgItem(hWndDlg, IDC_GREEN);
	hWndBlue	= GetDlgItem(hWndDlg, IDC_BLUE);

	GetWindowText(hWndRed, cText, sizeof(cText));
	g_color.r = atoi(cText);
	GetWindowText(hWndGreen, cText, sizeof(cText));
	g_color.g = atoi(cText);
	GetWindowText(hWndBlue, cText, sizeof(cText));
	g_color.b = atoi(cText);

	InvalidateRect(g_hWndMain, NULL, true);
	}

// In WindowProc()

case WM_PAINT:
{
	HDC hdc = GetDC(hWnd);

	HBRUSH brush	= CreateSolidBrush(RGB(g_color.r, g_color.g, g_color.b));
	HBRUSH oldBrush	= (HBRUSH)SelectObject(hdc, brush);

	// Time to draw

	Rectangle(hdc, 0, 0, 400, 350);

	// Now restore and delete

	SelectObject(hdc, oldBrush);
	DeleteObject(brush);
	break;
}
    
[edited by - peter86 on June 28, 2002 1:47:17 PM]

Share this post


Link to post
Share on other sites
Advertisement
Try:

RedrawWindow(g_hWndMain, NULL, NULL, RDW_ERASE | RDW_INVALIDATE);

...and see if that works.

Share this post


Link to post
Share on other sites
quote:
Original post by -Thork-
Try:

RedrawWindow(g_hWndMain, NULL, NULL, RDW_ERASE | RDW_INVALIDATE);

...and see if that works.


I get the same problem

Share this post


Link to post
Share on other sites
Assuming that the Redraw button is on a modal dialog, then the main window won''t redraw until it is moved as the message loop for the main window stops whilst a modal dialog is displayed. Therefore, the WM_PAINT message isn''t received straight away...

Share this post


Link to post
Share on other sites
quote:
Original post by -Thork-
Assuming that the Redraw button is on a modal dialog, then the main window won''t redraw until it is moved as the message loop for the main window stops whilst a modal dialog is displayed. Therefore, the WM_PAINT message isn''t received straight away...


It´s a modeless one!

Share this post


Link to post
Share on other sites
Maybe it´s this - should I set WNDCLASSEX::hbrBackground to NULL when I´m going to paint in the window?

[edited by - peter86 on June 28, 2002 3:20:55 PM]

Share this post


Link to post
Share on other sites

  • 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!