Help with polygons!

Help with polygons!

Post by Sm9l » Sun, 18 Jul 2004 08:48:02


I hope this is the right forum for this! It does use the API and it sort of is graphics, so I guess I'm close enough... :)

I'm drawing polygons using the same code from MSDN at http://www.yqcomputer.com/ ;en-us;81470

The only problem is this example requires the Forms (PictureBox, etc) ScaleMode to be set to VBPixels. This was fine for a while, but now it will no longer work.

My Forms ScaleWidth is negative, ScaleHeight is positive, ScaleWidth to ScaleHeight ratio is about 10 to 7... Please someone tell me you don't REALLY have to use VBPixels to draw a polygon with the API... If so, then does anyone have any suggestions? This is for personal use, so I wont pay for any outside controls.

Thanks,
Joe
 
 
 

Help with polygons!

Post by Mike D Sut » Sun, 18 Jul 2004 17:44:41

> I hope this is the right forum for this! It does use the API and it sort of is graphics, so I guess I'm close enough... :)

VB's scale-mode and the API mapping mode are two separate things, unless you've explicitly changed the underlying DC mapping mode it
should be set to MM_TEXT which is the equivalent of vbPixels (1:1 mapping between logical and device space.) If you want to convert
between a coordinate in your custom mapping mode to pixels then you can use the ScaleX() and ScaleY() methods of the PictureBox
control and map to vbPixels. If you want to change the mapping mode of the underlying DC to match that of your VB control then
you'll need to look into the SetMapMode() API call with probably the MM_ANISOTROPIC mapping mode, which requires you to set up your
own view-port and window mapping areas using the Set[Window/Viewport][Org/Ext]Ex() API calls - Have a look at the DC article on my
site and the MSDN for more on this, also here's an old post that synchronises the API scale-mode with VBs:
http://www.yqcomputer.com/ %40TK2MSFTNGP12.phx.gbl
Be warned though that the API always uses integers for it's coordinates, so if you have a very small granularity on your VB
scale-mode you may want to increase this by a couple of orders of magnitude when setting the API mapping mode.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: XXXX@XXXXX.COM
WWW: http://www.yqcomputer.com/