dcsimg
Results 1 to 22 of 22

Thread: [RESOLVED] How to create your own desktop?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Resolved [RESOLVED] How to create your own desktop?

    Ok, I'm back on the crazy bandwagon again and trying to do the impossible. I want to be able to create a desktop that sits on top of the real desktop. I would eventually like the icons to be on that desktop and have it perform the way the normal desktop does.

    I talked with someone who said they worked on a project like that, but I can't' remember who? My apologies. I have an idea of how to do the window that would replace the desktop, but the hard part would be getting the icons there and being able to accept new icons. I know it can be done and I don't think you have to be a genius to do it. One thing about it, it would be capable of doing outstanding graphics on the wallpaper

    Please give me your thoughts, ideas, or anything. This would be a big undertaking because of all the unknowns. And as always, I appreciate any thoughts you might have concerning this!

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    Just for fun, I made a window that sets over the desktop and I already have it integrated with the wallpaper changer. Now when the wallpaper thread fires up, it changes the background image of the form instead of the desktop...

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    I have now found out how to make the "desktop window" sit below running applications. So right now it appears like the desktop window because it's on top of the desktop, but below the applications. The next thing is to find out how to show the desktop icons on the newly created Desktop Window. And I'm sure, that's the hard part, lol
    Last edited by jumper77; Mar 15th, 2019 at 08:02 AM.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,046

    Re: How to create your own desktop?

    The Windows desktop is a ListView control, not a Form... Beyond that I'm not sure how you can do that.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    Hi Paul, thanks for your input. Yes it is a list view. "Program Manager" (Progman) is the parent, then SHELLDLL_DefView FolderView and SysListView32. Right now I'm working on finding a handle for all those.

    Code:
            Dim hwndIcon As IntPtr = FindWindow("Progman", "")
            hwndIcon = FindWindowEx(hwndIcon, IntPtr.Zero, "SHELLDLL_DefView", "")
            hwndIcon = FindWindowEx(hwndIcon, IntPtr.Zero, "SysListView32", "FolderView")
    I'm still working on getting all the user32 invokes/subs/functions so I can get the handles. In particular, I'm looking for EnumWindowsProc right now and should have it in a few minutes. Once I can get past this part, it should get easier (at least for a short while). But even in the state that it is, I'm running the program for fun and I forget that it's not actually the desktop because the only thing that is different is there are no desktop icons. Everything else looks the same

    Oh well.... back to work

  6. #6
    Addicted Member
    Join Date
    Jun 2018
    Posts
    192

    Re: How to create your own desktop?

    Here is a start. Double click an icon to launch the shortcut.

    Name:  desktop icons1.png
Views: 73
Size:  19.5 KB

    Code:
    Imports System.IO
    
    Public Class Form6
        Private WithEvents ListView1 As New ListView With {.Parent = Me, .Location = New Point(0, 0), .Dock = DockStyle.Fill}
        Private DeskTopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    
        Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Text = "Desktop Icons"
            Dim ImageList1 As New ImageList
            ListView1.LargeImageList = ImageList1
            ListView1.SmallImageList = ImageList1
            ListView1.View = View.LargeIcon
    
            Dim dirInfo As DirectoryInfo
            Dim fileInfo As FileInfo
            Dim exeIcon As System.Drawing.Icon
    
            dirInfo = New DirectoryInfo(DeskTopPath)
    
            For Each fileInfo In dirInfo.GetFiles
                If (Not String.IsNullOrEmpty(fileInfo.Extension)) Then
    
                    exeIcon = System.Drawing.Icon.ExtractAssociatedIcon(fileInfo.FullName)
    
                    If (ImageList1.Images.ContainsKey(fileInfo.FullName)) Then
                        ListView1.Items.Add(fileInfo.Name, fileInfo.FullName)
                    ElseIf (Not exeIcon Is Nothing) Then
                        ImageList1.Images.Add(fileInfo.FullName, exeIcon)
                        ListView1.Items.Add(fileInfo.Name, fileInfo.FullName)
                    Else
                        ListView1.Items.Add(fileInfo.Name)
                    End If
    
                End If
            Next
        End Sub
    
        Private Sub ListView1_DoubleClick(sender As Object, e As EventArgs) Handles ListView1.DoubleClick
            'launch the shortcut
            Dim proc As Process = New Process()
            proc.StartInfo.FileName = DeskTopPath & "\" & ListView1.SelectedItems(0).Text
            proc.Start()
        End Sub
    End Class

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    Hey Tom! Now I remember. It was you that talked about having done it before or come close to it. Cool. Thanks for the code, going to test it in just a minute... brb

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    Ok, just got it to work and it's AWESOME!!! Thank you for that! I now have lots of stuff to play with ahead of me.

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    I was going to get you a screen shot, but when I added your code, changing the background image on the form stopped working, so give me some time and I'll try to get things working

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    Ok, got it working... Took me a sec to realize what I needed to do. So here's a screen shot that's the result of our combined code. With the exception of the icons being so small, you can't tell it's not the real desktop. And I can fix the icon size...

    Name:  Clipboard-1.jpg
Views: 67
Size:  39.4 KB

    What amazed me was I realized that the entire desktop is just a ListView. The whole thing, lol.

    Now for the big question... Why are the icons just shortcuts and not the regular kind too? Is that information located somewhere else?

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    I take that back... they are not all links. There are some regular files there, but not all of them. What's up???

  12. #12
    Addicted Member
    Join Date
    Jun 2018
    Posts
    192

    Re: How to create your own desktop?

    Quote Originally Posted by jumper77 View Post
    I take that back... they are not all links. There are some regular files there, but not all of them. What's up???
    LOL. I said it was a start...

    One needs to decide what is it exactly... re-invent the desktop and make it better?

    How do you plan to make it work as a desktop exactly? What features will work and what wont? Are you going to hide the taskbar? How do you stop other applications from taking over?

    There are hundreds of possible ways and problems of course. Each major feature can determine how the gui etc should be.

    There is more than one icon size and there are windows settings for how big they are on the desktop screen and etc. Each app has their own. You have to get those icons and show them. The example uses the list view and that uses imagelist. So there are two controls to learn and the controls each have their ways and limits.

    The icons are available several ways. Apps have their own icons and some apps only give one 16 bit and some give 4 or more if you look at explorer it has hundreds of icons. Windows has some stores of icons.


    https://social.msdn.microsoft.com/Fo...orum=vbgeneral


    https://social.msdn.microsoft.com/Fo...orum=vbgeneral


    There is more than one type of shortcut on the desktop some are .ink and some might be url, jpg, .txt or etc. The example will run .ink extensions and some other things. You will have to figure what you want to do with it all.

    You dont have to use a list view. Maybe todays vb has a better way? Or draw it all yourself if you want real jungle adventure including mouse events. And depends on what else you plan to do. Like move the icons add delete copy etc. Large small left right here there... depends on how much you know, how long to take... etc.

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    Haha... Yes, it may be a big can of worms that I wish I never opened, but I'm still going to play with it some more. I found out how to get the missing files. They are directories (no extension). And windows won't extract an icon without an extension. I didn't know that until just a while ago. I can find all the directories and their names, but it looks dumb to have a file there without an image to go with it.

    One thing I'm thinking of is maybe there's a way to get the current Windows folder icon. I use a modified version, but that info has to be stored somewhere? If I can get my hands on the current folder icon I could add that with the folder name. yada,k yada...

    But you are right. I should probably take a minute out and see if I SHOULD do this, or I want to. There's no doubt that in the long run, it's going to be a LOT of work. And I may get towards the end of all that work and decide I can't do it (that's tough).

    So thank you for slapping me 'upside the head. I will give it some thought my friend...

    Edit: You asked about the taskbar. Well, the taskbar will work as it always has. You can still get to everything. I tested with hiding the taskbar and auto-hide worked fine. All I was kind of thinking about was to have something like a "living" Wallpaper. Hope that makes sense. But everything that's in windows is still there. Think of it as it's like windows put on some new clothes, but everything else is the same
    Last edited by jumper77; Mar 15th, 2019 at 02:28 PM.

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: How to create your own desktop?

    Tom, I don't think I'm going to go through with this project... I don't want to re-write windows and I think this project would have a high frustration level (something I don't need). But I will say it was fun playing with it today I think my time would be better spent optimizing the graphics we were working on and continue down that path.

    So thanks a bunch!

  15. #15
    Addicted Member Peter Porter's Avatar
    Join Date
    Jul 2013
    Posts
    207

    Re: How to create your own desktop?

    Quote Originally Posted by jumper77 View Post
    Hey Tom! Now I remember. It was you that talked about having done it before or come close to it. Cool. Thanks for the code, going to test it in just a minute... brb
    Hey, Jumper. I don't know if Tom replicated the desktop, but I did tell ya that I slapped one together which I haven't been able to find. Anyway, if you want to get the desktop icons current size, you can do this with the below code:

    With a new windows form application, add a class called RegistryTools.
    Code:
    Imports Microsoft.Win32
    
    Public Class RegistryTools
        '// Get a registry value for the Desktop
        Public Shared Function GetRegistryValue(ByVal hive As RegistryKey, ByVal subkey_name As String, ByVal value_name As String, ByVal default_value As Object) As Object
            Dim subkey As RegistryKey = hive.OpenSubKey(subkey_name, False)
            Dim result As Object = subkey.GetValue(value_name, default_value)
            subkey.Close()
            Return result
        End Function
    End Class
    Now add a label to your project's form, then this code:
    Code:
    Imports Microsoft.Win32
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim size_string As Object = RegistryTools.GetRegistryValue(Registry.CurrentUser, "Software\Microsoft\Windows\Shell\Bags\1\Desktop\", "IconSize", -1)
            Label1.Text = size_string.ToString() + " x " + size_string.ToString()
        End Sub
    End Class
    To know what recycle bin icon to use (full, empty), add another label to the above project... have your project reference "Microsoft Shell Controls And Automation"... Imports Shell32, and within form1 add:
    Code:
     Dim shell As Shell = New Shell()
            Dim recycleBin As Folder = shell.[NameSpace](10)
            Dim itemsCount As Integer = recycleBin.Items().Count
            If itemsCount > 0 Then
                If itemsCount = 1 Then
                    Label2.Text = "Recycle Bin has 1 item!"
                Else
                    Label2.Text = "Recycle Bin has " + CStr(itemsCount) + " items!"
                End If
            Else
                Label2.Text = "Recycle Bin is empty."
            End If
        End Sub
    Last, the extra large 256x256 Windows desktop icons for resizing are located within the imageres.dll at C:\Windows\System32 and C:\Windows\SysWOW64.

    On Windows 7, the extra large icon files in this DLL don't have file extensions. Not sure if that's the same with Windows 8 and 10. That can easily be fixed by programmically adding ".ico" to them. The only thing you would have to figure out is how to extract these icons from the DLL.
    Last edited by Peter Porter; Mar 15th, 2019 at 05:54 PM.

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: [RESOLVED] How to create your own desktop?

    Hey, Jumper. I don't know if Tom replicated the desktop, but I did tell ya that I slapped one together which I haven't been able to find.
    Hi Peter, yep it was you then because I remember you saying you couldn't find it. That's for the code, I will check it out. And about getting icons from the DLL's, I wrote a program that did it many years ago, and like everything else, don't remember how I did it in the least bit, haha. But I know there are examples out there on the net.

    I would be ahead of the game in one way only when it came to building this. I already have the code in my program to empty the recycle bin. Seems like it was just a couple lines of code.

    I could easily go back and forth about whether to do this project or not. And the other reason is just to say I did it! haha. Also, I thought of a way I might still be able to get the icons. My next move was going to be giving the folders an extension before displaying them, extract the icon, then go back to the original filename. I think it might work. When I tried to extract the icon with no extension, Windows said that it couldn't find the file. But if I wasn't trying to extract an icon, it saw it just fine, lol.

    I'm still on the fence about it I guess. I could also tell myself that all I have is time. I've got a lot of that

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: [RESOLVED] How to create your own desktop?

    Ok, so I'm putting it all back together (lol) and now the form will not show the backgroundimage. I have a staring image at design time and it shows up, but not when the program runs. Anyone have an idea about what might be happening?

  18. #18
    Addicted Member Peter Porter's Avatar
    Join Date
    Jul 2013
    Posts
    207

    Re: [RESOLVED] How to create your own desktop?

    Hey jumper, I mistakenly left something out with my code above for getting a desktop's current icon size when your app starts up. Adding to my code above, the below code will insure the code above gets the current icon size:

    First add Imports System.Runtime.InteropServices, and below:
    Code:
    <DllImport("user32")>
        Private Shared Function PostMessage(ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
        End Function
    
        <DllImport("user32.DLL")>
        Public Shared Function FindWindow(ByVal lpszClass As String,
                                          ByVal lpszWindow As String) As IntPtr
        End Function
    
        <DllImport("user32.DLL")>
        Public Shared Function FindWindowEx(ByVal hwndParent As IntPtr,
                                            ByVal hwndChildAfter As IntPtr,
                                            ByVal lpszClass As String,
                                            ByVal lpszWindow As String) As IntPtr
        End Function

    Next within Form1 add the following code:
    Code:
    Dim d As IntPtr = FindWindow("Progman", "Program Manager")
            d = FindWindowEx(d, IntPtr.Zero, "SHELLDLL_DefView", Nothing)
            d = FindWindowEx(d, IntPtr.Zero, "SysListView32", Nothing)
            PostMessage(d, &H100, New IntPtr(&H74), IntPtr.Zero)
    Basically what the above code does is refresh your desktop, like when you press F5, but it only works once for some reason. You only need it at start-up anyway.

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: [RESOLVED] How to create your own desktop?

    Hi Peter. Thank you for the code. I just now finished a small context menu for changing the icon size on the fake desktop, lol. I am having a blast with this. There is one thing I wish I could do. Maybe you know how to do it? It would save me a lot of heartache if when I right clicked the desktop or icon, that the standard context menu would show. That way it could actually handle all the work. I thought about faking it using something like sendKeys (although I've never used that), but I'm not sure it would be visible.

    The fake desktop is really staring to look good and I'm having fun

  20. #20

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: [RESOLVED] How to create your own desktop?

    Peter, what does this code do?

    Code:
            Dim d As IntPtr = FindWindow("Progman", "Program Manager")
            d = FindWindowEx(d, IntPtr.Zero, "SHELLDLL_DefView", Nothing)
            d = FindWindowEx(d, IntPtr.Zero, "SysListView32", Nothing)
            PostMessage(d, &H100, New IntPtr(&H74), IntPtr.Zero)
    I put it in my code but didn't notice anything happening?

  21. #21
    Addicted Member Peter Porter's Avatar
    Join Date
    Jul 2013
    Posts
    207

    Re: [RESOLVED] How to create your own desktop?

    Basically it refreshes a users desktop, kinda like if you would press F5. If you use my previous code from a few days ago without this, you wont always get the current icon size. You have to refresh Windows desktop to get the current size, which this code does. I only have it in Form_Load. Anywhere else it wont always work, but you only need to refresh the real desktop only once anyway when your app starts up.
    Last edited by Peter Porter; Mar 17th, 2019 at 03:19 PM.

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,055

    Re: [RESOLVED] How to create your own desktop?

    Ok thanks. I already have code that does that though. In my application I've used it a lot. Like when you change icons, lol. The reason I started to work on this software was to allow an end user to put their desktop icons in Listview mode. From there it's grown a lot. But I try to make sure that whatever is added has something to do with the desktop

    Edit: Were you able to think of any way I could get the default context menus up for the icons and desktop?

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