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. CRect::Width() and CRect::NormalizeRect()

CRect::Width() and CRect::NormalizeRect()

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
2 Posts 2 Posters 1 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.
  • G Offline
    G Offline
    Geert Delmeiren
    wrote on last edited by
    #1

    Before asking Chris to add this one as a 'bug' in MSDN, maybe someone can shed a light on the following. In MSDN for CRect::Width() I read: Calculates the width of CRect by subtracting the left value from the right value. The width can be negative I read something analog for CRect::Height(): Calculates the height of CRect by subtracting the top value from the bottom value. The resulting value can be negative. And in a note for both: The rectangle must be normalized or this function may fail. You can call NormalizeRect to normalize the rectangle before calling this function. While I read for CRect::NormalizeRect(): Normalizes CRect so that both the height and width are positive. Then is my question: "How can the result of CRect::Width() or CRect::Height() be negative if you must normalize it first?

    T 1 Reply Last reply
    0
    • G Geert Delmeiren

      Before asking Chris to add this one as a 'bug' in MSDN, maybe someone can shed a light on the following. In MSDN for CRect::Width() I read: Calculates the width of CRect by subtracting the left value from the right value. The width can be negative I read something analog for CRect::Height(): Calculates the height of CRect by subtracting the top value from the bottom value. The resulting value can be negative. And in a note for both: The rectangle must be normalized or this function may fail. You can call NormalizeRect to normalize the rectangle before calling this function. While I read for CRect::NormalizeRect(): Normalizes CRect so that both the height and width are positive. Then is my question: "How can the result of CRect::Width() or CRect::Height() be negative if you must normalize it first?

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Use the source, Luke ... :-D From afxwin1.inl (VC6):

      _AFXWIN_INLINE int CRect::Width() const
      { return right - left; }
      _AFXWIN_INLINE int CRect::Height() const
      { return bottom - top; }

      These function can't fail, unless MSDN means returning negative value by failure. Tomasz Sowinski -- http://www.shooltz.com

      - It's for protection
      - Protection from what? Zee Germans?

      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