PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Form ALWAYS at Bottom-VBForums
Results 1 to 15 of 15

Thread: Form ALWAYS at Bottom

  1. #1

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Arrow Form ALWAYS at Bottom

    First see this code by bushmobile.
    This works perfectly. The form is always at bottom but on top of icons.

    Now enable web view on your desktop. Show any html file as wallpaper. Then run the following code and hit command1.

    See ? The form is now behind the icons.

    Any idea how to do this when webview is not enabled ?
    VB Code:
    1. Option Explicit
    2. ' Add 2 command buttons in the form
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. 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
    5. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    6.  
    7. Dim Progman&
    8. Dim SHELLDLLDefView&
    9. Dim InternetExplorerServer&
    10.  
    11. Private Sub Command1_Click()
    12.     SetParent Me.hwnd, InternetExplorerServer
    13. End Sub
    14.  
    15. Private Sub Command2_Click()
    16.     SetParent Me.hwnd, Progman
    17. End Sub
    18.  
    19. Private Sub Form_Load()
    20.     Progman& = FindWindow("Progman", vbNullString)
    21.     SHELLDLLDefView& = FindWindowEx(Progman&, 0&, "SHELLDLL_DefView", vbNullString)
    22.     InternetExplorerServer& = FindWindowEx(SHELLDLLDefView&, 0&, "Internet Explorer_Server", vbNullString)
    23.     Command1.Caption = "InternetExplorerServer"
    24.     Command2.Caption = "Progman"
    25. End Sub
    Attached Images Attached Images  
    Last edited by iPrank; Aug 28th, 2006 at 04:27 AM. Reason: Added Screenshot
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Form ALWAYS on Bottom

    Just to be sure, you want the app to be behind the icons on the normal plain desktop with a picture as a background?


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Form ALWAYS on Bottom

    I tried maybe setting it to have a website and then try to hide the window. So it would be set as web and not plain desktop, but it wouldn't be visible. It didn't work though as I expected... Just thought of moving it off screen, might work... However, not having it set as web, it's just a plain listview from what I see from the classes. A listview that either has or doesnt' have a background image. So sending the app behind the icons doesn't seem easy, if even possible... I could be wrong, these are all assumptions I'm making


    Has someone helped you? Then you can Rate their helpful post.

  4. #4

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Form ALWAYS on Bottom

    See the parent hierarchy:
    Progman
    |
    SHELLDLLDefView
    |
    InternetExplorerServer (or SysListView32)

    So, I'm guessing, in web view the icons become some 'html thing' ?

    If you have an Active Desktop Channel it will behave same. It is of "DeskMover" class. It still has InternetExplorerServer as its parent.

    I thought about enabling Active Desktop programmetically - Do you know how ?

    But then thought of those annoying Active Desktop Recovery screens. - ok it can be taken care of by modifying the active desktop template. But still I'd like not to change user's system settings.

    Then I thought about placing a Webbrowser Control on desktop listview - but that didn't work.

    Edit: SetParenting to SHELLDLLDefView doesn't work either.
    Last edited by iPrank; May 31st, 2006 at 09:13 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Form ALWAYS on Bottom

    how about setting your form to the back - maximized, and then placing on it a transparent listview (if such a thing exists) of the desktop icons

    - i'm not even sure if it's possible, but its an idea.

  6. #6

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Form ALWAYS on Bottom

    Sorry, I don't understand.
    Could you please explain a little bit more ?

    Have you tried the code I posted when active desktop is enabled ? The form moves 'behind' the icons. That's what I want.

    Not sure about this "transparent listview" thing. Please tell me your idea.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  7. #7
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Form ALWAYS on Bottom

    I think bushmobile means to redraw the desktop in your app in a listview and put that on top of everything else in your app. Dunno how well that would work, if at all...


    Has someone helped you? Then you can Rate their helpful post.

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Form ALWAYS on Bottom

    yeah, that's what i meant.

    i've been fiddling around with this - i thought SysListView32 was transparent, and it just displayed the progman background, so i put the form behind it, but then it just disappears.

    The best I've managed to achieve so far is placing the SysListView32 inside my form which is inside SHELLDLL_DefView. You can then have the controls showing above the icons (not your aim, I know), but anyhow the ListView's background stills shows, and you need to get rid of that.

    However, the background seems to be linked to the actual desktop background (move the form and the listview background will move accordingly) - I can't seem to get rid of it.

    Interestingly, the only windowstyle change in progman or any of it's children when you switch to Active Desktop is the introduction of the extended style LVS_EX_REGIONAL on SysListView32. Wait a mo... regioning! we want to click through the listview - perfect! but i couldn't get it too set - maybe someone else will know how.

    I give up!

    Anyway, here's the code i was using:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    4.                 ByVal lpClassName As String, _
    5.                 ByVal lpWindowName As String) As Long
    6.                
    7. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
    8.                 ByVal hWnd1 As Long, _
    9.                 ByVal hWnd2 As Long, _
    10.                 ByVal lpsz1 As String, _
    11.                 ByVal lpsz2 As String) As Long
    12.                
    13. Private Declare Function SetParent Lib "user32" ( _
    14.                 ByVal hWndChild As Long, _
    15.                 ByVal hWndNewParent As Long) As Long
    16.                
    17. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
    18.                 ByVal hwnd As Long, _
    19.                 ByVal wMsg As Long, _
    20.                 ByVal wParam As Long, _
    21.                 lParam As Any) As Long
    22.  
    23. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
    24.                 ByVal hWndInsertAfter As Long, _
    25.                 ByVal x As Long, ByVal y As Long, _
    26.                 ByVal cx As Long, ByVal cy As Long, _
    27.                 ByVal wFlags As Long) As Long
    28.                
    29. Private Const LVBKIF_SOURCE_NONE = &H0
    30. Private Const LVM_SETBKIMAGEA = (LVM_FIRST + 68)
    31. Private Const LVM_SETBKIMAGE = LVM_SETBKIMAGEA
    32. Private Const LVM_FIRST As Long = &H1000
    33. Private Const LVM_SETBKCOLOR = (LVM_FIRST + 1)
    34. Private Const CLR_NONE = &HFFFFFFFF
    35.  
    36. Private Const SWP_NOMOVE = &H2
    37. Private Const SWP_NOSIZE = &H1
    38. Private Const HWND_BOTTOM = 1
    39.  
    40. Private Type LVBKIMAGE
    41.    uFlags As Long
    42.    hBmp As Long
    43.    pszImage As String
    44.    cchImageMax As Long
    45.    xOffsetPercent As Long
    46.    yOffsetPercent  As Long
    47. End Type
    48.  
    49. Private lhWnd As Long, lhWndLV As Long
    50.  
    51. Private Sub Command1_Click()
    52.     lhWndLV = FindWindowEx(lhWnd, 0&, "SysListView32", vbNullString)
    53.      
    54.     SetParent Me.hwnd, lhWnd
    55.     SetParent lhWndLV, Me.hwnd
    56.    
    57. '     This line will place the controls on the form above the desktop icons
    58. '        SetWindowPos lhWndLV, HWND_BOTTOM, 0&, 0&, 0&, 0&, SWP_NOMOVE Or SWP_NOSIZE
    59.    
    60. '     Trying to clear background - can't get it to work!
    61. '        Dim BKIMG As LVBKIMAGE
    62. '        BKIMG.uFlags = LVBKIF_SOURCE_NONE
    63. '        Call SendMessage(lhWndLV, LVM_SETBKCOLOR, 0&, ByVal CLR_NONE)
    64. '        Call SendMessage(lhWndLV, LVM_SETBKIMAGE, 0&, BKIMG)
    65. '     ----------------------
    66. End Sub
    67.  
    68. Private Sub Form_Load()
    69.     lhWnd = FindWindow("Progman", vbNullString)
    70.     lhWnd = FindWindowEx(lhWnd, 0&, "SHELLDLL_DefView", vbNullString)
    71. End Sub
    72.  
    73. Private Sub Form_Unload(Cancel As Integer)
    74.     SetParent lhWndLV, lhWnd
    75. End Sub

  9. #9

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Form ALWAYS on Bottom

    Quote Originally Posted by bushmobile
    yeah, that's what i meant.

    i've been fiddling around with this - i thought SysListView32 was transparent, and it just displayed the progman background, so i put the form behind it, but then it just disappears.
    Ya I tried that too.
    In web view, if you move the form too quickly in Webview, you'll notice that , the icons doesn't get refreshed correctly.
    That makes me think that, MS is actually using your custom draw idea.

    I'll try your other suggesations and post again.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  10. #10
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Form ALWAYS on Bottom

    An unrefined solution..... If you run it, do not, under any circumstances, exit via the IDE. ALWAYS exit via the system tray icon. Study it first. You have been warned....

    It's very much unrefined so there are a few non-critical bugs. Clicking on the desktop while it's running causes the icons to "disappear". Put the mouse at the edge of the screen and left-click to make them show. (See: Public Sub SetUpNewDesktop). Although it should play any media, the CPU gets overloaded, so it will probably only play WMVs (and mp3s).

    I can't stress exiting via the system tray icon strongly enough. Create a restore point if you intend to run it. You run it at your own risk. Don't blame me if you make a mistake
    Attached Files Attached Files

  11. #11
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Form ALWAYS on Bottom

    Quote Originally Posted by iPrank
    So, I'm guessing, in web view the icons become some 'html thing' ?
    No, they don't. The MS documentation says the Active desktop works "in parallel" with the normal desktop. This sounds like a load of (epithet deleted). I think the document's author couldn't understand a word of what a programmer said. As far as I have been able to make out (and remember ), the normal destop wallpaper is propagated throughout (Progman ?), SHELLDLLDefView and SysListView32. ie, at least SHELLDLLDefView andSysListView32 have a "picture" property. Again, if my memory is correct, Progman holds the desktop background colour.

    SHELLDLLDefView *appears* to contain the Active desktop, not Progman. It's certainly *above* SHELLDLLDefView and *below* andSysListView32. (It doesn't help when your intention is to "shuffle the desktop")

    In the attachment above I used WMP as a visible medium. There's no reson why you can't use any control or OLE object (such as excel). Although I wouldn't advise displaying critical data under an icon

  12. #12

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Form ALWAYS on Bottom

    Thanks schoolbusdriver for your code !

    I faced the problem with mouse/keyboard focus that you mentioned. I will check it again and will see if I can solve the problem.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  13. #13

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Form ALWAYS on Bottom

    Just for the record, I'm posting from the PMs that me and Bushmobile exchanged a while back. Most of my ideas were wrong. But may be it will give someone other ideas.

    Quote Originally Posted by bushmobile
    Did you ever manage to get that behind the desktop stuff working?
    Nope. I couldn't solve the desktop mystry.
    I found that, the wallpaper is hosted on the ShellDLL_DefView. Not as the background of the SysList.
    Exlorer makes the background of the listview transparent.

    I think all keyboard/mouse events ar processed by ShellDll_DefView. So, I tried putting a click through form on ShellDll_DefView and making the listview as it's child. Now the SysList can process keyboard/mouse events 'almost' in all cases.

    Then I put another form as child of ShellDll_DefView. But this didn't show up.

    I think if we can make the background of SysList transparent, it will show the new form behind it.
    Code:
    ShellDllDefView
      |
      |
      --- ClickThrough 'Ghost' form
                   |
                   |
                   --- SysListView32
                   |
                   |
                   --- My form
    VB Code:
    1. ' add 3 Forms and paste this code in Form1
    2. Option Explicit
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. 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
    5. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    6. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    7. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    8. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    9. Dim Progman&
    10. Dim SHELLDLLDefView&
    11. Dim SysListView32&
    12. Dim oldparent&
    13. Const GWL_EXSTYLE = -20, WS_EX_TRANSPARENT = &H20&, WS_EX_LAYERED = &H80000
    14. Const LWA_ALPHA = &H2&
    15. Private Sub Form_Load()
    16.     Progman& = FindWindow("Progman", vbNullString)
    17.     SHELLDLLDefView& = FindWindowEx(Progman&, 0&, "SHELLDLL_DefView", vbNullString)
    18.     SysListView32& = FindWindowEx(SHELLDLLDefView&, 0&, "SysListView32", vbNullString)
    19.     '
    20.     Load Form2
    21.     Form2.WindowState = vbMaximized 'This doesn't work
    22.     Form2.Show
    23.     SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
    24.     SetLayeredWindowAttributes hwnd, 0, 255, LWA_ALPHA
    25.     '
    26.     Form3.Show
    27.     SetParent Form3.hwnd, Form2.hwnd 'this form doesn't show-up
    28.     '
    29.     SetParent Form2.hwnd, SHELLDLLDefView
    30.     oldparent = SetParent(SysListView32&, Form2.hwnd)
    31.     '
    32. End Sub
    33.  
    34. Private Sub Form_Unload(Cancel As Integer)
    35.     SetParent SysListView32&, oldparent
    36.     Unload Form2
    37.     Unload Form3
    38. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  14. #14
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Form ALWAYS at Bottom

    I wish i could stick to my own warnings. Just exited from my code via the IDE . I never did finish the code in the attachment properly, as I started working on the HTML version when I saw the CPU usage. Anyway - a belated (3 years old ?) attempt to stop the icons vanishing:-

    in the module VideoDesktop add:-

    VB Code:
    1. Public WhatsGotFocus As Integer

    in frmStartup add:-

    VB Code:
    1. Private Sub Form_LostFocus()
    2.    WhatsGotFocus = 0
    3. End Sub
    4.  
    5. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    6. 'This procedure receives the callbacks from the System Tray icon.
    7.    Dim msg As Long
    8.  
    9. 'Add this:
    10.    WhatsGotFocus = 1 '<------------------------
    11.  
    12. 'The value of X will vary depending upon the scalemode setting
    13.    If Me.ScaleMode = vbPixels Then
    14.       msg = X
    15.    Else
    16.       msg = X / Screen.TwipsPerPixelX
    17.    End If
    18.    If msg = WM_RBUTTONUP Then  'Display popup menu
    19.       Call SetForegroundWindow(Me.hwnd)
    20.       Me.PopupMenu Me.mnuPopMain
    21.    End If
    22. End Sub

    in frmDeskHolder add:-

    VB Code:
    1. Private Sub Form_LostFocus()
    2.    If WhatsGotFocus = 1 Then
    3.       'Do nothing - the systray icon has the focus.
    4.       'Can't exit if it can't get the focus.
    5.    Else
    6.       Me.SetFocus 'Only applies to this app.
    7.    End If
    8. End Sub

    It still has other problems... you can't drag/drop the desktop icons, and right-clicks don't work on the desktop. One day, all these probs may be solved...

    (Just found some more code which was an attempt to create a "pseudo desktop". My idea was to leave the "real" desktop icons invisible and have a second more functional set replacing them while the program ran...)

    EDIT:- The added code above needs modifying to account for the frmPlaylists form as follows:-
    VB Code:
    1. Private Sub Form_LostFocus()
    2.    If WhatsGotFocus = 1 Then
    3.       'Do nothing - the systray icon has the focus.
    4.       'Can't exit if it can't get the focus.
    5.    Else
    6.       If frmPlaylists.Visible = False Then
    7.          Me.SetFocus 'Only applies to this app.
    8.       End If
    9.    End If
    10. End Sub
    Last edited by schoolbusdriver; Aug 28th, 2006 at 09:50 AM.

  15. #15
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Form ALWAYS at Bottom

    A bit more on the code in the attachment and the additional bits above:-

    If you comment out "Me.SetFocus 'Only applies to this app." run it in the IDE, and alternately click on the "desktop with icons" and the edge of the screen, in the IDE's Project window you can see the focus change between frmDeskHolder and frmVideoDesk.

    However, frmVideoDesk's got/lost focus events don't fire. This isn't a problem with frmDeskHolder, so any event handling code can be put in there.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width