Question

I've built a simple application that applies grid-lines to an image or just simple colors for use as desktop wallpaper. The idea is that the desktop icons can be arranged within the grid. The problem is that depending on more things than I understand the actual spacing in pixels seems to be different from system to system. I've learned that at least these things play a factor:

  • Resolution (duh)
  • Taskbar size and placement
  • Fonts

There has to be more than this. Maybe there's some api call that I don't know about?

Was it helpful?

Solution

there are a 1001 ways to get/set this (but I only know 2) :-D

Windows Register:

HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics

values are IconSpacing and IconVerticalSpacing

by code:

using System.Management;

public string GetWinIconSpace()

{

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2","SELECT * FROM Win32_Desktop"); 

foreach (ManagementObject wmi in searcher.Get())
{
    try
    {

        return "Desktop Icon Spacing: " + wmi.GetPropertyValue("IconSpacing").ToString();

    }

    catch { }

}

return "Desktop Icon Spacing: Unknown";

}

and the 3rd that I never tried you can find it here

OTHER TIPS

They might also be a size problem due to scaling algorithm if the requested size of the icon is not available.
(since an icon file is actually a collection of icons, as explained in this thread about Icons and cursors know where they came from, from the The Old New Thing)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top