Click here to Skip to main content
15,892,161 members

GetWindowExt returns cx = 1 and cy = 1

fd9750 asked:

Open original thread
Hi,

I have this bit of code to draw, for testing purposes, a line in a picture control (ID = IDC_GRAPH_D_GRAPH) located in a dialog box:

C++
void CGraphDlg::ShowGraph(void)
{
	m_iCount++;
	CPaintDC dc (GetDlgItem(IDC_GRAPH_D_GRAPH));
	CSize cs = dc.GetWindoxExt();
	CPen lpen(PS_SOLID, 1, RGB(255, 0, 0));
	dc.SelectObject(&lpen);
	dc.LineTo(100,m_iCount);
}


It works OK because it does draw the line as expected in the picture control so the declaration of dc and the link from it to the picture control in question clearly works.

Oddly enough though the member function "GetWindowExt" of "CClientDC dc" always returns a CSize with values cx = 1 and cy = 1 while the actual picture control size is several hundred pixels each way.
I am not using cx and cy for now but I would like to.

Obviously I must be missing something, anybody have an idea what it might be?

I am using: Visual studio 2010, and its a very basic MFC dialog box application.

Any help much appreciated.
Tags: C++, MFC, Visual Studio 2010

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900