Archived

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

Drazgal

Simple WM_PAINT / Send message errror

Recommended Posts

Drazgal    368
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

Share this post


Link to post
Share on other sites