Results 1 to 5 of 5

Thread: Minimising Game

  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

  2. #2
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    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.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    You Must Know The Caption Of The Window You Want To Minimize

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    5. Private Const SW_MINIMIZE = 6
    6.  
    7. Private Sub Command1_Click()
    8. Dim lngMinimizeIt As Long
    9. lngMinimizeIt = FindWindow(vbNullString, "Put Window Caption Here")
    10. ShowWindow lngMinimizeIt, SW_MINIMIZE
    11. End Sub

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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
  •  



Click Here to Expand Forum to Full Width