Filling a Solid Rect
-
Good day, Why would this not fill the complete rectangle specified by rcHighlight? this is for a Multiline(per item) ListCtrl and in the DrawItem function. CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc); rcHighlight.left += 1; rcHighlight.top += 1; rcHighlight.right -= 1; rcHighlight.bottom = rc.bottom - 1; if (lpDrawItemStruct->itemState & ODS_SELECTED) { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_HIGHLIGHT)); pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)) ; } else { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_WINDOW)); pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ; } I've verified that the rectangle is the correct rect and size but yet FillSolidRect only fills half of it. Any help is greatly appreciated. Bret Faller, Off-Duty programmer
-
Good day, Why would this not fill the complete rectangle specified by rcHighlight? this is for a Multiline(per item) ListCtrl and in the DrawItem function. CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc); rcHighlight.left += 1; rcHighlight.top += 1; rcHighlight.right -= 1; rcHighlight.bottom = rc.bottom - 1; if (lpDrawItemStruct->itemState & ODS_SELECTED) { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_HIGHLIGHT)); pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)) ; } else { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_WINDOW)); pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ; } I've verified that the rectangle is the correct rect and size but yet FillSolidRect only fills half of it. Any help is greatly appreciated. Bret Faller, Off-Duty programmer
You often have to add +1 to right and bottom. Also, line drawing does never include the last coordinate. Takes some to get used to.
-
Good day, Why would this not fill the complete rectangle specified by rcHighlight? this is for a Multiline(per item) ListCtrl and in the DrawItem function. CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc); rcHighlight.left += 1; rcHighlight.top += 1; rcHighlight.right -= 1; rcHighlight.bottom = rc.bottom - 1; if (lpDrawItemStruct->itemState & ODS_SELECTED) { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_HIGHLIGHT)); pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)) ; } else { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_WINDOW)); pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ; } I've verified that the rectangle is the correct rect and size but yet FillSolidRect only fills half of it. Any help is greatly appreciated. Bret Faller, Off-Duty programmer
check that nothing has set a clipping region on that DC (if you can) -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
-
check that nothing has set a clipping region on that DC (if you can) -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
Thanks for your response...how might I go about checking if something else has set the clipping region? I've looked into somem of the clipping functions but I'm actually not to familiar with the CDC. Thanks again for your response. Bret Faller, Off-Duty programmer
-
Good day, Why would this not fill the complete rectangle specified by rcHighlight? this is for a Multiline(per item) ListCtrl and in the DrawItem function. CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc); rcHighlight.left += 1; rcHighlight.top += 1; rcHighlight.right -= 1; rcHighlight.bottom = rc.bottom - 1; if (lpDrawItemStruct->itemState & ODS_SELECTED) { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_HIGHLIGHT)); pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)) ; } else { pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_WINDOW)); pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ; } I've verified that the rectangle is the correct rect and size but yet FillSolidRect only fills half of it. Any help is greatly appreciated. Bret Faller, Off-Duty programmer
I might be barking up the wrong tree in the wrong forest here, but:
CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc);
rcHighlight.left += 1;
rcHighlight.top += 1;
rcHighlight.right -= 1;
rcHighlight.bottom = rc.bottom - 1;Looking at the prototype for the GetItemRect Function:
int GetItemRect( int nIndex, LPRECT lpRect ) const;
The return value is just a status code. lpRect is where the rect comes in. But, your code uses a CRect rcHighlight for a return value ?!?! and you adjust it's size a little, and then draw it. Also, the fourth line of your code sets rcHighlight.bottom to rc.bottom, whereas the others just adjust the size of the incorrectly filled CRect object. I don't know, maybe you just mistyped the code into the discussion forum? Jon Sorry to dissapoint you all with my lack of a witty or poignant signature.
-
I might be barking up the wrong tree in the wrong forest here, but:
CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc);
rcHighlight.left += 1;
rcHighlight.top += 1;
rcHighlight.right -= 1;
rcHighlight.bottom = rc.bottom - 1;Looking at the prototype for the GetItemRect Function:
int GetItemRect( int nIndex, LPRECT lpRect ) const;
The return value is just a status code. lpRect is where the rect comes in. But, your code uses a CRect rcHighlight for a return value ?!?! and you adjust it's size a little, and then draw it. Also, the fourth line of your code sets rcHighlight.bottom to rc.bottom, whereas the others just adjust the size of the incorrectly filled CRect object. I don't know, maybe you just mistyped the code into the discussion forum? Jon Sorry to dissapoint you all with my lack of a witty or poignant signature.
Actually its my own custom GetItemRect function because this is for a multiline ListCtrl that I am making and it determines the size of the row based on how many lines of text the biggest subitem has. It takes the itemid and the original rect of the item which comes from the DRAWITEMSTRUCT in my DrawItem function and then it inflates it based on how many lines of text are in the biggest subitem. Thanks for your response though. Bret Faller Odyssey Computing, Inc.