Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Move desktop icons

Move desktop icons

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jarek G
    wrote on last edited by
    #1

    Is there a easy way to acces desktop icons and move them around in x and y pos? I think I saw a program that did that a while ago. /Jarek He believed the commercials that said drink beer, get laid but at closin' time he was alone, he didn't get paid. Last night his lover was a razorblade.. "Dan Reed song Mix it up"
    What do you want to patch today?

    D 1 Reply Last reply
    0
    • J Jarek G

      Is there a easy way to acces desktop icons and move them around in x and y pos? I think I saw a program that did that a while ago. /Jarek He believed the commercials that said drink beer, get laid but at closin' time he was alone, he didn't get paid. Last night his lover was a razorblade.. "Dan Reed song Mix it up"
      What do you want to patch today?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      How about getting a handle to the desktop window, and enumerating its child windows?

      J 1 Reply Last reply
      0
      • D David Crow

        How about getting a handle to the desktop window, and enumerating its child windows?

        J Offline
        J Offline
        Jarek G
        wrote on last edited by
        #3

        Okey sounds interessting but do you have some sample code or an example? I never did it before! /Jarek He believed the commercials that said drink beer, get laid but at closin' time he was alone, he didn't get paid. Last night his lover was a razorblade.. "Dan Reed song Mix it up"
        What do you want to patch today?

        D 1 Reply Last reply
        0
        • J Jarek G

          Okey sounds interessting but do you have some sample code or an example? I never did it before! /Jarek He believed the commercials that said drink beer, get laid but at closin' time he was alone, he didn't get paid. Last night his lover was a razorblade.. "Dan Reed song Mix it up"
          What do you want to patch today?

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Something like: HWND hDesktop = GetDesktopWindow(); EnumChildWindows(hDesktop, EnumProc, 0); BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam ) { return TRUE; // to continue enumeration } I've not ever needed to do something like this before, but I suspect it will return more windows than just the icons. Top-level applications probably have the desktop as their parent window, too.

          J 1 Reply Last reply
          0
          • D David Crow

            Something like: HWND hDesktop = GetDesktopWindow(); EnumChildWindows(hDesktop, EnumProc, 0); BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam ) { return TRUE; // to continue enumeration } I've not ever needed to do something like this before, but I suspect it will return more windows than just the icons. Top-level applications probably have the desktop as their parent window, too.

            J Offline
            J Offline
            Jarek G
            wrote on last edited by
            #5

            Thank you David! I tryed that to :-) and its just like you said it return manny windows, to manny. But the search goes on I found a VB program that doing this and I am on my way to disassamble the code! I think I have something to learn here It started as an effort to make a funny program but now its a chalange! /Jarek He believed the commercials that said drink beer, get laid but at closin' time he was alone, he didn't get paid. Last night his lover was a razorblade.. "Dan Reed song Mix it up"
            What do you want to patch today?

            D 1 Reply Last reply
            0
            • J Jarek G

              Thank you David! I tryed that to :-) and its just like you said it return manny windows, to manny. But the search goes on I found a VB program that doing this and I am on my way to disassamble the code! I think I have something to learn here It started as an effort to make a funny program but now its a chalange! /Jarek He believed the commercials that said drink beer, get laid but at closin' time he was alone, he didn't get paid. Last night his lover was a razorblade.. "Dan Reed song Mix it up"
              What do you want to patch today?

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Try this: LPMALLOC pMalloc; LPSHELLFOLDER pDesktopFolder = NULL; HRESULT hResult; LPITEMIDLIST pidlItems = NULL; LPENUMIDLIST ppenum = NULL; ULONG celtFetched; SHFILEINFO fi = {0}; hResult = SHGetMalloc(&pMalloc); if (NOERROR == hResult) { hResult = SHGetDesktopFolder(&pDesktopFolder); if (NOERROR == hResult) { hResult = pDesktopFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &ppenum); if (NOERROR == hResult) { while (hResult = ppenum->Next(1, &pidlItems, &celtFetched) == S_OK && (celtFetched) == 1) { SHGetFileInfo((const char *) pidlItems, 0, &fi, sizeof(fi), SHGFI_PIDL | SHGFI_ICON | SHGFI_DISPLAYNAME); TRACE2("Icon handle for ]%s[ = %#x\n", fi.szDisplayName, fi.hIcon); pMalloc->Free(pidlItems); } ppenum->Release(); } pDesktopFolder->Release(); } }

              J 1 Reply Last reply
              0
              • D David Crow

                Try this: LPMALLOC pMalloc; LPSHELLFOLDER pDesktopFolder = NULL; HRESULT hResult; LPITEMIDLIST pidlItems = NULL; LPENUMIDLIST ppenum = NULL; ULONG celtFetched; SHFILEINFO fi = {0}; hResult = SHGetMalloc(&pMalloc); if (NOERROR == hResult) { hResult = SHGetDesktopFolder(&pDesktopFolder); if (NOERROR == hResult) { hResult = pDesktopFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &ppenum); if (NOERROR == hResult) { while (hResult = ppenum->Next(1, &pidlItems, &celtFetched) == S_OK && (celtFetched) == 1) { SHGetFileInfo((const char *) pidlItems, 0, &fi, sizeof(fi), SHGFI_PIDL | SHGFI_ICON | SHGFI_DISPLAYNAME); TRACE2("Icon handle for ]%s[ = %#x\n", fi.szDisplayName, fi.hIcon); pMalloc->Free(pidlItems); } ppenum->Release(); } pDesktopFolder->Release(); } }

                J Offline
                J Offline
                Jarek G
                wrote on last edited by
                #7

                Thank you David! It works I can get the Desktopicons :-) I saw similar code in Q&A on MSDN Thank you again your code was better. /Jarek He believed the commercials that said drink beer, get laid but at closin' time he was alone, he didn't get paid. Last night his lover was a razorblade.. "Dan Reed song Mix it up"
                What do you want to patch today?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups