Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Filling a Solid Rect

Filling a Solid Rect

Scheduled Pinned Locked Moved C / C++ / MFC
architecturehelpquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bret Faller home
    wrote on last edited by
    #1

    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

    M C J 3 Replies Last reply
    0
    • B Bret Faller home

      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

      M Offline
      M Offline
      Mike Nordell
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B Bret Faller home

        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

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #3

        check that nothing has set a clipping region on that DC (if you can) -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

        B 1 Reply Last reply
        0
        • C Chris Losinger

          check that nothing has set a clipping region on that DC (if you can) -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

          B Offline
          B Offline
          Bret Faller home
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • B Bret Faller home

            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

            J Offline
            J Offline
            Jon Hulatt
            wrote on last edited by
            #5

            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.

            B 1 Reply Last reply
            0
            • J Jon Hulatt

              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.

              B Offline
              B Offline
              Bret Faller
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups