[comp.windows.ms.programmer] MapModes

rcomg@chudich.co.rmit.oz (Mark Gregory) (06/04/91)

I wish to display in two modes, similar to
the print preview and page view in W4W.

I have learnt how to turn the scroll bars on and off.
I have learnt how to get the x and y sizes for the printer
and the client window.

Could someone please tell me how to set up
the following commands for the two modes.

SetMapMode(MM_ISOTROPIC);
SetWindowOrg(
SetViewportOrg(
SetWindowExt(
SetViewportExt(

Your assistance will be appreciated.

Mark Gregory	       PHONE:(03) 660 2728   FAX:(03) 662 1060
IP No.: 131.170.32.1
ACSnet: rcomg@chudich.co.rmit.oz.au 
ARPA:   rcomg@chudich.co.rmit.oz.au@uunet.uu.net  
CSNET:  rcomg@chudich.co.rmit.oz.au  
BITNET: rcomg@chudich.co.rmit.oz.au@CSNET-RELAY
UUCP:   ...!uunet!munnari!chudich.co.rmit.oz.au!rcomg
SNAIL:  Royal Melbourne Institute of Technology,
        Department of Communication and Electrical Engineering,
        G.P.O. Box 2476V, Melbourne, Victoria, 3001. AUSTRALIA.
---------------------------------------------------------
The computer adventurer.
Gremlins and bugs hitherto unknown search me out.
If it can happen it will to me.

dsampson@x102a.harris-atd.com (sampson david 58163) (06/05/91)

Map modes are probably one of the most confusing things in windows
programming and are also one of the poorest documented features.  I've
spent many hours playing with them to just to see how they work.

As you're probably aware, MM_TEXT is the default map mode and
corresponds 1:1 with the screen pixels.  When I first read about that
I thought 'Great.  Does that mean that I can't draw anything larger
than the screen resolution.  And what if I'm trying to write this
Device Independent stuff.  Do I have to worry about whether a user has
an EGA vs. a VGA or Super VGA, etc....'

It turns out that you are not limited to the number of pixels on the
screen.  If you want to draw a rectangle on your EGA monitor starting
at 1000, 1000 go ahead and do it.  You can set up scroll bars for your
window, set the proper range, and scroll over to that area.

Even though MM_TEXT is set up to map pixels 1:1 it still acts like a
"world coordinate system".  The main difference between MM_TEXT and
all the other mapping modes is MM_TEXT is scaled 1:1 to the pixels and
the others are scaled by a different ratio (as explained in the SDK).
All of the map modes (MM_TEXT included) have a "world coordinate
system" that is limited to the size of an integer (32K), not the size
of the CRT. (I've ignored the extents in the ISOTROPIC modes because
that has no bearing on the Window or Viewport origins, which is what
this is really leading up to.)

I only recently discovered this fact.  I used other map modes in some
of my programs because I thought that the pixel limitation existed.
It turns out that most experience windows programmers that I've talked
to don't fool around with the other mapping modes (unless there is a
special reason to) because they were smarter than I was and discovered
that MM_TEXT was not limited to the number of pixels associated with a
display device.  :)

If you decide that you want to use one of the other mapping modes (I
have used the MM_ANISOTROPIC and LO_ENGLISH for projects) then you
have to contend with the viewport and window origins.  The trick is to
set your Window origin (and extent if that applies to the mode you've
selected) and don't change it.  This establishes your world coordinate
system and you want it kept fixed at all times.  Then setup the Viewport
origin (and extent).  To scroll around, you will only move the Viewport
Origin when you respond to a scroll msg.  This will act like a window
that you slide over the world coordinate system allowing you to view
parts of your large drawing.

Hope this helps.

David





--

                                          A new world record
                                          in the javalin throw
                                                
    /                                          /
   /                                          I
-------------------------------------------------


David Sampson                                         Harris Corporation
dsampson@x102a.ess.harris.com                   Gov't Aerospace Systems Divison
uunet!x102a!dsampson                                  Melbourne, Florida

-------------------------------------------------------------------------------