How to find the active form in CF

  • Thread starter Thread starter Hari
  • Start date Start date
H

Hari

Hi,
Can any one plz tell me how to know which form is active in an
application. My app contains many forms and requires to identify the
active form very frequently. I found that there is no property like
Form.ActiveForm available in CompactFramework. I could use a class
which contains a Form class variable to store the current form instance
and assign to it the current form instance in the page_load event of
that form. But this may lead to bugs if i fail to assign the correct
form instance. So i prefer a more direct way. Plz help!

- Hari
 
Have you looked at the SNAPI (State Notification API) for Windows Mobile 5
if you are using it. I can't remeber off the top of my head whether the
functionality you require is available in SNAPI.

Alternaively, have you considered creating a base form to which each form
derives which handles this global variable?

Regards
Simon.
 
Hi Simon,
Actually i'm not aware of SNAPI. I'm developing the app. using
..Net Compact Framwork and the language as C#. And regarding your second
suggestion, is it not similar to the way i've done. I've used a class
which is meant for holding the instance of the current form and i'm
setting that instance in the page_load event of every form. I think
this is almost similar to deriving from a base form which holds the
form instance as you said. Is it any different. Any other suggestion?
Thanks for the help.

- Hari
 
The managed equivalent of SNAPI is the Microsoft.WindowsMobile.Status
namespace. Take a look at the SystemState.ActiveApplication which may help
although I believe it only stores the names of separate application windows
and not forms within a single application.

Peter
 
It is not the same though is it because you are having to remember to set
this variable in each form (page_load delegate).
If you were to derive from a form, this class would handle this variable so
you would not have to remember to set it in each form you create.

Regards
Simon.
 
Back
Top