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:
Option Explicit
' Add 2 command buttons in the form
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
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.
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.
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.
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:
Option Explicit
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 Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
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.
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
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
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.
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:
' add 3 Forms and paste this code in Form1
Option Explicit
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 Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
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:
Public WhatsGotFocus As Integer
in frmStartup add:-
VB Code:
Private Sub Form_LostFocus()
WhatsGotFocus = 0
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'This procedure receives the callbacks from the System Tray icon.
Dim msg As Long
'Add this:
WhatsGotFocus = 1 '<------------------------
'The value of X will vary depending upon the scalemode setting
If Me.ScaleMode = vbPixels Then
msg = X
Else
msg = X / Screen.TwipsPerPixelX
End If
If msg = WM_RBUTTONUP Then 'Display popup menu
Call SetForegroundWindow(Me.hwnd)
Me.PopupMenu Me.mnuPopMain
End If
End Sub
in frmDeskHolder add:-
VB Code:
Private Sub Form_LostFocus()
If WhatsGotFocus = 1 Then
'Do nothing - the systray icon has the focus.
'Can't exit if it can't get the focus.
Else
Me.SetFocus 'Only applies to this app.
End If
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:
Private Sub Form_LostFocus()
If WhatsGotFocus = 1 Then
'Do nothing - the systray icon has the focus.
'Can't exit if it can't get the focus.
Else
If frmPlaylists.Visible = False Then
Me.SetFocus 'Only applies to this app.
End If
End If
End Sub
Last edited by schoolbusdriver; Aug 28th, 2006 at 09:50 AM.
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.