Results 1 to 3 of 3

Thread: minimize non- vbapp

  1. #1

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Question minimize non- vbapp

    What's the best way to minimize a non-vb application?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: minimize non- vbapp

    You have to use APIs to get the other apps window handle and then send to
    message to minimize. Lookup FindWindow and SemdMessage APIs.

    When working with APIs its best to download the API Guide and API Viewer from allapi.net.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: minimize non- vbapp

    How about doing this?
    VB Code:
    1. Option Explicit
    2. Private Declare Function ShowWindow Lib "user32" ( _
    3.     ByVal hwnd As Long, _
    4.     ByVal nCmdShow As Long _
    5. ) As Long
    6.  
    7. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    8.     ByVal lpClassName As String, _
    9.     ByVal lpWindowName As String _
    10. ) As Long
    11.  
    12. Private Const SW_HIDE = 0
    13. Private Const SW_MINIMIZE = 6
    14.  
    15.  
    16. Private Sub Command1_Click()
    17. Dim hWndApp As Long
    18. Dim strCaption As String
    19. Dim strProgram As String
    20.  
    21. strProgram = "notepad.exe"
    22. strCaption = "Untitled - Notepad"
    23.  
    24. 'see if program is already running
    25. hWndApp = FindWindow(vbNullString, strCaption)
    26.  
    27. 'if not then start it
    28. If hWndApp = 0 Then
    29.     Shell strProgram, vbNormalFocus
    30.     While hWndApp = 0
    31.         hWndApp = FindWindow(vbNullString, strCaption)
    32.         DoEvents
    33.     Wend
    34. End If
    35.  
    36. 'mimimize it
    37. MsgBox "Press OK to minimize"
    38. ShowWindow hWndApp, SW_MINIMIZE
    39.  
    40. End Sub

    ...

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