Re: SetMapMode



On Mar 23, 9:25 am, "Mike Williams" <m...@xxxxxxxxxxxxxxxxx> wrote:
"Steve" <sredm...@xxxxxxxxxx> wrote in message

news:1174648665.249890.144470@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

So given only the hWnd (which ofcoarse I know means I can
also get the hDc) how can I tell what the current ScaleMode
setting of a VB window is?

You can't. At least I can't think of a way of doing it, not if all you have
is the hWnd. VB stores the current ScaleMode of each appropriate object
somewhere of course (in its own working data area, wherever that may be) but
I'm fairly sure there is nothing in the actual DC or window structure that
will tell you what it is. As far as VB is concerned it uses a mapping mode
of MM_TEXT (device pixels) for all of its windows (Forms, Picture Boxes,
etc) regardless of the VB ScaleMode you are using and it performs the
conversion from the VB ScaleMode units to device pixels at run time before
drawing into the DC.

You can write code to temporarily change the API mapping mode of a VB window
from pixels to anything you want if for some reason you wish to perform a
drawing in a different mapping mode, as long as you make sure that you
return the DC to its original condition before you allow VB itself to do
anything with the window, but there is no way you can find out what the VB
ScaleMode is simply by looking at the hWnd or at the DC. As far as VB is
concerned it sets the initial mapping mode to pixels and it leaves it that
way. When you use a native VB drawing method, VB performs runtime
conversions from ScaleMode units to pixels when drawing into the DC.

If the code you are writing is designed to perform various operations with
VB Forms or Controls then you would be better off passing your routines a
reference to the Control itself rather than simply its window handle. Then
you will be able to get at everything.

Mike

Well that would work (passing a reference to the window) if I always
knew what type of window would be passed (or did not mind late
binding) and could be assured that any window passed actually
supported the ScaleMode properties (some don't ie. Frames).

However I do not know what type of window may be passed in and since
what I am writting is an ActiveX component, I can not even be assured
that the passed in window will be a VB window (might be any window
from any enviornment capable of utilizing ActiveX)

But I guess if there is no way to know what units the X,Y are in I
will have to do something different, maybe add an optional parameter
to these methods, that allows the user to specify the units,
defaulting to pixels of coarse.

Thanks,
Steve

.


Loading