473,503 Members | 12,367 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 9652
[DllImport("user32")]
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**********@hotmail.com> wrote in message
news:eW**************@TK2MSFTNGP11.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**@fakedomain.com> scripsit:
[DllImport("user32")]
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.InteropServices.DllImport("user32. dll", _
EntryPoint:="IsIconic", _
CallingConvention:=Runtime.InteropServices.Calling Convention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
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.ProcessExtra()
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**************@tk2msftngp13.phx.gbl...
* "Shakir Hussain" <sh**@fakedomain.com> scripsit:
[DllImport("user32")]
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**********@hotmail.com> scripsit:
I tried it, but unfortunately it didn't work :-(
This is the code I used:

<System.Runtime.InteropServices.DllImport("user32. dll", _
EntryPoint:="IsIconic", _
CallingConvention:=Runtime.InteropServices.Calling Convention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
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.ProcessExtra()
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.MainWindowHandle' 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.InteropServices.DllImport("user32. dll", _
EntryPoint:="SetForegroundWindow", _
CallingConvention:=Runtime.InteropServices.Calling Convention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
Public Shared Function SetForegroundWindow(ByVal handle As IntPtr) As
Boolean
' Leave function empty
End Function

<System.Runtime.InteropServices.DllImport("user32. dll", _
EntryPoint:="ShowWindow", _
CallingConvention:=Runtime.InteropServices.Calling Convention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
Private Shared Function ShowWindow(ByVal handle As IntPtr, ByVal nCmd As
Int32) As Boolean
' Leave function empty
End Function

<System.Runtime.InteropServices.DllImport("user32. dll", _
EntryPoint:="IsIconic", _
CallingConvention:=Runtime.InteropServices.Calling Convention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
Private Shared Function IsIconic(ByVal hWnd As IntPtr) As Boolean
' Leave function empty
End Function

<System.Runtime.InteropServices.DllImport("user32. dll", _
EntryPoint:="IsIconic", _
CallingConvention:=Runtime.InteropServices.Calling Convention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
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.MainWindowHandle

If IntPtr.Zero.Equals(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)
SetForegroundWindow(hwnd)
Else
'maximzed or restored
SetForegroundWindow(hwnd)
End If
End Sub

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

<System.Runtime.InteropServices.DllImport("user32. dll", _
EntryPoint:="IsIconic", _
CallingConvention:=Runtime.InteropServices.Calling Convention.StdCall, _ CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _ 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.ProcessExtra()
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.MainWindowHandle' 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
10759
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...
5
1796
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...
9
1836
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...
3
7812
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...
2
2101
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...
8
4533
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 ...
0
1552
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...
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. ...
1
2451
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...
5
11407
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...
0
7212
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,...
0
7098
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...
0
7296
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,...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
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...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1524
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 ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.