Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to scale when the window is bigger or smaller, How can I do? I draw a pie using cdc and drawitem

What I have tried:

I tried with onsize, but I don't know how I can use it
Posted
Updated 2-Dec-20 6:06am

In GUI code, a mapping mode is sometimes used to do this : SetMapMode function (wingdi.h) - Win32 apps | Microsoft Docs[^]. You can set the mapping mode so regardless of the actual window dimensions it looks the same to drawing code so if the window is bigger the drawing is scaled accordingly and automatically. I think it MM_ISOTROPIC or MM_ANISOTROPIC, I can't remember which. Further reading should clarify this.

FWIW, I haven't dealt with this issue in quite some time. I use GDI+ when I need to do this kind of thing and set a scale transform to handle it.
 
Share this answer
 
Comments
Richard MacCutchan 2-Dec-20 12:45pm    
"set a scale transform to handle it"
Something I have never quite managed to grasp. Sixty and more years ago mathematics seemed easy to understand. These days it takes me a lot of time to get my head round what should be pretty simple stuff.
Rick York 2-Dec-20 13:12pm    
It took me a while to get that too but graphics are one of my favorite things so I dug into it. What it boils down to is you can feed it points that range from say, -0.1 to 0.1 and then set a scale factor of 1000,1000 and they will be drawn as being from -100 to 100. It's really that simple. Also the scaling can be non-uniform or something like 500,1000 if you want ellipses to look more like circles.
Richard MacCutchan 3-Dec-20 4:09am    
Thanks, that sounds nice and logical; now I need to run some samples.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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