ImageButtonClick coords not right

Discussion in 'ASP .Net Building Controls' started by beanweed, May 30, 2005.

  1. beanweed

    beanweed Guest

    I created a "colour-chooser" by constructing a BMP image of coloured
    rectangles and an xml document linking the location of the rectangle with its
    RGB value. So when a user clicks on the image, the Click event handler looks
    up the RGB and passes it along to other code.

    Problem is, it doesn't work when the client DPI is different. On my 96dpi
    screen, the image is 190x280 px (there is an
    onmouseover="self.status=event.x+','+event.y" to tell me where the mouse is
    on entering the image). The ImageClickEventArgs 'x' and 'y' (rounded to
    nearest 10) at the centre of top-bottom-left-right are
    90,0-90,280-140,0-140,190, as expected. However, on my 1400x1050 screen, with
    125%dpi setting, the image is still 190x280 px but the corresponding clicks
    are 90,0-90,350-175,0-175,240.

    So my question is how do I get the correct x,y? It seemed reasonable that if
    the image was forced to be the same size (through CSS and width properties)
    that the ImageClickEventArgs x and y would be the same too. That is, since
    the image has rescaled why doesn't the click property? I could write a
    formula to rescale but how do I discover the display dpi scale?
     
    beanweed, May 30, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. simast
    Replies:
    2
    Views:
    382
  2. Albert Wiersch
    Replies:
    14
    Views:
    1,584
    Neredbojias
    Aug 19, 2005
  3. Dave Harris
    Replies:
    1
    Views:
    625
    Peter Otten
    May 28, 2004
  4. Matthias Vodel

    Change coords of a canvas.line item

    Matthias Vodel, Jan 5, 2007, in forum: Python
    Replies:
    3
    Views:
    311
    Wojciech =?ISO-8859-2?Q?Mu=B3a?=
    Jan 5, 2007
  5. Joe
    Replies:
    2
    Views:
    298
    Tim Harig
    Jun 27, 2009
Loading...

Share This Page