Turn auto arrange for icons on desktop off in program.

Anyone know how to turn off the auto arrange for icons on desktop inside a program? any Win32 API for that? please let me know or show me the method if you know how thanks.
waimunAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
connexConnect With a Mentor Commented:

Ok.. this has drawn my attention and I played around a bit
today. I found a way to actually change the setting but still loking for a way to change it in the context menu as well.
Here's what I got so far:

CWnd *dsk = (CWnd *)FindWindow("Progman","Program Manager");
CWnd *dsk1 = (CWnd *)dsk->GetWindow(GW_CHILD);
CWnd *ExpList = (CWnd *)dsk1->GetWindow(GW_CHILD);
ExpList -> ModifyStyle(LVS_AUTOARRANGE,0,0);

This changes the setting, you can check it with spy++, but
does not modify the context menu until restart.
I'm working on that too, but it might turn out to use some bad messing around.

0
 
Tommy HuiEngineerCommented:
The way I would do it is to use

  HWND desktop = GetDesktopWindow();
  SetWindowLong(desktop, GWL_STYLE, GetWindowLong(desktop, GWL_STYLE) & ~LVS_AUTOARRANGE);


0
 
waimunAuthor Commented:
Hi thui,
Have you tried the solution you gave? In fact I tried it before, and even use FindWindow for 'progman' and get its child window to locate the desktop HWND. All these fails, I believed that this got to do with the reason that this is not a normal Listview class, it is a desktop and hence the solution given above of similar type will fail... May be I have did the wrong thing, you go and try and if yours work, send your code to me at email: waimun@cheerful.com and I will give you an 'A' for it if it works. Anyway thanks. I believe, there is something got to do with SysListView32 class, and that desktop is from another process...tricky huh!
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
waimunAuthor Commented:
I'm raising the point for better solution...
0
 
waimunAuthor Commented:
Adjusted points to 150
0
 
waimunAuthor Commented:
Adjusted points to 200
0
 
waimunAuthor Commented:
Hi connex, I've tried your solution, but it some how fails to work...I'm not sure whats went wrong. I've tried using ModifyStyle() and also SetWindowLong, and even tried using PostMessage but all fails. May be you can send me the code and let me try out. Email: waimun@cheerful.com. If it works, I'll definitely give you 'A'. When trying your solution, SPY++ did not indicate the changes as you claimed, may be something went wrong in my code. By the way, what I really want is tohas the effect immediately, i.e. when the program changes the auto arrange option of the desktop, I should expect that I can move the icon anywhere I like on the desktop without being auto arrange back. I know that this is possible using window hooks and of course a DLL file. But, I hope to be able to do it without the hassle of DLL file. Thanks!
0
 
connexCommented:
The effect is immediately. The third parameter 0 indicates that the explorer shall
refresh the display. I will mail you my sample code on Monday when i'm back in my office.


0
 
waimunAuthor Commented:
Thanks a lot connex. By the way, out of curiosity, there is a computer based vision group out there call Connex in USA, that provide vision supports. Are u anyway related to them?
0
 
connexCommented:
Ok just sent the source code.
No i'm not related to them .) There are several companies around
with the name connex. But I took the name simply from
my desk :-) It's the brandname of my phone.

0
 
waimunAuthor Commented:
thanks connex...evaluating...give u reply in 1 day time
0
 
waimunAuthor Commented:
hi connex, I have evaluated your source code but it didn't work out. Don't know what is wrong. May be u are using NT, while i'm using Window 95. I think this makes the differences. Even Spy++ doesn't show any thing. I'm very sure that the ExpList is a SysListView32 class as i used GetWindowClass to counter check. But nothing works out. Anyway for your kind help and hard work I will still give u the 'A'. Thanks! By the way, may be u send the executable file for me to test? Thanks!!!
P.S.-Maybe Window 95 doesn't allow the changes to happen... In future if you know the solution, or something regarding this, do drop me an email and I will be very much appreciated! Thanks...
0
 
connexCommented:
hmm i will check this tomorrow on my W95 notebook. maybe i can lighten this a bit .)

0
All Courses

From novice to tech pro — start learning today.