Link to home
Start Free TrialLog in
Avatar of Sheritlw
SheritlwFlag for United States of America

asked on

Determine which form has focus

Hi,
I am trying to implement .chm contextid help in my application and need to test what form currently has focus.
How do I determine which form, in a MDI application, has focus?
thanks
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Avatar of Sheritlw

ASKER

Yes, I already saw that article in my search.  However, it does not tell me how to use it to determine which form has focus.

For example,

Form currentForm = Form.ActiveForm;

If currentform = myformname then I want to show my help

I am very new to C# and am just trying to implement help within a MDI application by determining which form has the focus.  

Please provide an example.
Thank you
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I receive an error that  project.AddEmpForm is a type but used like a variable
Below is what I have
private void btnHelp_Click(object sender, EventArgs e)
     
    {
      Form currentForm = Form.ActiveForm.ActiveMdiChild;
      String cfName = currentForm.Name;

      this.helpProvider1.SetHelpNavigator(this.btnHelp, System.Windows.Forms.HelpNavigator.TopicId);

     
      {
        if (cfname = "AddEmpForm")
          this.helpProvider1.SetHelpString(this, "html\\1150.htm");
      }
      //write here code
      //to go to design mode from Code press Shift+F7.
    }
The error was because cfname is case sensative (should have been cfName) and needed ==