Results 1 to 5 of 5

Thread: Minimising Game

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width