View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Robert Baer Robert Baer is offline
external usenet poster
 
Posts: 93
Default Determine closest control to MouseUp event?

Auric__ wrote:
Is there an easy, accurate method to determine the closest control to a
MouseUp (or MouseDown, if it's easier) event, if the user clicks on the
UserForm instead of a control? (My form will be used on a touch screen.)

My current best guess is to do it manually (so to speak): look at the
coordinates of the click, and then look at the coordinates of each control
and decide which one is closest. I'm sure it'll work, but it's going to be a
PITA, and I'm looking for something built-in, or alternately code that's
already been written. (My google-fu has failed me here.)

Javascript can definitely get you X,Y pixel positions. Screen is
ASS-u-MEd to be 80x600, fixed.

Snippet from working code at http://www.oil4lessllc.org/gTX.htm:
<head
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
<titleTexas Stripper Wells and Production</title
<style type="text/css"
</style
</head

<body
<SCRIPT type="text/javascript"
var yr= 0; var awls = new Array(); var aprd = new Array(); var yar =
new Array();

awls[1941]="31,126"; awls[1942]="30,763"; awls[1943]="-";
awls[1944]="32,170"; awls[1945]="35,000";
awls[1946]="33,678"; awls[1947]="32,528"; awls[1948]="38,053";
awls[1949]="39,759"; awls[1950]="46,197";
awls[1951]="42,956";
///more array stuff///
aprd[1998]="128,822,329"; aprd[1999]="131,129,272";
aprd[2000]="135,151,385"; aprd[2001]="129,017,097";
aprd[2002]="127,252,695";
aprd[2003]="128,058,395"; aprd[2004]="126,260,710";
aprd[2005]="139,959,142"; aprd[2006]="147,506,457*";
aprd[2007]="119,683,522";
aprd[2008]="-";
var lin=""; var leg=" ";

legend="*Estimated #Not available -No data !Revised ?Suspect
&Confirmed"

var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
Xmm = (isNav) ? e.pageX : event.clientX;
Ymm = (isNav) ? e.pageY : event.clientY;
yr=Math.round((Xmm-116)/7.414286+1940);
lin=""; leg="";
if (yr1940) {
if (yr<=2008) {
yar[yr]=yr;
lin=yr+" Production of "+aprd[yr]+" BBLs from "+awls[yr]+" wells";
if ( lin.indexOf("*") -1 ) {
leg="*Estimated ";
}
if ( lin.indexOf("#") -1 ) {
lin=yr+" Information not available";
}
if ( lin.indexOf("-") -1 ) {
lin=yr+" No data";
}
if ( lin.indexOf("!") -1 ) {
leg=leg+"!Revised ";
}
if ( lin.indexOf("?") -1 ) {
leg=leg+"?Suspect ";
}
if ( lin.indexOf("&") -1 ) {
leg=leg+"&Confirmed ";
}
}

else {
lin=""; leg="";
}
}
document.dataholder.datlin.value=lin;
document.dataholder.com.value=leg;
}
if (isNav) {
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
</SCRIPT

<!-- style and then img src as separate items makes IE happy; GIF
is 90% BMP --

<div style="position: absolute; height: 341px; width: 720px; top: 80px;
left: 0px; "
<img src="Texas.gif" alt="" usemap="#TX" style="border-style:none"
</div

<!-- cannot use "len" to specify size below --
<div style="position: absolute; top: 1px; left: 120px; "
<form name="dataholder" action=""
<table border=0
<tr
<td<input type="text" size=57 name="datlin" value="0"</td
<td<input type="text" size=25 name="com" value="0"</td
</tr
</table
</form
</div

<div style="position: absolute; height: 312px; width: 518px; top: 420px;
left: 120px; "
<img src="TXdaily.jpg" alt="daily" style="border-style:none"
</div

<div style="position: absolute; top: 30px; left: 300px; " <H3<iŠ 2013
Oil 4 Less LLC</i</H3</div

</body
</html