|
-
Feb 1st, 2005, 12:53 PM
#1
Thread Starter
Lively Member
Minimising Game
Hey,
Im trying to minimise a game but i'm having problems. The game doesn't appear to minimse. However the Windows Calculator does. I'll show you some of my code, which is messy and rubbish, so if you could share some source or point me into the right direction on how to minimise a game that would be great. Alot of the code is not needed but i'm that much of a noob 
Code:
Option Explicit
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1 'bring to top and stay there
Private Const SWP_NOMOVE = &H2 'don't move window
Private Const SWP_NOSIZE = &H1 'don't size window
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_NOTOPMOST = -2
Private Type POINTAPI
x As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
length As Long
FLAGS As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWNORMAL = 1
Private sAppName As String, sAppPath As String
Private Sub Command1_Click()
Shell sAppPath, vbMinimizedFocus
End Sub
Private Sub Command2_Click()
'Call EndTask(sAppName)
End Sub
Private Sub Command3_Click()
Dim app_hwnd As Long
Dim ofp As WINDOWPLACEMENT
app_hwnd = FindWindow(vbNullString, sAppName)
ofp.length = Len(ofp)
ofp.showCmd = SW_SHOWMINIMIZED
SetWindowPlacement app_hwnd, ofp
End Sub
Private Sub Command4_Click()
Dim app_hwnd As Long
Dim ofp As WINDOWPLACEMENT
app_hwnd = FindWindow(vbNullString, sAppName)
ofp.length = Len(ofp)
ofp.showCmd = SW_SHOWMAXIMIZED
SetWindowPlacement app_hwnd, ofp
End Sub
Private Sub Form_Load()
sAppName = "Operation Flashpoint"
sAppPath = "C:\Program Files\Codemasters\OperationFlashpoint\FLASHPOINTRESISTANCE.EXE"
Call SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Private Sub Mini_Click()
Dim app_hwnd As Long
Dim ofp As WINDOWPLACEMENT
app_hwnd = FindWindow(vbNullString, sAppName)
ofp.length = Len(ofp)
ofp.showCmd = SW_SHOWMINIMIZED
SetWindowPlacement app_hwnd, ofp
End Sub
Private Sub Timer1_Timer()
If GetActiveWindow = 0 Then
Call SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End If
End Sub
Thanks in advance
Last edited by BefunMunkToloGen; Feb 1st, 2005 at 12:56 PM.
Reason: For King Arthur
-
Feb 1st, 2005, 01:10 PM
#2
Frenzied Member
Re: Minimising Game
I'm probably way off base, but is there some reason why you can't just say Me.WindowState = vbMinimized?
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
-
Feb 1st, 2005, 01:40 PM
#3
Thread Starter
Lively Member
Re: Minimising Game
Yeah can't do that because the application i want to minimise isn't "me" it's a completely different programme. It's a retail PC game. Lol you should understand now.
-
Feb 1st, 2005, 01:47 PM
#4
You Must Know The Caption Of The Window You Want To Minimize
VB Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_MINIMIZE = 6
Private Sub Command1_Click()
Dim lngMinimizeIt As Long
lngMinimizeIt = FindWindow(vbNullString, "Put Window Caption Here")
ShowWindow lngMinimizeIt, SW_MINIMIZE
End Sub
-
Feb 1st, 2005, 04:53 PM
#5
Re: Minimising Game
A lot of games cannot be minimized. I think DirectX is one type that doesn't allow it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|