TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jim Tat
NA
52
47.5k
How To Check If A Window Is Minimized In C#
Sep 6 2016 6:06 AM
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);
}
}
}
}
But when I compile nothing happen , do you have any idea ?
Reply
Answers (
6
)
barcode how to program ?
how to split and merge file