none
How to set the property sheet inactive border color RRS feed

  • Question

  • Dear Sir,

        I am trying to set the property sheet border color. If I change the color corrresponding to one of COLOR_3DFACE or COLOR_INACTIVEBORDER(i am not ure which of the two) then the desired element color changes with the undesired side effect of changing all the window colors on the system. I have tried OnCtlColor with no luck. I have allready googled on the subject and have not found an answer.

    Regards,

    Ramesh D.



    • Edited by rameshdk Saturday, August 17, 2019 2:20 PM
    Friday, August 16, 2019 4:06 PM

Answers

All replies

  • Hi,

    Thank you for posting here.

    >>How to set the property sheet inactive border color?

    I suggest you could try to overload the default message handler and then redraw border.

    LRESULT CPropPage1::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
    	// TODO: Add your specialized code here and/or call the base class
    	LRESULT lrst = CDialog::DefWindowProc(message, wParam, lParam);
    
    	if (!::IsWindow(m_hWnd))
    		return lrst;
    
    	if (message == WM_MOVE || message == WM_PAINT || message == WM_NCPAINT || message == WM_NCACTIVATE || message == WM_NOTIFY)
    	{
    		CDC* pWinDC = GetWindowDC();
    		if (pWinDC)
    			DrawBorder(pWinDC);
    		ReleaseDC(pWinDC);
    	}
    	return lrst;
    
    	return CPropertyPage::DefWindowProc(message, wParam, lParam);
    }
    
    void CPropPage1::DrawBorder(CDC *pDC)
    {
    	if (m_hWnd)
    	{
    		CBrush Brush(RGB(255, 0, 0));
    		CBrush* pOldBrush = pDC->SelectObject(&Brush);
    
    		CRect rtWnd;
    		GetWindowRect(&rtWnd);
    
    		CPoint point;
    
    		point.x = rtWnd.Width();
    		point.y = GetSystemMetrics(SM_CYFRAME) + 1;
    		pDC->PatBlt(0, 0, point.x, point.y, PATCOPY);
    
    		point.x = GetSystemMetrics(SM_CXFRAME);
    		point.y = rtWnd.Height();
    		pDC->PatBlt(0, 0, point.x, point.y, PATCOPY);
    
    		point.x = rtWnd.Width();
    		point.y = GetSystemMetrics(SM_CYFRAME) + 1;
    		pDC->PatBlt(0, rtWnd.Height() - point.y, point.x, point.y, PATCOPY);
    
    		point.x = GetSystemMetrics(SM_CXFRAME);
    		point.y = rtWnd.Height();
    		pDC->PatBlt(rtWnd.Width() - point.x, 0, point.x, point.y, PATCOPY);
    	}
    }

    Best Regards,

    Jeanine Zhang

    Monday, August 19, 2019 9:50 AM
    Moderator
  • Thanks for your reply.

    I have a correction to make.The system color that I am trying to change is COLOR_3DFACE it is the area next to the tab controls and around the property sheet.How can I get the region correspoonding to this area. The code given by you would be different in that case. I guess. Sorry for the inconvenience caused.

    Regards,

    Ramesh D


    • Edited by rameshdk Tuesday, August 20, 2019 3:20 PM
    Tuesday, August 20, 2019 7:33 AM
  • Hi,

    A Property Sheet is a Tab Control with Dialog Boxes.I suggest you could try to use WM_PAINT to draws a border around the display area (unless the TCS_BUTTONS style is specified) and paints any tabs that intersect the invalid rectangle. For each tab, it draws the body of the tab (or sends a WM_DRAWITEM message to the parent window) and then draws a border around the tab. 

    For more details I suggest you could refer to the links:
    https://docs.microsoft.com/en-us/windows/win32/controls/tab-controls
    https://docs.microsoft.com/windows/desktop/gdi/wm-paint

    Best Regards,

    Jeanine Zhang

    Wednesday, August 21, 2019 2:28 AM
    Moderator
  • Hi,

    Thanks for the code and links.

    The area I am trying to change color is next to all the tab controls and small area around.It is not the tab controls itself. It also happens to be the area corresponding to COLOR_3DFACE system color.

    The code you have given is for the COLOR_INACTIVEBORDER which has to be changed.I have no idea how to get the coordinates of this area(region) so that I can paint it.

    Thank You,

    Regards,

    Ramesh D.



    • Edited by rameshdk Thursday, August 22, 2019 6:45 AM
    Thursday, August 22, 2019 6:34 AM
  • The area I am trying to change color is next to all the tab controls and small area around.It is not the tab controls itself. It also happens to be the area corresponding to COLOR_3DFACE system color.



    Well,

    you have posted this task here too: https://social.msdn.microsoft.com/Forums/en-US/bc4420de-06e2-4f07-a75e-67c38b146726/property-sheet-color?forum=vcgeneral

    There is an answer already too. Still I don't know why you set this post here as a question and the other post as a discussion. You can close both posts because your question is answerd.

    Regards, Guido

    Thursday, August 22, 2019 6:55 AM
  • I had not got a reply for three days so I started a discussion on the same topic.

    Thanks for all your replies. I will pursue further in the other post .

    Regards,

    Ramesh D.

    Thursday, August 22, 2019 7:25 AM
  • The question has been answererd.

    Thank you,

    Regards,

    Ramesh D.

    • Marked as answer by rameshdk Wednesday, September 4, 2019 6:27 AM
    Wednesday, September 4, 2019 6:27 AM
  • The question has been answererd.

    Thank you,

    Regards,

    Ramesh D.

    You mark your answer as the answer to your question. What is the answer? Did the discussion help you get the answer? Then insert the link to the discussion please. If someone in the future has the same problem, then he can read the answer in the discussion.
    Wednesday, September 4, 2019 6:33 AM