コード例 #1
0
ファイル: WindowFinder.cs プロジェクト: Nucs/nlib
 /// <summary>
 /// Sets the window handle if handle is a valid window.
 /// </summary>
 /// <param name="handle">The handle to set to.</param>
 public void SetWindowHandle(IntPtr handle)
 {
     if ((NativeWin32.IsWindow(handle) == false) || (NativeWin32.IsRelativeWindow(handle, this.Handle, true)))
     {
         // Clear window information
         windowHandle     = IntPtr.Zero;
         windowHandleText = string.Empty;
         windowClass      = string.Empty;
         windowText       = string.Empty;
         isWindowUnicode  = false;
         windowCharset    = string.Empty;
     }
     else
     {
         // Set window information
         windowHandle     = handle;
         windowHandleText = Convert.ToString(handle.ToInt32(), 16).ToUpper().PadLeft(8, '0');
         windowClass      = NativeWin32.GetClassName(handle);
         windowText       = NativeWin32.GetWindowText(handle);
         isWindowUnicode  = NativeWin32.IsWindowUnicode(handle) != 0;
         windowCharset    = ((isWindowUnicode) ? ("Unicode") : ("Ansi"));
     }
     if (WindowHandleChanged != null)
     {
         WindowHandleChanged(this, EventArgs.Empty);
     }
 }