Visual Basic Explorer
Visual Basic Explorer
 Navigation
 Home


 Coding
 Source Code

 FAQ Center

 VB Tips

 Downloads

 ToolBox

 Tutorials

 VB Games

 VB News

 VB Award

 VB Forums



 Affiliates
 Planet Source Code

 Rent a Coder

 DirectX4VB


 Misc
 Search

 Feedback

 Advertise

 About


Need to hire
a VB coder?

Please support our sponsor:

 Home 
 Site Map 
 Forums 
 News 
 Feedback 

 

'-------------------------------------
'Author: Eric D. Burdo, Sean Solo
'URL: http://www.redleif.com
'Added: 31-June-2000
'-------------------------------------
'Program: APPACTIVATER.ZIP
'-------------------------------------
'Description: This sample will activate
'and maximize a previous instance of the
'app.
'
'This only works with a compiled EXE, and
'will not work if run from the IDE so you
'must compile to see it work correctly.
'-------------------------------------
Option Explicit

 
Private Declare Function ShowWindow Lib "User32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As Any) As Long
Private Const SW_SHOWMAXIMIZED = 3
Private Sub Form_Load()

 
Dim hWnd As Long
Dim sTitle As String

 
If App.PrevInstance Then 'Is there a previous instance?
sTitle = Caption 'Store the current caption of this form
Caption = "Test ABC" 'Change the caption to something else
hWnd = FindWindow(0&, "Test 123") 'Find the window
If hWnd = 0 Then 'If the window is not found
Exit Sub '>>>>>>>>>>>> Something is wrong, so leave
Else 'Otherwise
AppActivate sTitle 'Activate the program
ShowWindow hWnd, SW_SHOWMAXIMIZED 'And maximize the window
End If
Unload frmMain 'Unload this form (ends the program)
End If
End Sub

 


Downloads

In IE right-click and select 'Save Target As...' or in Netscape right-click and select 'Save Link As...'

 

View Plain Text View Plain Text
Download Demo Project Download Demo Project
View Code Online Not Available





Home | About | What's New | Source Code | FAQ | Tips & Tricks | Downloads | ToolBox | Tutorials | Game Programming | VB Award | Search | VB Forums | Feedback | VBNews | Copyright & Disclaimer | Advertise | Privacy Policy |

Quick searches: Site Search | Advanced Site Search 

Copyright 2002 by Exhedra Solutions, Inc.
By using this site you agree to its terms and conditions
VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc.