Results 1 to 11 of 11

Thread: Windows At Back

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Location
    FlyingOffice
    Posts
    178

    Windows At Back

    I found a lot of code teaching how to put the window on top of others.

    Do anybody know how to put one's window at the back of all other windows (they are of different exe programs)

    Thanks

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
    4.                                                     ByVal hWndInsertAfter As Long, _
    5.                                                     ByVal x As Long, ByVal y As Long, _
    6.                                                     ByVal cx As Long, ByVal cy As Long, _
    7.                                                     ByVal wFlags As Long) _
    8.                                                     As Long
    9.  
    10. Private Const SWP_FRAMECHANGED = &H20
    11. Private Const SWP_NOACTIVATE = &H10
    12. Private Const SWP_NOMOVE = &H2
    13. Private Const SWP_NOREDRAW = &H8
    14. Private Const SWP_NOSIZE = &H1
    15. Private Const SWP_SHOWWINDOW = &H40
    16.  
    17. Private Const SWP_ALL = SWP_FRAMECHANGED Or SWP_NOACTIVATE Or SWP_NOMOVE Or _
    18.                         SWP_NOSIZE Or SWP_SHOWWINDOW
    19.  
    20. Private Const HWND_BOTTOM = 1
    21.  
    22. Private Sub Command1_Click()
    23.     Call SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_ALL)
    24. End Sub

    That won't lock the window at the bottom of the order, but it will get moved there until it gets activated again.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    i found that using setparent and place it in the desktop listview it will always stay bottom.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Location
    FlyingOffice
    Posts
    178
    Thanks crptcblade, I will try

    BuggyProgrammer, would you mind to elaborate the code used?

  5. #5
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    VB Code:
    1. Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal _
    2. hWndChild As Long, ByVal hWndNewParent As Long) As Long
    3.  
    4. 'Then go find the Desktop sysListView's handle and ur app's
    5. 'handle, then
    6. SetParent Me.hWnd, LstViewhWnd
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  6. #6
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: Windows At Back

    Quote Originally Posted by jian2587 View Post
    VB Code:
    1. Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal _
    2. hWndChild As Long, ByVal hWndNewParent As Long) As Long
    3.  
    4. 'Then go find the Desktop sysListView's handle and ur app's
    5. 'handle, then
    6. SetParent Me.hWnd, LstViewhWnd
    Desktop sysListView's? how to do that?. a enum windows name search?

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,624

    Re: Windows At Back

    jian25887's last post was in June 2008. PROBABLY not checking this forum any more. Might be best if you start your own thread.

  8. #8
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine on fire (country of slaves)
    Posts
    750

    Re: Windows At Back

    flyguille, GetDesktopWindow().
    Malware analyst, VirusNet developer, HiJackThis+ author || my CodeBank works

  9. #9
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: Windows At Back

    Quote Originally Posted by Dragokas View Post
    flyguille, GetDesktopWindow().
    What it is in multi-monitors systems?

  10. #10
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: Windows At Back

    Quote Originally Posted by Dragokas View Post
    flyguille, GetDesktopWindow().
    I tryed to replace those FindWindow, with the GetDesktopWindow, but didn't work, so what is the difference in the pointer fetched?

    this works

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
                    ByVal lpClassName As String, _
                    ByVal lpWindowName As String) As Long
                    
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
                    ByVal hWnd1 As Long, _
                    ByVal hWnd2 As Long, _
                    ByVal lpsz1 As String, _
                    ByVal lpsz2 As String) As Long
                    
    Private Declare Function SetParent Lib "user32" ( _
                    ByVal hWndChild As Long, _
                    ByVal hWndNewParent As Long) As Long
     
    Private Sub Form_Load()
        Dim ProgMan&, shellDllDefView&, sysListView&
        
        ProgMan = FindWindow("progman", vbNullString)
        shellDllDefView = FindWindowEx(ProgMan&, 0&, "shelldll_defview", vbNullString)
        sysListView = FindWindowEx(shellDllDefView&, 0&, "syslistview32", vbNullString)
        
        SetParent Me.hwnd, sysListView
    End Sub

    and this don't work

    Code:
    
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    
    Private Declare Function SetParent Lib "user32" ( _
                    ByVal hWndChild As Long, _
                    ByVal hWndNewParent As Long) As Long
     
    Private Sub Form_Load()
        Dim sysListView&
        
    
        
        sysListView = GetDesktopWindow()
        
        SetParent Me.hWnd, sysListView
    End Sub

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

    Re: Windows At Back

    Quote Originally Posted by flyguille View Post
    Desktop sysListView's? how to do that?. a enum windows name search?
    Please do not post up or bump old threads. Just create your own new thread and add a link to this thread, for example, for reference as needed otherwise this thread, and all old threads, will need to be closed from commenting.

    Thanks
    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

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