[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Determine which form has focus

Posted on 2008-01-26
5
Medium Priority
?
1,243 Views
Last Modified: 2008-01-26
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
0
Comment
Question by:Sheritlw
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20750898
0
 

Author Comment

by:Sheritlw
ID: 20750918
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
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 20751034
Form currentForm = Form.ActiveForm;
String cfName = currentForm.Name;

if (cfName = "your form name")
{
   // show help ...
}
0
 

Author Comment

by:Sheritlw
ID: 20751054
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.
    }
0
 

Author Comment

by:Sheritlw
ID: 20751105
The error was because cfname is case sensative (should have been cfName) and needed ==
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question