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. How to get the width and height of a window? (MFC)

How to get the width and height of a window? (MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I wanna know the width and height of a window in pixels!? How to? / |------ \

    P M B J 4 Replies Last reply
    0
    • L Lost User

      I wanna know the width and height of a window in pixels!? How to? / |------ \

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      Client area -> GetClientRect() whole window (borders, caption) -> GetWindowRect() --- Blessed are those who can laugh at themselves, for they shall never cease to be amused :laugh:

      1 Reply Last reply
      0
      • L Lost User

        I wanna know the width and height of a window in pixels!? How to? / |------ \

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        CRect rc;

        cwnd.GetClientRect ( &rc );

        rc.right is the width, and rc.bottom is the height. --Mike-- http://home.inreach.com/mdunn/ "....." -- Silent Bob :love: your :bob: with :vegemite: and :beer:

        1 Reply Last reply
        0
        • L Lost User

          I wanna know the width and height of a window in pixels!? How to? / |------ \

          B Offline
          B Offline
          Braulio Dez
          wrote on last edited by
          #4

          Normally GetClienRect() would work fine, if it doesn´t give you the size in pixels you have to change the viewport HTH Braulio

          1 Reply Last reply
          0
          • L Lost User

            I wanna know the width and height of a window in pixels!? How to? / |------ \

            J Offline
            J Offline
            JerzyPeter
            wrote on last edited by
            #5

            CRect rect; GetWindowRect(&rect); int nWidth=rect.Width(); int nHeight=rect.Height(); Jerzy

            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