News:

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

Main Menu

Simple question with Slider Bar.

Started by AssemblyChallenge, March 31, 2015, 08:26:45 AM

Previous topic - Next topic

AssemblyChallenge

Hi all.

I almost finished a small project and everything works except this part. There is a Slide Bar control with a Static control on top of it. The idea is simple: If you move the slide rigth-left, no matter if keyboard or mouse, the static text shows the value in order to make it more visible.

The problem: It doesnt works. I read and use the slider value but cant make its value show on the static. My homework before asking was Bill Cravener's examples, EasyCode's File Shredder and MSDN part about it too. Here is my code:

.
ElseIf (uMsg == WM_HSCROLL) ; || (uMsg == WM_VSCROLL)
LoWord wParam
Nop
Nop
.If (Ax == SB_LINELEFT) || (Ax == SB_LINERIGHT)
Invoke GetValue, SliderXorHandle
Invoke String, Eax, Addr TmpString, ecDecimal
Invoke SetWindowText, StaticXorHandle, Addr TmpString
.EndIf


If the theory is right, WM_HSCROLL is all that I need (whenever it changes, no matter what, just show Static value). The NOPs are for debugging (in fact Olly never came in there  :dazzled:) The SB_LINELEFT, etc, came out of my desperation trying to find a reason. What's wrong ??

Than you.

dedndave

i generally ignore lParam and use SendMessage to get the current position
it supports values larger than 65535
there may have been some other advantage that i've long forgotten - lol

i keep a DWORD variable with the current position in it
if the value hasn't changed, i don't perform the update code (whatever that might be)

    .elseif eax==WM_VSCROLL
        .if wParam!=SB_THUMBPOSITION
            INVOKE  SendMessage,hTrackBar,TBM_GETPOS,0,0
            .if eax!=dwTrackPos
                mov     dwTrackPos,eax

                ;perform update code here

            .endif
        .endif
        xor     eax,eax            ;return 0


in my case, it is a vertical slider, so i used WM_VSCROLL

AssemblyChallenge

Well, I found the problem (sort of).

This little tip could save some lives :lol: When I created the Form, added the GroupBox first and then inside of it the Slider. That was the problem: The GroupBox ended up being the "father" instead of Main so the WM_HSCROLL part was fine but ignored. In C++ forums they said something about sub-classing the Group so Main can see the Slider's messages. :dazzled:

A very easy workaround is simply to create the Controls first in the Main window and then move them inside the GroupBox. This way you can control the messages with uMsg as usual as the Controls are Main's children.