Simple WM_PAINT / Send message errror

Started by
1 comment, last by Drazgal 22 years, 4 months ago
I have this as my windows message handler
  
LRESULT CALLBACK TheWindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch(uMsg)
	{
		case WM_DESTROY:
			{
				PostQuitMessage(0);
				return(0);
			}break;
		case WM_PAINT:
			{
				PAINTSTRUCT ps;
				HDC hdc=BeginPaint(hwnd,&ps);
			
				if(AppMode == Text)
				{
					RECT Rect;
					GetClientRect(hWndMain,&Rect);
					HDC hdc = GetDC(hWndMain);
					FillRect(hdc,&Rect,(HBRUSH)GetStockObject(WHITE_BRUSH));
					ReleaseDC(hWndMain,hdc);
					TextFile.RunThroughFile(NewFont,OldFont,hWndMain);
				}
			
				EndPaint(hwnd,&ps);
				return(0);
			}break;
		case WM_COMMAND: 
			{
				switch(LOWORD(wParam))
				{
					case IDR_NEW: 
					{
						TextFile.NewFile();
						AppMode = Text;
						SendMessage(hWndMain,WM_PAINT,0,0);
					}break;
			
					case IDR_EXIT:
					{
						DestroyWindow(hWndMain); 
					}break;
				}
			}break;
		case WM_MOVE: 
		{
			MoveWindow(hWndMain,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYMAXIMIZED) - 6 * GetSystemMetrics(SM_CYBORDER),true);
		}break;
	}
	return(DefWindowProc(hwnd,uMsg,wParam,lParam));
}
  
The problem being that when the user clicks new on th menu the program should paint a white background across the application, I do this with an if stement checking if a new file is ment to be there then painting if it is. Everything there seems to be fine, the problem is when New is clicked I have used SendMessage, to tell the application to repaint, which then means it looks through sees it needs to draw the white rectangle then does so. Unfortunatly it doesnt, if I then do something to call the WM_PAINT like minimize then maximize then it does paint the white rectangle I need. So does anyone have an idea why the sendmessage isnt working? Thanks Ballistic Programs
Advertisement
Remember to invalidate the rectangle of the area you want to repaint (I believe it''s InvalidateRect or something like that), otherwise you won''t see any redraw.
Thanks for the quick reply, works now!

Ballistic Programs

This topic is closed to new replies.

Advertisement