Jump to content
  • Advertisement

Archived

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

Drazgal

Simple WM_PAINT / Send message errror

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

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
Advertisement

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!