简体   繁体   中英

How to get Child Process state(active or not) of a main window in another application using c#

I've a client application which having some tabs in the menu tab as follows 在此处输入图片说明 .I need to perform some action when the browse tab is selected. how can i get that event in my application. i want to write my own application to perform this action. I tried in this way

int chars = 256;
                StringBuilder buff = new StringBuilder(chars);
                // Obtain the handle of the active window.
                IntPtr handle = GetForegroundWindow();
                if (GetWindowText(handle, buff, chars) > 0)
                {
                   if (buff.ToString() == mainWindowName)
                    {
                        IntPtr WndToFind = FindWindowByCaption(IntPtr.zero, "Browse");
                        if(WndToFind != IntPtr.Zero)
                        {
                            MessageBox.Show("Inside Browse");
                        }     
                    }
                }

I want to dispaly some message when Browse tab is active. Please help me.

If you are using tabcontrol, below is the code to know which tabpage is selected by user.

 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {          
      if (tabControl1.SelectedTab == tabControl1.TabPages["tabPage2"])
      {
           ...add your code here
      }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM