Thread: Not updating window until I resize it!

  1. #1
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Not updating window until I resize it!

    I have an menu option that has 2 radio buttons when I select either one I want it to redraw the client area, but it doesn't until I resize the window.

    I've listed what I believe to be the relevant code below. I am assuming that I have made some simple error in my dialog callback!

    Code:
    case WM_SIZE:
    		cxClient = LOWORD (lParam);
    		cyClient = HIWORD (lParam);
    		
    		//	return 0;  Want it to fall thru...
    
    case WM_PAINT:	// The window needs to be redrawn.
    		{
    			hdc = BeginPaint (hwnd, &ps) ;
    			SetMapMode(hdc, MM_TWIPS);
    			
    			///////////////////////////////////////
    			// Begin centering output on screen. //
    
    // Lots of stuff here...
    
    		  if(bDisplayCoords)  // check buttons in Menu Options.
    		  {
    			///// do stuff //////
    		  }
    
              EndPaint (hwnd, &ps) ;
              return 0 ;
    	}
    
    
    
    
    
    
    
    BOOL CALLBACK DisplayPropProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    	switch (Message)
    	{
    	case WM_INITDIALOG:
    		//**************************************************************************
    		// Do I want to allow no options checked?
    		// Need to rezoom depending upon selection.
    		// ...therefore need to recalc min max for each option.
    		// ...Send a paint message to redraw picture.
    
    		// Set default radio button.
    		if(bDisplayCoords)
    		{
    			hdlg = GetDlgItem(hwnd, IDC_DISPLAY_COORDINATES );
    			SendMessage(hdlg, BM_SETCHECK, 1,0);
    		}
    		else
    			{
    			hdlg = GetDlgItem(hwnd, IDC_LENGTHSANGLES );
    			SendMessage(hdlg, BM_SETCHECK, 1,0);
    		}
    			//if(SendMessage(GetDlgItem(hwnd, IDC_LENGTHSANGLES ), BM_GETCHECK, (WPARAM)0 ,(LPARAM)0) == BST_CHECKED)
    		return TRUE;
    	case WM_COMMAND:
    		switch (LOWORD(wParam))
    		{
    		case IDOK:
    			if(SendMessage(GetDlgItem(hwnd, IDC_DISPLAY_COORDINATES ), BM_GETCHECK, (WPARAM)0 ,(LPARAM)1) == BST_CHECKED)
    			{
    				bDisplayCoords = true;
    				InvalidateRect(hwnd, NULL, true);
    				UpdateWindow (hwnd);
    			}
    			if(SendMessage(GetDlgItem(hwnd, IDC_LENGTHSANGLES ), BM_GETCHECK, (WPARAM)0 ,(LPARAM)0) == BST_CHECKED)
    			{
    				bDisplayCoords = false;
    			}
    			EndDialog(hwnd, IDOK);
    			break;
    		case IDCANCEL:
    			MessageBeep (0);
    			EndDialog(hwnd, IDCANCEL);
    			break;
    			}
    		default:
    			return FALSE;
    	}
    	return true;
    }

    What am I doing incorrectly?
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    make sure you're using the correct hwnd. In your code it appears that you're using the handle from the current proc, I'm not sure if that's what you intended or not?

    -edit-
    if that doesn't work, just try sending a WM_PAINT message yourself to manually call it

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I think it is the empty update rect.
    Check the help on InvalidateRect()

    in the paint handler before BeginPaint(), use GetUpdateRect(), check if it is empty with IsRectEmpty() and if so fill with GetClientRect().
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    when you pass NULL to invalidate rect, it resets the entire rectangle as far as i know. I've always passed NULL when i want the whole window/control to redraw

    -from msdn-
    lpRect [in] Pointer to a RECT structure that contains the client coordinates of the rectangle to be added to the update region. If this parameter is NULL, the entire client area is added to the update region.

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Sorry, did not have my complier.

    It is UpdateWindow() that won't send the paint message if there is no update area.



    Is the callback DisplayPropProc() for the dialog you want repainted?

    It is the dialog you are calling to be painted but the code for the paint is somewhere else.

    If it is not then change the HWND as previously suggested to the correct dialogs in both the InvalidateRect() and UpdateWindow()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    Thanks everyone for the replies. When I get done fixing my buddies pc. I'll give your suggestions a try.
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM