473,804 Members | 3,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Restore Window After Duplicate Instance Check

I can determine if another instance is running, but how do I get it's
minimized window to restore (in VBNET). Using the standard win32 functions
is not working.

Thanks
Nov 21 '05 #1
6 2305

Credit to Herfried...

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

"Glenn" <g.***@comcast. net> wrote in message
news:#Y******** ******@TK2MSFTN GP11.phx.gbl:
I can determine if another instance is running, but how do I get it's
minimized window to restore (in VBNET). Using the standard win32 functions
is not working.

Thanks


Nov 21 '05 #2
Herfried's code is extremely long when you can produce the same result is
around 3-5 lines.

Why not use appActivate using the process handle?

Crouchie1998
BA (HOS) MCP MCSE
Nov 21 '05 #3
Herfried

Why didn't you just tell the user to Import System.Runtime. InteropServices
to shorten then API calls?

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #4
Sorry for delay, I was away:

AppActivate does not restore the window according to the documentation and
also from trying.

Thanks for your comment.

Best,
Glenn
"Crouchie19 98" <cr**********@s pamcop.net> wrote in message
news:uq******** ******@TK2MSFTN GP09.phx.gbl...
Herfried's code is extremely long when you can produce the same result is
around 3-5 lines.

Why not use appActivate using the process handle?

Crouchie1998
BA (HOS) MCP MCSE

Nov 21 '05 #5
Thanks for your response. I will give it a try. Seems amazing that for
something that one might think was a fairly common need, there would not be
something simple built in
like App.Activate, something like, App.Activat(Res toreWindow), etc.

Best,
Glenn

"scorpion53 061" <sc************ @nospamhereyaho o.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..

Credit to Herfried...

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

"Glenn" <g.***@comcast. net> wrote in message
news:#Y******** ******@TK2MSFTN GP11.phx.gbl:
I can determine if another instance is running, but how do I get it's
minimized window to restore (in VBNET). Using the standard win32
functions
is not working.

Thanks

Nov 21 '05 #6
Finally got to test. Restoring from icon does not work. If the window is
maximized or normal, the window comes to foreground, but if minimized, then
not. IsIconic() reports false when window minimized. Also, ShowWindow does
not restore and SetToForground does not even highlight the window.

Any further ideas?
--
Thanks.

Best,
Glenn
"scorpion53 061" wrote:

Credit to Herfried...

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

"Glenn" <g.***@comcast. net> wrote in message
news:#Y******** ******@TK2MSFTN GP11.phx.gbl:
I can determine if another instance is running, but how do I get it's
minimized window to restore (in VBNET). Using the standard win32 functions
is not working.

Thanks


Nov 21 '05 #7

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

Similar topics

3
3511
by: Vikrant | last post by:
Friends, Due an application (old) install program problem, Under AIX I could only create DB2 instance, I could also catalog it. Its complex application and I am not expert in creating full database for this application, but I have desired DB2 backup (by db2 backup db command). Can I do redirected restore (SET TABLESPACE CONTAINERS ....) only when instance is created & cataloged , I am under the impression that redirected restore is...
2
3089
by: Vikrant | last post by:
Friends, I have read DB2/UDB 8.x 'RESTORE DATABASE Command', with my 'limited' knowledge & skill. I think it should address my concern, but I want advice/ opinion / experience and any care I must take to restore DB2/UDB 8.x database 64 to 32 bit). (1) Due to hardware limitaion I can not have 64 bit DB2/UDB 8 on AIX 4.3.3 host. Let us call this as host vhost32. I can migrate 7.2EE FP11 32bit to 8.x 32 bit on vhost32. This is my test...
9
14027
by: GL | last post by:
I am running DB2 8.1.1 on AIX 5.1 Having a problem with a redirected restore. Once into the restore continue phase, I immediately get the following “SQL2059W A device full warning was encountered on device "TBS_IDX". Do you want to continue(c), terminate this device only(d), abort the utility(t) ? (c/d/t) t
3
7056
by: cerbdog | last post by:
Hello, all. Was hoping someone might be able to help us out with an issue: We're trying to perform a restore from a backup of one AIX 5.1 server, we'll call it "AIX", to another AIX 5.1 server; we'll call this one "DEV". We're using Netbackup 5.1 MP3 to do this. For some reason when we try to restore from AIX's backup to DEV we recieve an error from Netbackup that states: ____________________________________________ + db2 restore...
5
4328
by: chow.justy | last post by:
Dear all, I'm a new beginner of DB2. I face 2 question during restore the data. I have 2 DB2 servers on my company. Server A is running on V7.2 and Server B is running on v8.2 (Enterprise Server). I backup a database from Server A and restore it on Server B. Question 1) "SQL2542N database name is not match on the source file" error
4
1640
by: lesperancer | last post by:
it looks like this will save many versions of a relationship window, but based on the fact that the same tables are displayed in the relationship window and it will restore versions of what was saved as long as all the tables that were saved are currently shown in the relationship window so if I have 2 tables, employee and customer and if I show just the employee table in the relationship window, I can save it as 'employee'
0
4454
by: mitrofun63 | last post by:
Hello. On my production site i have DB2 9.1.2 database configured for archiving logs and making backup through TSM Data Protection for DB2 UDB The LOGARCHMETH1 parameter is set to LOGARCHMETH1=VENDOR:/usr/tivoli/ tsm/tdp_r3/db264/libtdpdb264.a I make an online backup with include logs to servers local disk and then tranfer backup image to my test box for backup validate.
3
2630
by: aka | last post by:
Hi, I'm actually working on the migration of a DB2 unicode db (V8.2 FP 15) from a Sunfire machine with SunOS (64 bit, Big-endian) to an AIX 5.3 (64-bit, Big-endian) server located in US. The target server has DB2 V8.2 FP 15 installed and instance name and filesystem user groups rights an so on are all identical. From the manuals I see that a crossplatform backup-restore should be supported between the two systems. I did a full offline...
4
7929
by: DL | last post by:
Background Info: Instance A: SQL Server 2005 on Windows Server 2003 OS Instance B: SQL Server 2005 on XP Prof w/ SP2 Process: backup a database on Instance A like this: step 1 -- Management Studio for Instance A BACKUP DATABASE myAppNameDB TO DISK = 'c:\Temp\myAppNameDB_FullRecovery.bak' GO
0
9710
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10593
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7626
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
3
3000
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.