Scrollbars - How in the world can I get them to function?

Started by allynm, October 01, 2009, 01:50:18 AM

Previous topic - Next topic

allynm

Hi everyone -

My previous question concerning static variables in a WndProc (which I think was solved satisfactorily, thanks to everyone's generosity) was prompted by my total inability to get a vertical scrollbar to work.

I have been trying to re-write Charles Petzold's Windows C progams into MASM.  It's not very easy for a beginner.  As you can imagine.

I am stalled out trying to make vertical scrollbars function.  I can get the scrollbars on the window, but I can't get the program to respond to my mouse.  I can paint text on the window, but the scrollbar doesn't seem to care about me at all.

Can anyone suggest some code to get the darn thing to function.  I've programmed Petzold's stuff in C and looked at Ollydbg's disassembly of his C program but it doesn't make a lot of sense.  Stuff is getting added in by the compiler that I can't follow.

Thanks as always,
Mark Allyn

redskull

Scrollbars aren't automatic in operation; they need to be manually programmed to do almost anything.  You need to program what needs to happen in response of being clicked; for example, keep track of the starting line of a text box, and when the scroll bar is clicked, adjust that variable, and redraw the contents starting from there, and adjust the range and position of the scrollbar.  Posting some code will be more helpful.  As Petzold says:

QuoteThese are Windows' responsibilities for scroll bars:

  • Handle all processing of mouse messages to the scroll bar.
  • Provide a reverse-video "flash" when the user clicks the scroll bar.
  • Move the thumb as the user drags the thumb within the scroll bar.
  • Send scroll bar messages to the window procedure of the window containing the scroll bar.

These are the responsibilities of your program:

  • Initialize the range and position of the scroll bar.
  • Process the scroll bar messages to the window procedure.
  • Update the position of the scroll bar thumb.
  • Change the contents of the client area in response to a change in the scroll bar.
Strange women, lying in ponds, distributing swords, is no basis for a system of government

PBrennick

aallym,
Attached is an example that shows how to do it. Actually, it is an example that was translated from Petzold's stuff to assembly by Ron Thomas. Probably it is the one you are working on (colormix.c).

Paul
The GeneSys Project is available from:
The Repository or My crappy website

Bill Cravener

Here is an another example: Scollbar controls

This example is also in hutch's Masm32 package I believe.
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat