473,569 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to see if another application/Window is minimized?

Hi,

How can you see with a VB.NET-application if the Window of another
Application (for exemple an opened Word-Document) is Mimized?
Is there also a way to see if it is Maximized?

Thanks a lot,

Pieter
Nov 20 '05 #1
5 9659
[DllImport("user 32")]
public static extern bool IsIconic (int hwnd);

usage

int hwnd = //get msword application handle

bool bMinimized = IsIconic (hwnd);

bMinimized = true means window is in minized state

--
Shak
(Houston)
"DraguVaso" <pi**********@h otmail.com> wrote in message
news:eW******** ******@TK2MSFTN GP11.phx.gbl...
Hi,

How can you see with a VB.NET-application if the Window of another
Application (for exemple an opened Word-Document) is Mimized?
Is there also a way to see if it is Maximized?

Thanks a lot,

Pieter

Nov 20 '05 #2
* "Shakir Hussain" <sh**@fakedomai n.com> scripsit:
[DllImport("user 32")]
public static extern bool IsIconic (int hwnd);

usage

int hwnd = //get msword application handle

bool bMinimized = IsIconic (hwnd);

bMinimized = true means window is in minized state


This will allow you to check the window state, but it won't give you a
notification when the window state changes. 'hwnd' should be 'IntPtr'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
I tried it, but unfortunately it didn't work :-(
This is the code I used:

<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Is Iconic", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Function _
IsIconic(ByVal hWnd As IntPtr) As Boolean
End Function
Public Sub pbenmin()
Dim clsProc As New clsProcesses
Dim p As Process
p = clsProc.Process Extra()
Dim IsNormal As Boolean

'Dim HWND As Integer
Dim hwnd As IntPtr
hwnd = p.Handle

If hwnd.ToInt64 = 0 Then
IsNormal = False
Exit Sub
End If
If IsIconic(hwnd) <> 0 Then
IsNormal = False
End If
End Sub
The result of IsIconic was always different than 0...

Any idea what I did wrong?

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:OT******** ******@tk2msftn gp13.phx.gbl...
* "Shakir Hussain" <sh**@fakedomai n.com> scripsit:
[DllImport("user 32")]
public static extern bool IsIconic (int hwnd);

usage

int hwnd = //get msword application handle

bool bMinimized = IsIconic (hwnd);

bMinimized = true means window is in minized state


This will allow you to check the window state, but it won't give you a
notification when the window state changes. 'hwnd' should be 'IntPtr'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #4
* "DraguVaso" <pi**********@h otmail.com> scripsit:
I tried it, but unfortunately it didn't work :-(
This is the code I used:

<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Is Iconic", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Function _
IsIconic(ByVal hWnd As IntPtr) As Boolean
End Function
Public Sub pbenmin()
Dim clsProc As New clsProcesses
Dim p As Process
p = clsProc.Process Extra()
Dim IsNormal As Boolean

'Dim HWND As Integer
Dim hwnd As IntPtr
hwnd = p.Handle


'p#Handle' will return a /process/ handle, you need a /window/ handle.
Use 'p.MainWindowHa ndle' instead.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
Thanks a lot!!! It works Great! I never thought it would be possible, hehe
:-)
I finally did it like this:

Public Const GW_HWNDPREV = 3
Private Const SW_SHOW = 5
Private Const SW_RESTORE = 9

<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Se tForegroundWind ow", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Public Shared Function SetForegroundWi ndow(ByVal handle As IntPtr) As
Boolean
' Leave function empty
End Function

<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Sh owWindow", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Shared Function ShowWindow(ByVa l handle As IntPtr, ByVal nCmd As
Int32) As Boolean
' Leave function empty
End Function

<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Is Iconic", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Shared Function IsIconic(ByVal hWnd As IntPtr) As Boolean
' Leave function empty
End Function

<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Is Iconic", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Shared Function IsZoomed(ByVal hWnd As IntPtr) As Boolean
' Leave function empty
End Function
Public Shared Sub SetToForGround( ByVal hwnd As IntPtr)
Dim strStatus As String
'Dim hwnd As IntPtr
'hwnd = p.MainWindowHan dle

If IntPtr.Zero.Equ als(hwnd) Then
strStatus = ""
Exit Sub
End If
If IsIconic(hwnd) Then
strStatus = "MIN"
End If
'If IsZoomed(hwnd) Then
' IsNormal = True
'End If
'If IsIconic(hwnd) And IsZoomed(hwnd) Then
' IsNormal = True
'End If

If strStatus = "MIN" Then
'mimized
ShowWindow(hwnd , SW_RESTORE)
SetForegroundWi ndow(hwnd)
Else
'maximzed or restored
SetForegroundWi ndow(hwnd)
End If
End Sub

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
* "DraguVaso" <pi**********@h otmail.com> scripsit:
I tried it, but unfortunately it didn't work :-(
This is the code I used:

<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Is Iconic", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _ CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _ Private Function _
IsIconic(ByVal hWnd As IntPtr) As Boolean
End Function
Public Sub pbenmin()
Dim clsProc As New clsProcesses
Dim p As Process
p = clsProc.Process Extra()
Dim IsNormal As Boolean

'Dim HWND As Integer
Dim hwnd As IntPtr
hwnd = p.Handle


'p#Handle' will return a /process/ handle, you need a /window/ handle.
Use 'p.MainWindowHa ndle' instead.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
10786
by: Brian Jorgenson | last post by:
On my web page, I have a few hyperlinks with target frame of _blank. The hyperlink brings up a second window, but everytime I click on thie hperlink, it keeps bringing up a new window and not defaulting the the first active window. How do I make a hyperlink point to the active window? I don not want the hyperlink to default to the same page. I...
5
1802
by: DraguVaso | last post by:
Hi, How can you see with a VB.NET-application if the Window of another Application (for exemple an opened Word-Document) is Mimized? Is there also a way to see if it is Maximized? Thanks a lot, Pieter
9
1844
by: Denise | last post by:
I have posted a similar message in 2 other forums but got no response. I have spent more hours than I can count researching this. Can anyone provide some insight...? Our ASP.Net application needs to transparently log a user on to a separate secure web site (PHP - not controlled by us). We want to save the user the step of typing in his...
3
7814
by: DraguVaso | last post by:
Hi, My application has some interaction with an other application. I sometimes need to put the other application to the front. The problem is that I'm not able to get a nice solution to work in every case. I tryed two ways: one way it disn't maximazi the Windowd when it was Minimized, in the other way it resized the application when it was...
2
2107
by: Gary Townsend | last post by:
I have seen similar requests to this but not quite what i was looking for i have an mdi interface and i have 3 child forms 2 are application forms (meaning they do stuff for the application) and the other is a debug window with a multiline text field for displaying debug messages within the application. What happens is i load the debug form...
8
4539
by: Avi G | last post by:
Hi, i've created an application and i want it to be minimized to the sys tray, how i do it? if you can direct me step by step even with create a small application and put it in the sys tray Thanks
0
1557
by: =?Utf-8?B?U2VudGhpbCBTdWJyYW1hbmlhbg==?= | last post by:
Our requirement is to run the vb dot net application in minimize mode with system tray icon in the remote machine (remote desktop). When we running in the remote desktop window is showing in normal mode without minimize mode. when we running in the console mode our application window is minimized without any issues, when we executed the...
6
1087
by: pamela fluente | last post by:
Hello friends, I have a simple question. If I have an application with several forms, you see on the windows bar, usually on the bottom of your screen, the various tags for the various forms. Now if the bar gets crowded, windows automatically puts all the minimized forms of the same application together, and indicates how many of them...
1
2463
by: Thom Little | last post by:
Using C# 3.5 (including using System.Runtime.InteropServices) ... .... if the window is Minimized (IsIconic) ... I would like to ... If the window was Normal and then Minimized I would like to return it to Normal. If the window was Maximized and then Minimized I would like to return it to Maximized How can I determine for any window...
5
11427
by: uvklein | last post by:
Hi there, I'm writing an application with forms. my main window can be hidden (minimize to a tray icon) like...Microsoft Outlook for example. this application can run only one instance (again like outlook) - meaning that on initialization, I check if there is another process running and if so I exit from the new one. in case the main...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.