Solved

Dialog Controls not drawing with correct aspect ratio in Visual Studio 6.0 C++:

Posted on 2010-11-22
4
480 Views
Last Modified: 2012-05-10
I'm using VC6.0.  When I put some controls on a dialog (such as buttons, listboxes, etc), I want them to be square in shape.  For example, 40 x 40.  While using the resource editor, in the very bottom right corner of Visual Studio, the size of my selected controls displays.  But even when the numbers say 40 x 40, the control itself draws as a rectangle, being taller than it is wide.  This even happens in design time. So the control that I want to be 40 x 40 is drawn as if it's actually about 30 x 40.

Any idea why this occurs, or how to fix this (other than simply figuring out the "scale" and adjusting the size of my controls accordingly?

Thanks a bunch.
0
Comment
Question by:cjm20
  • 2
  • 2
4 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34191353
You talk about during design - when the app runs is it OK ?
0
 

Author Comment

by:cjm20
ID: 34191400

No.  Same issue at run time.  The controls are drawn taller than they are wide.  This happens on numerous monitors, btw.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 34205729
I suspect you are running into  a problem that the dialog editor doesn't use pixels but an arbitrary unit based on the average width and height of characters in the font the dialog is using.

For  more info look at GetDialogBaseUnit and MapDialogRect in the help files.

If they do need to be square you might have to resize them at runtime - look at SetWindowPos and MoveWindow in help.  (I like SetWindowPos because the flags allow you to just resize it without moving it if that is all you require).
0
 

Author Comment

by:cjm20
ID: 34258420
You are correct.  Ultimately resizing at runtime is what I've settled upon.   It's too bad (at the least VC6.0) can't use a 1:1 aspect ratio for controls in its resource editor.  You'd think that would be the most intuitive way to go about it.  Oh well.  Thanks for the help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now