B
Bob
I'm struggling with identifying the active form in an access
application. There are functions called from shortcut menus that need
to determine the key value of a record displayed in the form when the
shortcut menu control is activated. The method I've been trying to use
is to identify the form that has the focus when the shortcut menu is
activated. This is not working for a couple of reasons:
The active form has its popup property set to true. That means that
Screen.ActiveForm and Screen.ActiveControl refer to the only form in
the application that isn't popup, the "startup" form of the
application. Also, the Activate/Deactivate events don't fire.
The active form can't be referenced (at least directly) via the Forms
collection, because I'm opening multiple instances of the form class
via the New statement.
I've been experimenting with the Windows API GetFocus() call, which
returns the window handle of the window with the focus. I can associate
a window handle with a form object in a dictionary object, and then
refer back to it later. However, an Access form seems to have more than
one window handle depending on which control has the focus. Also,
different records in a continuous form seem to have different window
handles. Even if I wanted to go to the trouble of recording every
possible window handle in a form, it seems that GetFocus() returns a
different window handle for the same control in the same record
depending on how the control is entered.
If I wanted to give up multiple instances of the forms, I could
dedicate a shortcut menu to each form and subform, and find the form
object via the Forms collection, but that would involve a significant
change to the user interface. I have run out of ideas for identifying
the form with the focus in my application, given the design
constraints. Are there any other avenues I may not have tried? Is there
another way of passing an argument to a shortcut action at runtime,
that doesn't depend on activate/deactivate/gotfocus/lostfocus? Thanks.
Bob
application. There are functions called from shortcut menus that need
to determine the key value of a record displayed in the form when the
shortcut menu control is activated. The method I've been trying to use
is to identify the form that has the focus when the shortcut menu is
activated. This is not working for a couple of reasons:
The active form has its popup property set to true. That means that
Screen.ActiveForm and Screen.ActiveControl refer to the only form in
the application that isn't popup, the "startup" form of the
application. Also, the Activate/Deactivate events don't fire.
The active form can't be referenced (at least directly) via the Forms
collection, because I'm opening multiple instances of the form class
via the New statement.
I've been experimenting with the Windows API GetFocus() call, which
returns the window handle of the window with the focus. I can associate
a window handle with a form object in a dictionary object, and then
refer back to it later. However, an Access form seems to have more than
one window handle depending on which control has the focus. Also,
different records in a continuous form seem to have different window
handles. Even if I wanted to go to the trouble of recording every
possible window handle in a form, it seems that GetFocus() returns a
different window handle for the same control in the same record
depending on how the control is entered.
If I wanted to give up multiple instances of the forms, I could
dedicate a shortcut menu to each form and subform, and find the form
object via the Forms collection, but that would involve a significant
change to the user interface. I have run out of ideas for identifying
the form with the focus in my application, given the design
constraints. Are there any other avenues I may not have tried? Is there
another way of passing an argument to a shortcut action at runtime,
that doesn't depend on activate/deactivate/gotfocus/lostfocus? Thanks.
Bob