News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Superclassing and "intrinsic" scrollbars

Started by NoCforMe, September 02, 2022, 11:17:44 AM

Previous topic - Next topic

NoCforMe

@JJ: Back there in the topic about including "intrinsic" scrollbars in custom controls, you wrote:

Quote from: jj2007 on August 28, 2022, 07:04:17 AM
If you are not using one of the predefined registered controls, there might be no "intrinsic" Win32 scrollbar. So you might have to add it... but I might be wrong, too.

I did a little experiment to see if I could get one with a static control. (No need to try with an edit control, as they come built-in if you use the ES_AUTOHSCROLL or ES_AUTOVSCROLL styles). I also wanted to learn a new trick, so I tried superclassing, since I'd never done this before.

Well, superclassing is super-easy, almost as easy as subclassing, so I'm glad I have this tool in my belt now. But the experiment basically failed. I created a superclass of the static control which attempted to activate the scrollbar included by the WS_HSCROLL style. Well, I can get the scrollbar all right; I just can't make it actually do anything. Not very useful.

As pointed out in the on-screen text, I was able to get the scrollbar to actually work by activating it via SetScrollInfo() (in the WM_NCCREATE handler) and then not passing to the base-control code. The scrollbar worked, but none of the base-class functionality was there, which pretty much defeats the whole purpose. So in this case you were right. Who knows? There may be some Win32 controls that will support a scrollbar (besides the ones that explicitly do so, like listboxes, listviews, etc.). But apparently in the case of a static control the control's creation code just shuts off any scrollbar functionality.

I was able to set a nicer font in the WM_CREATE handler. Superclassing does have its uses.

(For those not familiar with superclassing, it's like subclassing, but as the name implies, instead of going "under" the class by hooking its window procedure, it actually creates a new class based on an existing class but with whatever behavior changes you want. You take the existing class and redirect it to your own window procedure, which is also what subclassing does. The main difference here is that with superclassing, you get all messages intended for the base class including WM_NCCREATE and WM_CREATE. With subclassing you only get messages sent after these two, which makes sense since you can't subclass the window until after you've created it.)
Assembly language programming should be fun. That's why I do it.

jj2007

Very interesting :thumbsup:

Here are the messages when clicking on the scrollbar:

msg     1796    WM_COMMAND: 00000000h   ID 513
msg     1797    WM_PARENTNOTIFY
msg     1799    WM_MOUSEACTIVATE