ImageButtonClick coords not right

B

beanweed

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top