View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Determine closest control to MouseUp event?

GS 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.)


Mouse clicks will be measured/scaled in screen position. Controls on
a userform are positioned from 0,0 (top,left) of the form. You'll
need to do some conversion and control mapping to do this. Wouldn't
it be easier/better, though, for the user to just click the desired
control?


Yes, of course, but...

Or use the Tab key to move around the controls in the order you've
defined?


Not necessarily. Let me clarify a bit.

This form has 33 textboxes, 2 comboboxes, a listbox, and a button.
All of them are tabstops. (There are also labels and another button
that aren't tab stops, but they don't matter.) The user doesn't have
to hit tab 35 times to go from the first box to the last, of course,
but being designed for touchscreens, I expect that users will run
into fat finger syndrome pretty often, hitting the form background
rather than the control they wanted.

I want to try to work around that a bit by guessing which control the
user wants. The best method I've thought of is what I described
above. (Hitting a label will move the focus to the associated
text/combo/listbox.)

(I can't adjust the size and/or layout of the boxes very much because
I'm assuming the on-screen keyboard will be used for data entry. On
my tiny tablet, there is literally not enough screen space for
anything except the form and the OSK.)


How about shifting focus in the label_Click event?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion