4

A reminder about the correct way of accessing and manipulating the position of i...

 2 years ago
source link: https://devblogs.microsoft.com/oldnewthing/20211122-00/?p=105948
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

A reminder about the correct way of accessing and manipulating the position of icons on the desktop

Raymond

November 22nd, 2021

A customer reported that their code to manipulate the position of icons on their desktop stopped working. It had worked “just fine” until the 19H1 update. The escalation engineer debugged the program and discovered that what it does is that it looks for its icons on the desktop and repositions them by hunting for the ListView control that holds the desktop icons, and then sending it a LVM_SET­ITEM­POSITION. They claim that this stopped working, and they want to know why.

It stopped working because it never was guaranteed to work in the first place.

Starting in Windows 10 version 1809, there were changes to the way that the positions of the desktop icons are managed, and one of the consequences is that if you try to manipulate the icon positions by talking directly to the ListView control, those changes aren’t taken into account by the icon management code, and your changes are lost.

The solution is to stop sending messages to an undocumented window to take advantage of internal implementation details, because the nature of implementation details is that they change when the implementation changes.

The supported API for manipulating desktop icons is IFolder­View::Select­And­Position­Items, and that API still works. (As it should, because it’s the supported API.) You can look at some code I wrote many years ago for manipulating the position of desktop icons to see how it’s done.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK