well after a lot of fight a start subclassing... heheh

here a SLIDER made from a window button with a bitmap on it. :)


what is realy bad is that i asked people that know much more then me and nobody
has done such a simple example.. :(

next i ask a simple knob example , i will try to do it my self , i know it requires some
trigonometrical funcions and pi i think well will try (r,angle)

tested on windows XP :)

download example here :
Posted on 2003-04-17 20:52:34 by Nguga
Its a great start. Im not too familiar with VASM's addressing scheme tho. However, found it a bit glitchy on Win98SE, but it worked.

If your planning on multiple sliders, i still urge you to consider writing your own custom control for this task. There is alot more flexibiliy, can be resused, and have multiple instances running at once on a parrent window.

Custom controls are not hard to make. The biggest thing to adhear to is that you can not use global memory in your control winproc (since there may be more than one control instanciated and using this proc simutaneously is separate threads, but not a the same moment). To get around this, you decair some heap memory and store the pointer in the window itself with SetWindowLong.

After that is more or less drafting up the behavior you want to see. I would be glad to help you design one (i could do it myself in about an hour or so, but you wont learn anything from this ;) ). Rather, i will give your help/guidance along the way if you decide to make an attempt at it.

Either way, your current work does look like its on its way..
Keep up the hard work!
:alright:
NaN
Posted on 2003-04-17 22:46:15 by NaN
Well NaN i think you did no see the code becouse i already have done a own custom control for this task.


here is the prove of multislider download it here:
Posted on 2003-04-18 07:01:18 by Nguga
;---------- [ Loading Bitmap for Sliders ] 

call LoadImageA, [hInst],"1.bmp",IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE
mov [hbitmap_slider],eax

;---------- [ Create Slider 1 ]
call CreateWindowEx, 0,"BUTTON", 0, WS_CHILD | WS_VISIBLE | BS_BITMAP ,20,24,18,28, [hwnd],101, [hInst], 0
mov [slider1],eax
call SendMessageA,[slider1],BM_SETIMAGE,0, [hbitmap_slider]
call Subclass_Slider,[slider1]

;---------- [ Create Slider 2 ]
call CreateWindowEx, 0,"BUTTON", 0, WS_CHILD | WS_VISIBLE | BS_BITMAP ,45,24,18,28, [hwnd],102, [hInst], 0
mov [slider2],eax
call SendMessageA,[slider2],BM_SETIMAGE,0, [hbitmap_slider]
call Subclass_Slider,[slider2]




;; ============[ Subclass_Slider ] :======================

rotin Subclass_Slider,hwnd
call SetWindowLong,[hwnd], GWL_WNDPROC, SliderCtl
mov [SubSlider], eax
endrotin
;; =================================================





;; ============[ SliderCtl ] :============================


rotin SliderCtl , hwnd, wMsg, wParam, lParam

sectiondata
pt resb POINT_size
x_slider dd 0
flagkeydown dd 0
sectioncode

call CallWindowProc,[SubSlider], [hwnd], [wMsg], [wParam], [lParam]
cmp dword [wMsg],WM_LBUTTONDOWN
jne .see_if_up
call GetCursorPos, pt
call ScreenToClient, [hWnd],pt
mov byte [flagkeydown],1
call SetCapture, [hwnd]
.see_if_up
cmp dword [wMsg], WM_LBUTTONUP
jne .see_if_move
mov dword [flagkeydown],0
call ReleaseCapture
.see_if_move
cmp dword [wMsg], WM_MOUSEMOVE
jne near .out_
cmp byte [flagkeydown],1
jne near .out_

; -- THE SELECTED SLIDER IS ...

mov dword eax,[hwnd]
switch eax
case [slider1]
mov dword [x_slider],20 ; x position slider 1
break
case [slider2]
mov dword [x_slider],45 ; x position slider 2
break
switchend

call GetCursorPos,pt
call ScreenToClient,[hWnd],pt

mov eax , [pt+POINT.x]

; -- [ +- 10 tracking mouse around slide ]

sub eax,10 ; -10
cmp dword [x_slider],eax
jng near .out_
add eax,10 ; restore eax

add eax,10 ; +10
cmp dword [x_slider],eax
jg near .out_
sub eax,10
;-- [ lenght of the slider |5-105| =100 ]

cmp byte [pt+POINT.y],5
jl .out_
cmp byte [pt+POINT.y],105
jg .out_

call MoveWindow,[hwnd] ,[x_slider], [pt+POINT.y] ,18,28,TRUE

; --- outputing slider value
mov ebx,[pt+POINT.y]
sub ebx,5
call SetDlgItemInt,[hMainWnd],100,ebx ,TRUE
.out_

endrotin ;----- SliderCtl end
;; =============================================

.:EDIT:. Added "CODE" "/CODE" blocks.
Posted on 2003-04-18 07:03:50 by Nguga
Well sorry, i see a subclassed button. Not a custom control. To me they are two different things entirely.

Your getting there. Im not telling you to do anything, just offering suggestions. However, Your latest version is still a bit glitchy. Im not sure if your suppose to be able to click and depress the button, but if you double click on it, it will. Also, you have to move the sliders slowly or the sliders will loose track of your mouse and stop. Third thing, it seems you cant click anywhere on the button to start sliding, but rather the upper half for some reason.

As a suggestion, look into using Get/Set/ReleaseCapture on the mouse, when slidding. This will help the button track the mouse even when it has moved to fast.

:NaN:
Posted on 2003-04-18 09:11:44 by NaN
:) like you you are the only one that help me .
Posted on 2003-04-18 10:59:35 by Nguga

:) like you you are the only one that help me .


Thank you Nguga! - N?Pr?
Posted on 2003-05-31 04:57:40 by Forginforcer