Hello, I need to check if a window is minimized in c# Here is what I did:
- {
- class RestoreWindow
- {
- [DllImportAttribute("user32.dll")]
- public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
- [DllImportAttribute("user32.dll")]
- public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
- [DllImportAttribute("user32.dll")]
- public static extern bool SetForegroundWindow(IntPtr hWnd);
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- static extern bool IsIconic(IntPtr hWnd);
- public static void MaximizeWindowIfMinized(string windowName,Form f1)
- {
- try
- {
- var instance = FindWindow(null, windowName);
- if (IsIconic(instance))
- {
- Button btn = new Button();
- btn.Width = 10;
- btn.Height = 10;
- f1.Controls.Add(btn);
- MessageBox.Show("Window is minimized");
- // ShowWindow(instance, 1);
- //SetForegroundWindow(instance);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
Jim TatPosted Sep 6, 2016, 10:44 AM
Tapan PatelPosted Sep 6, 2016, 10:21 AM
Jim TatPosted Sep 6, 2016, 6:46 AM
Midhun TpPosted Sep 6, 2016, 6:36 AM
Jim TatPosted Sep 6, 2016, 6:32 AM
Akash VarshneyPosted Sep 6, 2016, 6:29 AM