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. Windows API
  4. Windows Desktop Align Icons To Grid

Windows Desktop Align Icons To Grid

Scheduled Pinned Locked Moved Windows API
csharpcssjsonhelp
3 Posts 2 Posters 24 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
    Jim Thomson
    wrote on last edited by
    #1

    I'm working on a program for myself that saves a desktop layout and restores it using API calls to the Desktop's listview control. I'm working on a Windows 7 machine. To use my program I have to right click the desktop, select View, uncheck the Align Icons to Grid option, and then run my program. It works find at that point. I would like to toggle the "Align Icons to Grid" setting in code but haven't been able to identify the correct API messages to send to the listview control. I tried clearing and setting the LVS_EX_GRIDLINES style with the LVM_SETEXTENDEDLISTVIEWSTYLE windows message but that just turns the grid lines on and off. I've looked at quite a few articles and posts here but haven't yet found a solution. It seems like I'm just plain missing something. I'm working in VB6 but I can probably translate .NET VB or C. I know I could download something from the web but with all the nasty stuff out there these days and too much time on my hands I thought I would give it a shot. Any help will be greatly appreciated.

    S 1 Reply Last reply
    0
    • J Jim Thomson

      I'm working on a program for myself that saves a desktop layout and restores it using API calls to the Desktop's listview control. I'm working on a Windows 7 machine. To use my program I have to right click the desktop, select View, uncheck the Align Icons to Grid option, and then run my program. It works find at that point. I would like to toggle the "Align Icons to Grid" setting in code but haven't been able to identify the correct API messages to send to the listview control. I tried clearing and setting the LVS_EX_GRIDLINES style with the LVM_SETEXTENDEDLISTVIEWSTYLE windows message but that just turns the grid lines on and off. I've looked at quite a few articles and posts here but haven't yet found a solution. It seems like I'm just plain missing something. I'm working in VB6 but I can probably translate .NET VB or C. I know I could download something from the web but with all the nasty stuff out there these days and too much time on my hands I thought I would give it a shot. Any help will be greatly appreciated.

      S Offline
      S Offline
      Staffan Bruun
      wrote on last edited by
      #2

      It seems you need to toggle the LVS_AUTOARRANGE flag from the window style. Don't know how to do that in VB, though. The Windows C API has the following functions:

      LONG style = GetWindowLong(hwnd, GWL_STYLE);
      style &= LVS_AUTOARRANGE;
      SetWindowLong(hwnd, GWL_STYLE, style);

      J 1 Reply Last reply
      0
      • S Staffan Bruun

        It seems you need to toggle the LVS_AUTOARRANGE flag from the window style. Don't know how to do that in VB, though. The Windows C API has the following functions:

        LONG style = GetWindowLong(hwnd, GWL_STYLE);
        style &= LVS_AUTOARRANGE;
        SetWindowLong(hwnd, GWL_STYLE, style);

        J Offline
        J Offline
        Jim Thomson
        wrote on last edited by
        #3

        Thanks. I did find that and tried it but had a problem with it. While it did actually toggle the auto arrange functionality, the change did not show up in the desktop menu that comes up when you right click an empty icon position on the desktop. That menu item is still checked even when auto arrange is off and vice versa. The desktop doesn't expose its menu so I searched the desktop for an unused icon position and used sendinput to move the mouse pointer there, right click, and then send key strokes to manipulate the menu itself. It's a bit messy but it works reliably. Fortunately I already had code to do the sendinput from another project. Thanks for taking the time to answer.

        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