How to find the active form in CF

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
 
S

Simon Hart

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.
 
H

Hari

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
 
P

Peter Foot [MVP]

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
 
S

Simon Hart

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top