Jump to content
Tuts 4 You

How to set a slider control position by mouseclick?


LCF-AT

Recommended Posts

Hi again,

got a new problem again where I need some help.I created a sliderbar control and wanna change the position by mouseclick exactly where I do press with the mouse.I did subclass the slider control and do catch at WM_LBUTTONDOWN message and wrote my code so far...

.if uMsg == WM_LBUTTONDOWN
	        LOWORD lParam
	        mov pt.x,eax
	        mov ISH, eax ; <----
	        HIWORD lParam
	        mov pt.y,eax
	        nop

	    invoke SendMessage,SLIDERHANDLE,TBM_GETCHANNELRECT,0,addr CHANNELRECT
            push CHANNELRECT.right
            pop eax
            push CHANNELRECT.bottom
            pop ecx
            push CHANNELRECT.left ; x
            pop edi
            push CHANNELRECT.top  ; y
            pop esi
            sub eax,edi
            sub ecx, esi	        
            mov edx, CHANNELRECT.left
            mov ebx, CHANNELRECT.top	        
	        

	        mov FULL_LENGHT, eax

	        mov eax, ISH ; current
	        mov ecx, 64h
	        mov edx, 0h
	        mul ecx
	        mov ecx, FULL_LENGHT ; full length
	        mov edx, 0
	        div ecx
	        invoke SendMessage,hWnd,TBM_SETPOS,TRUE,eax

...so its also working good so far but the small problem I have is that the slider will not set exactly at the position where I press with the mouse so its some mm more right at the beginning and gets less at the end so at the end its correctly etc you know what I mean.So have I to calc else or so?My slider maxrange is set to 100.Anyway,so I come not clear again with that calculations so maybe you can help again a little.On the net I found a Delphi example what does div by 2 anyhow etc.

http://www.delphipraxis.net/107882-beim-klick-auf-eine-trackbar-zur-klickposition-springen.html

Thanks

Link to comment

Hi,

I have another question.Does anyone know how to set a window smaller than the client itself?Same as in your videoplayer like VLC.Just imagine you start playing a 16:9 video and now you wanna cut the view to 4:3 format (left & right side get cut of video).Problem now is how to handle that.So I have set the clientwindow (videowindow) same to player window at WM_SIZE so that the video does move with the app window if I change it.So I am getting totaly confused so maybe you can help a little.

Thanks

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...