Hey,
I was trying to use the code from:
http://www.java2s.com/Tutorial/CSharp/0520__Windows/GetcurrentActiveWindow.htm
to get the topmost window handle; however, I need to click a notify icon, which will bring up a form.
I tried to use
private void notifyIcon1_MouseMove(object sender, MouseEventArgs e)
{
if (this.Visible == false
&& e.Button == System.Windows.Forms.MouseButtons.None)
{
IntPtr x = GetForegroundWindow();
if (x != this.Handle)
handle = x;
int chars = 256;
StringBuilder buff = new StringBuilder(chars);
if (GetWindowText(handle, buff, chars) > 0)
{
notifyIcon1.Text = buff.ToString();
}
}
}
This correctly displays the text etc. but when I click the notify icon, it changes.