I have created several list boxes with a macro. I need to change one of them to have vertical scroll bar.
How can I change style, I tried SendMessage but have  no luck.

thx for your help
klod
Posted on 2009-12-27 23:22:14 by Klod
I have tried this here (NAsm syntax)

invk GetWindowLongA, , GWL_STYLE
invk HexPrint,eax
invk SetWindowLongA ,,GWL_STYLE,WS_CHILD | WS_VISIBLE |LBS_HASSTRINGS | LBS_SORT | WS_VSCROLL
invk GetWindowLongA, , GWL_STYLE
invk HexPrint,eax
invk UpdateWindow,


Get Window returns the correct Style and I can set the new style with SetWindowLongA however the newly set style does not show when I update the control??

invk SetClassLongA,,GCL_STYLE,WS_CHILD | WS_VISIBLE |LBS_HASSTRINGS | LBS_SORT | WS_VSCROLL


Tried this one too, don't work either

Klod
Posted on 2009-12-28 15:20:51 by Klod
One possibility, as per MSDN: Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.
Posted on 2009-12-28 15:49:18 by SpooK
Thanks Spook for your help.

invk SetWindowLongA,,GWL_STYLE,WS_CHILD | WS_VISIBLE | LBS_HASSTRINGS | LBS_SORT	| WS_VSCROLL ;200000h
invk GetWindowLongA, , GWL_STYLE               ;GWL_EXSTYLE
invk HexPrint,eax                    ;Verify change style
invk  SetLastError,0                            ;clear last ERROR
invk SetWindowPos,,HWND_NOTOPMOST,,,,,SWP_FRAMECHANGED  ;SWP_NOZORDER ;SWP_NOSIZE
invk @GetErrDescription,eax


I call this code right after creation of the List box and change the style for the affected Listbox. SetWindowPos appears to have the same effect as MoveWindow function, the change to the Style does not take effect.

I have been playing around with different flags/settings but no luck. Although different Flags give different results, GetErrDescription always returns 1,"Incorrect function".
per Win32help
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Any suggestions?

Regards Klod

Posted on 2010-01-17 14:56:14 by Klod
Is SetWindowPos by chance returning 1, and technically succeeding, thus tripping up GetErrDescription and giving you a false error?
Posted on 2010-01-17 16:42:13 by SpooK
Exactly
I know the function completes with no errors, because I can substitute the SetWindowLongA function with MoveWindow function and the program works the same, but the syle change does not take effect either way.

any other suggestions?
regards Klod
Posted on 2010-01-19 11:54:44 by Klod
Klod,

Try to create that listbox with scrollbar and turn it off after that. Windows probably doesn't allow to show/hide scrollbar if it wasn't created beforehand.
Posted on 2010-01-22 22:53:17 by baldr
Thanks  baldr for your suggestion
But I have tried that already, same effect.
It seems as if Windows is ignoring the change of style

regards Klod
Posted on 2010-01-28 08:53:56 by Klod