Click to See Complete Forum and Search --> : How to add zoom?


pui_kay
May 27th, 1999, 06:14 AM
I am now doing a project that need to provide zoom view with different percentage...
Can anyone help me in solving this problem?
I am new to Visual C++ , so don't know those function provide by it.
Thanks in advance

May 27th, 1999, 10:27 AM
Before performing any kind out text drawing routine, select in a font that is
sized according to some zoom factor. You will need to ensure to create the
fonts before painting, select the fonts into the device context, perform the
necessary text drawing, restore the previous font into the device context and
finally delete the font previously created. When you create the font, size it
to some zoom factor that the user has control over. For any bitmaps, you will
need to scale them using this zoom factor as well.

If you have used the MFC Doc/View architecture and all of your painting/drawing
occurs within some view's OnDraw(), it shouldn't be too difficult.

Xexi
May 29th, 1999, 12:51 PM
If you perform all your drawing in the OnDraw() function, all you need to do is set values to SetWindowExt() and SetViewportExt() in your OnPrepareDC().

For intance, if you set a value of SetWindowExt(100, 100) and SetViewportExt(100, 100) also, you get a 100% zoom. All you need to do then, is to keep SetWindowExt(100, 100) and change SetViewportExt(75, 75) to get a 75% zoom. See? you have to combine values with these functions to scale to whatever value you want.

This is independent from the values you have assigned to your view with functions like SetScrollSizes() or SetScaleToFitSize() during window construction. The combination of values in SetWindowExt() and SetViewportExt() just make your pixels look bigger or smaller, but doesn't modify the actual size of your window.

I hope this can help you.

Xexi
"Life's a journey, not a destination"