8 Replies - 1549 Views - Last Post: 20 September 2012 - 05:07 PM

how to use slider from toolbox

Posted 11 September 2012 - 01:36 PM

he!

surprising enough i didnt found anything about how to use a slider in masm.
what i want to do is when the user moves with the slider then a operation should be execute like changing the windows volume.

Re: how to use slider from toolbox

Posted 14 September 2012 - 05:14 PM

Not exactly sure what you want, but I think this should do it. As I don't have your RC file or WAP project file, change your dialog id to 1000, your trackbar to 1001, add a static control somewhere and give it an id of 1002, when we set the trackbar buddy to use the static control, it will position it to the right of the trackbar. When you move the slider, it will update the buddy control with its position.

Let's take 65541 which is 10000000000000101, you with me? We are interested in the message which is in the low word of 65541 so we and it with FFFF (65535)
10000000000000101 ∧
01111111111111111
-----------------
00000000000000101 (5) = SB_THUMBTRACK

AND uses a simple truth table
1 ∧ 1 = 1
1 ∧ 0 = 0
0 ∧ 0 = 0
0 ∧ 1 = 0

There are other ways to separate the high and low words, but this is used often.

So the trackbar gets its min and max values from a packed DWORD
mov cx, 100 ; max trackbar pos
ror ecx, 16
mov cx, 0 ; min trackbar pos
Move the value 100 into cx (the low word of ecx) and rotate it right 16 bytes gives you 6553600, we really don't need mov cx, 0 as you can see it is already 0, it is to make sure it is zero and not garbage.
Change the numbers and zero out ecx first to make it clearer:

Try this:
Open your calc in windows and press ALT + 3 for programmer view. Enter a number and look at the binary rep of that number. Press RoR 16 times and watch what happens each time. The documentation for the mnuemonics discusses all this. Read it!