Re: Stack over flow?



On 16 Apr, 15:58, "Steve Gerrard" <mynameh...@xxxxxxxxxxx> wrote:

if there is a postable message that
could carry something useful, maybe
just a simple integer parameter . . .

There's one thing I forgot to mention in the code I recently posted
Steve. For the code to work so that the value received is the same as
the value sent you need to set the PictureBox ScaleMode to vbPixels (I
did this in the properties Window in the IDE when writing my example
and so you'll need to add it to the example code).

The reason for this is that VB preprocesses the MouseMove message it
receives from the OS (which of course contains standard default pixel
values) and it converts those values according to the current
ScaleMode of the PictureBox. That's because VB Form and VB PictureBox
DCs always actually use a MapMode of MM_TEXT (pixels) under the hood,
regardless of their VB ScaleMode. For example if you use the
following:

Private Sub Command2_Click()
sTest = "A"
PostMessage Picture1.hwnd, _
WM_MOUSEMOVE, 0&, 100&
sTest = sTest & "B"
End Sub

.. . . and if the PictureBox ScaleMode is vbPixels then you will also
get a value of 100 in the Single which refers to the x xoordinate in
the PictureBox's MouseMove event. However, if the ScaleMode is vbTwips
you will get a value of 1500 on a machine running at the standard 15
twips per pixel (96 dpi) setting and a value of 1200 on a machine
running at 12 twips per pixel (120 dpi) and various other values on
machines running at any of the various other possible twiups per pixel
settings. So, best use a PiuctureBox ScaleMode of pixels to make the
result reliable on all systems in a way that does not require you to
perform any conversions.

Mike



.



Relevant Pages

  • 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: Floating point coordinates
    ... For a Form or Picbox you would need to use a ScaleMode that is not ... integer-based (iow something other than Twips or Pixels). ... the precision is still 1 pixel. ... in twips is always an exact multiple of Screen.TwipsPerPixelX. ...
    (microsoft.public.vb.winapi.graphics)
  • Re: button size problem
    ... twips or pixel, set the width and height of the form, and make sure ... ScaleMode (for example twips, pixels, inches or whataver). ... Command1.Left = Me.ScaleX(0.5, vbInches, Me.ScaleMode) ...
    (comp.lang.basic.visual.misc)
  • Re: button size problem
    ... The scalemode is set to 'user'. ... user, twips or pixel, set the width and height ... and make sure the Scalewidth and ScaleHeight are identical. ...
    (comp.lang.basic.visual.misc)