0

I have an MFC MDI application. In order to place some controls in the view (MyView derived from CView), I need to know the size of the client area of the view. I will be using dimensions based on the client area's size in the Create function for the control.

When I use MyView.GetClientRect(), I get 1154 x 466. But the actual client size in pixels is 1410 x 725, as measured using both Spy++, and Paint on a screen shot.

How do get the size in pixels of the client area?

C++, Visual Studio 2010, 64-bit Windows 7 Pro

Woody20
  • 791
  • 11
  • 30
  • Are you playing with dpi in your application? – Flot2011 Jan 18 '13 at 08:37
  • No. DPI is the Windows 7 default, and I'm not doing anything with it. – Woody20 Jan 18 '13 at 17:33
  • Do your view has a frame? – Flot2011 Jan 18 '13 at 17:39
  • As I said, it is an MFC MDI application. That means there is a main frame window, and multiple child windows, containing the view(s). – Woody20 Jan 18 '13 at 19:23
  • Please post a screenshot. We rely on GetClientRect all the time without any problems. – snowdude Jan 18 '13 at 21:03
  • GetClientRect works fine in most situations; maybe the MDI child window is not the same as the view. – Woody20 Jan 18 '13 at 23:10
  • My question was, if the style of your child windows does include WS_BORDER or something of the kind – Flot2011 Jan 19 '13 at 10:04
  • Styles are WS_CHILDWINDOW, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN. Extended styles WS_EX_LEFT, WS_EX_LTREADING, WS_EX_RIGHTSCROLLBAR, WS_EX_CLIENTEDGE. – Woody20 Jan 19 '13 at 17:51
  • 1
    it depends when you are trying to call this. If you are calling it in OnInitialUpdate(), or OnCreate(), the MyView might not be maximised by the frame and have an initial size you have used when created the view. Try to call it after the view has been displayed and see if it works – cha Jan 21 '13 at 04:03

0 Answers0