Cursor location

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am in a form and want to place the one of two date fields into a report I
am emailing.

the Date field names are FirstDateMailed and SecDateMailed.....

I want to identify where the cursor is (in which field) and then place the
contents of the field into a report. I think I know how to do that if I can
ID which field the cursor is setting in. Is there a system command that
tells where the cursor is?



Any help you could give would be helpful......Thanks ahead of time.
 
[...]
I want to identify where the cursor is (in which field) and then place
the
contents of the field into a report. I think I know how to do that if I
can
ID which field the cursor is setting in. Is there a system command that
tells where the cursor is?

As near as I can tell, only if you are using .NET 3.0. Then you can use
the Position property of the Mouse class. Without that class, the
..NET-enabled way is likely to create a MouseMove event handler, and keep
track of the last known mouse position. Then once you have the mouse
position, you can use Control.GetChildAtPoint() to identify the actual
field.

However, it begs the question: what is the user doing to indicate that one
of the two date fields should be copied to your report? A typical user
interface, for example, would have the user double-click on the field they
want to copy. If your user is doing something similar, then it probably
makes more sense to just handle the DoubleClick event (or whatever) in
each field directly. You probably can even just use the same event
handler for both, using the Control.Text property to retrieve the data
regardless of which control was double-clicked (or whatever).

In other words, while it's possible to get the current mouse location, in
a typical user-friendly interface it is almost never necessarily to poll
the mouse position directly. You are almost always able to handle some
event generated by the user action that either includes the mouse
position, or makes the mouse position moot by providing you with the extra
details you'd just have to get yourself from the mouse position.

Pete
 
Wouldn't your cursor be someplace else (like, on a "Send Report" button)
when you send your report?

Anyway, to see where your cursor is *before* you click anyplace else can be
done this way:

if( FirstDateMailed.Focused )
{
// Put the date from the FirstDateMailed field into the report...
}
else if( SecDateMailed.Focused )
{
// Put the date from the SecDateMailed field into the report...
}
 
Handle the MouseEnter event for each input Control, and keep track of which
Control it is in that way.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Back
Top