Page 1 of 1

WinAPI for AutoArrange Desktop icons

Posted: Sun Sep 03, 2006 2:27 am
by eJan
I need API call to set permanently AutoArrange & Align to Grid for Desktop icons. I Have tried using Registry but it doesn't work with Reatogo-X-PE. Please help!

Posted: Sun Sep 03, 2006 3:09 am
by netmaestro

Code: Select all

; Set desktop icons to permanently autoarrange
hWnd = FindWindow_("Progman", 0) 
hWnd = GetWindow_(hWnd, #GW_CHILD) 
hWnd = GetWindow_(hWnd, #GW_CHILD) 
SetWindowLong_(hWnd, #GWL_STYLE, GetWindowLong_(hWnd, #GWL_STYLE) | #LVS_AUTOARRANGE | #LVS_ALIGNLEFT)

Posted: Sun Sep 03, 2006 12:09 pm
by eJan
Thanks netmaestro, unfortunately it doesn't work under XP even with:

Code: Select all

mouse_event_(#MOUSEEVENTF_RIGHTDOWN,0,0,0,0) : mouse_event_(#MOUSEEVENTF_RIGHTUP,0,0,0,0)

Posted: Sun Sep 03, 2006 12:40 pm
by netmaestro
I'm running XP pro SP2, if I uncheck autoarrange on my desktop and move a few icons around, then run that code they all straighten up and autoarrange becomes checked. I couldn't guess at all why it might not work on another machine with the same os.

Posted: Sun Sep 03, 2006 12:47 pm
by techjunkie
netmaestro wrote:

Code: Select all

; Set desktop icons to permanently autoarrange
hWnd = FindWindow_("Progman", 0) 
hWnd = GetWindow_(hWnd, #GW_CHILD) 
hWnd = GetWindow_(hWnd, #GW_CHILD) 
SetWindowLong_(hWnd, #GWL_STYLE, GetWindowLong_(hWnd, #GWL_STYLE) | #LVS_AUTOARRANGE | #LVS_ALIGNLEFT)
Works fine here; WinXP Pro SP2 (english) , if I turn off "Auto Arrange".

Posted: Sun Sep 03, 2006 12:53 pm
by eJan
Sorry, yes it works - I have look only at checked-unchecked popupmenu. :D

Posted: Sun Sep 03, 2006 1:09 pm
by netmaestro
Hm. I guess you have to tell the registry somewhere that the style got changed, otherwise the checks won't show accurately. A bit of sleuthing with Regshot ought to reveal where and what.