Re: SetMapMode



"Steve" <sredmyer@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


.



Relevant Pages

  • Re: SetMapMode
    ... need to know is what scalemode is being used by a VB form. ... owns the coordinate system is the hWnd. ... how do I determine the VB ScaleMode setting of a window ... I told you - 98% of the time it is Pixels ...
    (microsoft.public.vb.general.discussion)
  • Re: SetMapMode
    ... if Steve is not prepared to write his code in such a way that the user passes the Control to his dll then he is unlikely to want the user to pass the Form or the Forms collection either. ... The second reason is because Steve has said that the window handle which is being passed to his dll is not necessarily the handle to a VB window. ... Besides, Steve apparently wants to "read" the VB ScaleMode of the window in order that he can calculate the pixel values of the passed coordinates in accordance with the ScaleMode, but doing it that way assumes that the person who wrote the code that "called" his function is actually using the ScaleMode units for his coordinates. ...
    (microsoft.public.vb.general.discussion)
  • Re: SetMapMode
    ... also get the hDc) how can I tell what the current ScaleMode ... setting of a VB window is? ... of MM_TEXT (device pixels) for all of its windows (Forms, Picture Boxes, ... drawing in a different mapping mode, as long as you make sure that you ...
    (microsoft.public.vb.general.discussion)
  • Re: newbie questions on OpenGL and C#. I am using NeHe example code
    ... and 2) you can have the window covered by another window ... This implies that read pixels is not ... to put a red square down on the drawing surface. ... >> percentage the first polygon covers the second. ...
    (comp.graphics.api.opengl)
  • Re: newbie questions on OpenGL and C#. I am using NeHe example code
    ... > and 2) you can have the window covered by another window ... This implies that read pixels is not ... to put a red square down on the drawing surface. ... >> graphics card then you're rendering in software. ...
    (comp.graphics.api.opengl)

Loading