c++mfccdccpropertysheet

How to get the visible client rect of a CPropertySheet object?


I'm trying to change some colors of my MFC CPropertySheet object. I'm able to change the color of all regions I want. However, there's still one region I can't control. Here is an image of what I'm getting with my code.

enter image description here

As you can see, I can draw one thin border over the top and left margins using the code below.

void CEasyPropertySheet::Draw_Borders(CDC* pDC)
{
    // I check how many lines of tabs the control has.
    CTabCtrl* pTab = this->GetTabControl();
    int lines = pTab->GetRowCount();

    // I get the rect I want to define the borders of the control.
    CRect rect; this->GetClientRect(rect);
    pDC->FillSolidRect(rect, GENERIC_BACKGROUND_COLOR);

    // I draw the border in 2 steps. First of all I fill one rect with the border color.
    // After that, I deflect the rect and I filled again using the background color I want.
    rect.DeflateRect(0, 19 * lines, 0, 0);  
    pDC->FillSolidRect(rect, GENERIC_BORDER_COLOR);
    rect.DeflateRect(1, 1);
    pDC->FillSolidRect(rect, PROPERTYPAGE_BACKGROUND_COLOR);
}

However, I can't use the same method to draw the others (bottom and right borders). I think that the rectangle I'm using is bigger than the one showed on the screen but I don't know what to do to get that rectangle.

Does anybody knows what to do?


Solution

  • Well. After trying a couple of things (including things that doesn't make sense) I finally found the answer I was looking for. All what I have to do is to get a different rectangle. Here is the code that works:

    void CEasyPropertySheet::Draw_Borders(CDC* pDC)
    {
        // I check how many lines of tabs has the controls.
        CTabCtrl* pTab = this->GetTabControl();
        int lines = pTab->GetRowCount();
    
        // I get the rect I want to define the borders of the control.
        CRect rect;
        pTab->GetClientRect(rect);
        pDC->FillSolidRect(rect, GENERIC_BACKGROUND_COLOR);
    
        // I draw the border in 2 steps. First of all I fill one rect with the border color.
        // After that, I deflect the rect and I filled again using the background color I want.
        rect.DeflateRect(0, 19 * lines, 0, 0);
        pDC->FillSolidRect(rect, GENERIC_BORDER_COLOR);
        rect.DeflateRect(1, 1);
        pDC->FillSolidRect(rect, PROPERTYPAGE_BACKGROUND_COLOR);
    }
    

    I was getting the rectangle of the whole CPropertySheet and that was the mistake. What I have to do is to get the rectangle of the CTabCtrl. Here is the result:

    Code result