hi
i have 30curve in a windows and i wanna use a scrollbar for scrolling them, as what scrollbar do in editboxes, i mean in edit box when user reach end of windows, a scrollbar ganna be there for scrolling texts that are not in visible area... i was thinking about changing my curves data with position of scrollbar, like adding scroll bar return value to Y of each dots in my curves ,but is it the best way for this issue?
did you know the range for x?
yeap thats around 448
:-s no more help?
It should work well.
Using Scroll Bars - http://msdn.microsoft.com/en-us/library/bb787531%28v=VS.85%29.aspx
You need to tell the scroll bar how big your 'page' is (range of Y), the scrolling step size, and then respond to the messages and when it scrolls (and update your drawing as necessary.)
hi,
In the attachment an quick and dirty example for scrolling the client area.
qWord
Thats what i want quick and dirty xD
i just need vertical scroll bar doing this :P
im working on changing it xD
I put my code here :
Here i create my child win:
.elseif eax==WM_CREATE
invoke RegisterWinClass,ADDR childwin1,ADDR ClassName1,hIcon,hCursor,COLOR_BTNFACE
invoke CreateWindowEx,WS_EX_DLGMODALFRAME or WS_EX_CLIENTEDGE ,
ADDR ClassName1,NULL,
WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or WS_VSCROLL,
1,1,448,663,hWin,NULL,hInstance,ADDR cc
mov hChild1, eax
invoke SetParent, hChild1, hWin
;invoke SetLastError,0
invoke SetWindowLong,hChild1,GWL_WNDPROC,addr childwin1;
;mov childproc1,eax
invoke CreateSolidBrush,00AB5B14h ; BLUE as COLORREF number
mov hBrush1, eax
invoke SetClassLong,hChild1,GCL_HBRBACKGROUND,hBrush1 ; Set back color of WinChild1
invoke GetClientRect,hChild1,ADDR rect
invoke InvalidateRect,hChild1,ADDR rect,TRUE
Here is my child windows proc:
childwin1 Proc hChild:DWORD,uMsg:DWORD,wParam:DWORD,lParam :DWORD
LOCAL hDC:DWORD
LOCAL memDC:DWORD
LOCAL gX:DWORD
LOCAL gY:DWORD
LOCAL ps:PAINTSTRUCT
LOCAL cc:CLIENTCREATESTRUCT
.elseif uMsg == WM_PAINT
invoke BeginPaint,hChild1,ADDR ps
mov dChild1, eax
invoke SelectObject,dChild1,hPen1 ; Entekhabe Ghalam
mov gX,0
mov gY,0
@@:
invoke MoveToEx,dChild1,gX,gY,NULL
add gY,2
invoke LineTo,dChild1,gX,gY
add gY,51
.if gY < 700
jmp @b
.endif
mov edx,divX1
add gX,edx
mov gY,0
.if gX < 580
jmp @b
.endif
invoke SelectObject,dChild1,hPen2 ; Entekhabe Ghalam
invoke Polyline,dChild1,vCurve1,1000;
invoke TextOut,dChild1,xT1,yT1,SADD("25ms 1"),6
invoke SelectObject,dChild1,hPen ; Entekhabe Ghalam
invoke Polyline,dChild1,vCurve2,1000;
invoke TextOut,dChild1,xT2,yT2,SADD("25ms 2"),6
invoke Polyline,dChild1,vCurve3,1000;
invoke TextOut,dChild1,xT3,yT3,SADD("25ms 3"),6
invoke Polyline,dChild1,vCurve4,1000;
invoke TextOut,dChild1,xT4,yT4,SADD("25ms 4"),6
invoke Polyline,dChild1,vCurve5,1000;
invoke TextOut,dChild1,xT5,yT5,SADD("25ms 5"),6
.elseif uMsg == WM_CLOSE
invoke ReleaseDC,hChild1,dChild1
invoke EndPaint,hChild1,ADDR ps
mov hChild1,0
.endif
invoke DefWindowProc,hChild,uMsg,wParam,lParam
ret
childwin1 endp
there are 5 polylines , i need to put 30 polylines in my application and scroll them vertically :P
The easiest way is to create a compatible dc (you also need to create and select a compatible bitmap into it), and draw your curves into that dc - do this once on creation. Then bitblt that dc into your window dc each time you want to redraw.
Adjusting for the scroll offset is a simple matter of changing the y offset in the bitblt.
Attachment of qWord is same thing for horizontal scrollbar
And this is the code for vertical scrollbar in my application :)
Thanks
.if uMsg == WM_CREATE
invoke GetDC,hChild1
mov hdc,eax
mov hDrawDC,rv(CreateCompatibleDC,hdc)
invoke DeleteObject,rv(SelectObject,hDrawDC,rv(CreateCompatibleBitmap,hdc,553,2000))
invoke ReleaseDC,rv(GetDesktopWindow),hdc
invoke CreateSolidBrush,00AB5B14h ; BLUE as COLORREF number
mov hBrush1, eax
mov rect.top,0
mov rect.left,0
mov rect.right,553
mov rect.bottom,2000
invoke FillRect,hDrawDC,ADDR rect,hBrush1
invoke TextOut,hDrawDC,250,250,SADD("Hello ... !"),11
mov sci.cbSize,SIZEOF sci
mov sci.fMask,SIF_ALL
mov sci.nMin,0
mov sci.nMax,2000-1
mov sci.nPage,663
mov sci.nPos,0
mov sci.nTrackPos,0
invoke SetScrollInfo,hChild,SB_VERT,ADDR sci,1
.elseif uMsg == WM_VSCROLL
mov sci.cbSize,SIZEOF sci
mov sci.fMask,SIF_ALL
invoke GetScrollInfo,hChild,SB_VERT,ADDR sci
switch WORD ptr wParam , ax
case SB_BOTTOM
mov edx,sci.nMax
case SB_ENDSCROLL
mov edx,sci.nPos
case SB_LINELEFT
mov edx,sci.nPos
lea edx,[edx-1]
case SB_LINERIGHT
mov edx,sci.nPos
lea edx,[edx+1]
case SB_PAGELEFT
mov edx,sci.nPos
lea edx,[edx-300]
case SB_PAGERIGHT
mov edx,sci.nPos
lea edx,[edx+300]
case SB_THUMBPOSITION
movzx edx,WORD ptr wParam+2
case SB_THUMBTRACK
movzx edx,WORD ptr wParam+2
case SB_TOP
mov edx,sci.nMin
default
xor eax,eax
ret
endsw
mov sci.nPos,edx
mov sci.fMask,SIF_POS
invoke SetScrollInfo,hChild,SB_VERT,ADDR sci,1
invoke InvalidateRect,hChild1,0,1
.elseif uMsg == WM_PAINT
invoke BeginPaint,hChild1,ADDR ps
mov dChild1, eax
mov sci.cbSize,SIZEOF sci
mov sci.fMask,SIF_POS
invoke GetScrollInfo,hChild1,SB_VERT,ADDR sci
sub ASM(mov edx,ps.rcPaint.right),ps.rcPaint.left
sub ASM(mov ecx,ps.rcPaint.bottom),ps.rcPaint.top
inc edx
inc ecx
invoke BitBlt,ps.hdc,ps.rcPaint.left,ps.rcPaint.top,edx,ecx,hDrawDC,ps.rcPaint.left,sci.nPos,SRCCOPY
there isn't much need to handle SB_BOTTOM, SB_TOP, or SB_THUMBPOSITION
you also don't need to handle SB_ENDSCROLL :P
Hmm yeap i just copied it from qWord example in my application with whole details :D
well - if you play with it - see what actions generate which values...
if you click on the arrows at the end of the scrollbar, you get SB_LINEUP or SB_LINEDOWN
if you drag the scrollbar, it contunually sends SB_THUMBTRACK, with the new position in the high word of wParam
if you click on the dead space (scrollbar area where there is no thumbbox), it sends SB_PAGEUP or SB_PAGEDOWN
for most cases, those are the only values you need to handle
once in a while, you will see a scrollbar with 2 arrow boxes at each end - the second one may have a double-arrow or something
i suspect those get SB_TOP and SB_BOTTOM
otherwise - i haven't seen those values sent :bg
Thank you , i changed it to:
.elseif uMsg == WM_VSCROLL
mov sci.cbSize,SIZEOF sci
mov sci.fMask,SIF_ALL
invoke GetScrollInfo,hChild,SB_VERT,ADDR sci
switch WORD ptr wParam , ax
case SB_LINEUP
mov edx,sci.nPos
lea edx,[edx-1]
case SB_LINEDOWN
mov edx,sci.nPos
lea edx,[edx+1]
case SB_PAGEUP
mov edx,sci.nPos
lea edx,[edx-300]
case SB_PAGEDOWN
mov edx,sci.nPos
lea edx,[edx+300]
case SB_THUMBTRACK
movzx edx,WORD ptr wParam+2
default
xor eax,eax
ret
endsw
mov sci.nPos,edx
mov sci.fMask,SIF_POS
invoke SetScrollInfo,hChild,SB_VERT,ADDR sci,1
invoke InvalidateRect,hChild1,0,1
and it works ok ??
Yeap , work fine :green2
now - if you want to add stuff....
add mouse wheel support - WM_MOUSEWHEEL
add keyboard support - a number of ways to do it
Im working on it :D
well - you don't have to do that stuff :P
thats like a training work, bad point is that i should complete this project as fastest as i can so i guess when i done important things in it im ganna include mouse wheel to it, right now im working on print issue (http://www.masm32.com/board/index.php?topic=16076.new#new)] ::)
I found out why SB_BOTTOM ,SB_TOP was there >:)
there is a right click menu on scrollbar that contain TOP and BOTTOM
so there should be something for handling this commands :P
SB_BOTTOM and SB_TOP was useful :8)
nice catch :U
for the life of me, i couldn't find any way to activate them
i will add to my code, as well - afterall - those are 2 of the easy ones :P