SetWindowLong c++ Windows

Started by
4 comments, last by Oluseyi 18 years, 3 months ago
Hey ho guys, i once again rely on your help. I am currenty writing on some window classes, and I wish to change the style of some windows while the windows are running. e.g., I want to ad a scroll bar to a listbox or maybe remove a scroll bar from a list box. This is what i tried so far: current style of the Listbox: dwstyle = LBS_NOTIFY | WS_BORDER | WS_CHILD; Trying to add the scroll bar: dwstyle |= WS_VSCROLL; SetWindowLong(hwnd, GWL_style, dwstyle); ShowWindow(hwnd, SW_SHOW); Unfortunatly nothing is changed by these three lines and as far as I understand the references that is all there should be done. Thank you for any insight! cherio Woltan
Advertisement
SetWindowLong (Remarks section):
Quote: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
Ok I tried that but it didn't work. Thats my source now:
I am trying to disable the scroll bar:
SetWindowLong(hwnd, GWL_style, LBS_NOTIFY | WS_BORDER | WS_CHILD);
SetWindowPos(hwnd, HWND_TOP, x, y, w, h, SWP_FRAMECHANGED);

And in my references there was nothing mentioned that you quoted, i found it on msdn though.

There is also something else strange going on. I can add and remove almost any style like the WS_THICKFRAME or even the WS_HSCROLL.
the only thing that doesnt seem to work is the WS_VSCROLL.

Thx for any advice you could give me
cherio Woltan
You're probably better off using SetScrollI nfo instead of diddling with window styles directly.
-Mike
hey Anon Mike,
after 4 hours of trying things, i think i will just write some scroll bar classes that will take care of my problem. but it surely is the weirdest thing, almost everything, and i spent at least 4 hours troublshooting, is editable in the styleworld BUT the WS_VSCROLL item. so i will start progging some scroll bar classes and hopefully dont encounter any probs. if i do i know where to go ;)
cherio Woltan
About Scrollbars: Standard Scrollbars and Scrollbar Controls:
Quote:A scroll bar is included in a window either as a standard scroll bar or as a scroll bar control. A standard scroll bar is located in the nonclient area of a window. It is created with the window and displayed when the window is displayed.

...

A scroll bar control is a control window that belongs to the SCROLLBAR window class. A scroll bar control appears and functions like a standard scroll bar, but it is a separate window. ... You can use as many scroll bar controls as needed in a single window.

What you are trying to do is impossible. You can't add a standard scrollbar after the window has been created. If you need to add the scrollbar after the fact, then use a scrollbar control. Otherwise, specify the appropriate scrollbar style when you create the window.

This topic is closed to new replies.

Advertisement