Thread: focus policy
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default focus policy

Hi Terry

The event you want, or rather closest to it, is called MouseMove. You can code most your
controls and containers like this:

Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As
Single, ByVal Y As Single)
TextBox1.SetFocus
End Sub

When it comes to the form itself it's more awkward, and the sheet has no mousemove thing
at all. Adding to the problems that there's no MouseExit event on anything, that the form
or sheet to my knowledge won't activate/deactivate itself by code and that they don't even
know when it happens when done manually. Anyway, I think you'd be 70% there with mousemove
on all form controls.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Terry von Gease" wrote in message ...
Is there any way to set, or at least fake, Excel, or windows in general, to
mimic the Motif-like 'focus follows mouse' focus policy?

Assume a sheet and a modeless form displayed. When the mouse cursor moves
onto the form, the form gets the focus, and vice versa, when the mouse
cursor moves from the form onto the sheet, the sheet gets the focus. No
clicking, just moving.

Something on the effective order of:

Sub UserForm_Enter()
Me.someControl.SetFocus or whatever
End Sub
. . .

Sub Worksheet_Enter()
SetFocus or Activate or whatever
End Sub

While modeless forms are certainly a boon, without being able to do this
they can tend to cause more confusion than they're worth. One never knows
just where one is typing without making sure that the place you assume you
are is in fact the place with the focus.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley