Results 1 to 6 of 6

Thread: Make program stick to desktop and stay there no matter what whether refresh restart

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2014
    Posts
    33

    Make program stick to desktop and stay there no matter what whether refresh restart

    exactly what my topic was how do i make a program stick to my desktop no matter if i restart y computer log off refresh my desktop and also how do i make it invisible in the task bar im trying to make a docking program for my desktop with cool effects but i do not know how to make it stick to my desktop please give me the code in idiot form and tell me exactly where to put it please

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,677

    Re: Make program stick to desktop and stay there no matter what whether refresh resta

    This code "pins" the form to the Desktop:
    Code:
    'API
    Declare Function SetParent Lib "user32.dll" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    
    Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    
    'Code
    SetParent(Me.Handle, FindWindow("ProgMan", Nothing))
    Me.SendToBack()
    But in order for your program to automatically start when the computer is restarted then you'll need to add your program to registry, which I don't know how to do, but Google is your friend.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2014
    Posts
    33

    Re: Make program stick to desktop and stay there no matter what whether refresh resta

    it gives me error declaration expected and syntax error line 13 and declaration on line 12

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

    Re: Make program stick to desktop and stay there no matter what whether refresh resta

    try this:

    Code:
    Imports Microsoft.Win32
    
    Public Class Form1
    
        'API
        Declare Function SetParent Lib "user32.dll" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
        Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    
        Dim regKeyCU As RegistryKey = Registry.CurrentUser
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            SetParent(Me.Handle, FindWindow("ProgMan", vbNullString))
            Dim regKey As RegistryKey = regKeyCU.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    
            'change "test key" to name of your application
            If Not regKey.GetValueNames.Contains("test key") Then
                regKey.SetValue("test key", Application.ExecutablePath)
            End If
    
        End Sub
    
    End Class
    Last edited by .paul.; Feb 28th, 2015 at 02:11 PM.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2014
    Posts
    33

    Re: Make program stick to desktop and stay there no matter what whether refresh resta

    now my forms not even visible does it have to do with the progman thing cuz i tried changing that to my aplication name too and it still doesnt snap to the center of my desktop

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,399

    Re: Make program stick to desktop and stay there no matter what whether refresh resta

    progman is the className of the listview which forms the desktop as you see it.

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