CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Oct 2012
    Posts
    3

    Groupbox keeps not repaint itselfs on window resizing

    I have written a program in which I have 2 splitters and 3 controls (subwindows). While resizing splitter (window) in which groupox is contained, groupbox does not repaint its frames ( I think so). What do I wrongly?

    Code:
    	case WM_SIZE:
    		{
    		if (info == NULL)
    			break;
    
    		if (info->horizontal)
    		{
    		/* 
    		   If window is shrunk so that splitter now lies outside the 
    		   window boundaries, move the splitter within the window.
    		*/
    		
    		if ((wParam != SIZE_MINIMIZED) && (HIWORD(lParam) < info->dwSplitterPos))
    			info->dwSplitterPos = HIWORD(lParam) - 10;
    		
    
    		/* Adjust the children's size and position */
    		
    		MoveWindow(info->hWnd1, 0, 0, LOWORD(lParam), info->dwSplitterPos - 1, TRUE);
    		MoveWindow(info->hWnd2, 0, info->dwSplitterPos+2, LOWORD(lParam) , HIWORD(lParam) - info->dwSplitterPos - 2, TRUE);
    		
    		}
    		else
    		{
    
    			if ((wParam != SIZE_MINIMIZED) && (LOWORD(lParam) < info->dwSplitterPos))
    				info->dwSplitterPos = LOWORD(lParam) - 10;
    
    			
    			MoveWindow(info->hWnd1, 0, 0, info->dwSplitterPos - 1, HIWORD(lParam), TRUE);
    			MoveWindow(info->hWnd2, info->dwSplitterPos+2, 0, LOWORD(lParam) - info->dwSplitterPos - 2, HIWORD(lParam) , TRUE);
    		}
    
    		InvalidateRect(hWnd, NULL, TRUE);
    		UpdateWindow(hWnd);
    
    		return 0;
    		}
    And creation of groupbox and splitters
    Code:
    	case WM_CREATE:
    		{
    			
    			InitCommonControls();
    		
    		HWND hWnd1 = CreateWindowEx( WS_EX_CLIENTEDGE,
    					L"button", L"Dane",  
    					WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 
    					0, 0, 0, 0, 
    					hWnd, (HMENU) 1,
    					hInst, NULL );
    
    		oldGroubox = (WNDPROC)GetWindowLongPtr(hWnd1, GWL_WNDPROC);
    		SetWindowLongPtr(hWnd1, GWL_WNDPROC, (LONG_PTR)GroupboxWndProc);
    
    		hWnd2 = CreateWindowEx(0, L"button", NULL, WS_CHILD | WS_VISIBLE , 5, 5, 150, 200,
    			hWnd, NULL, hInst, NULL);
    		LRESULT CALLBACK GroupboxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    		HWND hwndlog = CreateWindowEx(0, L"listbox", 0, WS_CHILD | LBS_NOINTEGRALHEIGHT
    			
    			| WS_VISIBLE  , 0, 0, 0, 0,
    		hWnd2, NULL, hInst, NULL);
    
    
    
    		HWND hWnd3 = CreateWindowEx( WS_EX_CLIENTEDGE,
    					L"listbox", NULL,  
    					WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL,
    					0, 0, 0, 0, 
    					hWnd, (HMENU) 3,
    					hInst, NULL );		
    
    		SendMessage(hWnd3, LB_ADDSTRING, 0, (LPARAM)L"Element 1");
    
    		
    
    		InitializeSplitter(hInst);
    
    		HBRUSH rec = CreateSolidBrush(RGB(255, 0, 0));
    		HBRUSH blue = CreateSolidBrush(RGB(0, 0,255));
    		splitter = CreateSplitterWindow(hInst, hWnd1, hWnd2, L"splitter", rec, TRUE);
    		splitter2 = CreateSplitterWindow(hInst, hWnd3, splitter, L"splitter2", blue, FALSE);
    		SetParent(splitter2, hWnd);
    		UpdateWindow(splitter);
    		UpdateWindow(splitter2);
    		ShowWindow(splitter2, TRUE);
    			
    		Log(L"Utworzono");
    Whole project
    grafika.zip

    --EDIT-- After covering window and uncovering window repaints correctly (maximizing and minimizing windows make the window to repaint itself also).
    Incorrect drawing means the window leaves grayish unpainted mix of colors within the new added space (by moving splitter)
    Last edited by duga; October 31st, 2012 at 04:59 PM. Reason: Some details added

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured