Jump to content
Tuts 4 You

How to calc Hscroller with tabs correctly?


LCF-AT

Recommended Posts

Hi guys,

so I have a question about using / calculate / handling a HSCROLL control.So I would like to create a HSCROLL control what gets set and moved correctly and nice dependent on a tab control (X tabs = dynamic).Problem is I dont get it really good working.

Lets say I have only one tab so then the thumbtrack should take the entire place in the hscroller and if I add more tabs then it should get smaller and smaller etc like in Notepad app for example.Next problem are the positions to set them correctly + calculate the right value to adjust everything you know.I made a example for testing.Maybe you can check this.

		invoke GetDlgItem,hWnd,IDC_HSCROLL
		mov HS_HANDLE, eax
		mov SINFO.cbSize, sizeof SINFO
		mov SINFO.fMask, SIF_ALL
		mov SINFO.nMin, 0
		mov SINFO.nMax, 100
		mov SINFO.nPage, 10
		invoke SetScrollInfo,HS_HANDLE,SB_CTL,addr SINFO,TRUE 





	.elseif uMsg == WM_HSCROLL
	          invoke GetDlgItem,hWnd,IDC_HSCROLL
	          .if lParam == eax
	              mov edi, wParam
	              LOWORD wParam
	              mov edi, eax
	              HIWORD wParam
	              .if edi==SB_LINELEFT || edi==SB_PAGELEFT || edi==SB_THUMBTRACK && eax < 50
	                            invoke SetScrollPos,HS_HANDLE,SB_CTL,eax,FALSE
	                            invoke SendMessage,TABHANDLE,TCM_GETITEMCOUNT,0,0
	                            .if eax!=0
	                                mov esi,eax
	                                invoke SendMessage,TABHANDLE,TCM_GETCURSEL,0,0
	                                .if eax!=-1h || eax!=0h
	                                    mov edi, eax
	                                    sub edi, 1h
	                                    .if edi==0h || edi < esi
	                                    invoke SendMessage,TABHANDLE,TCM_SETCURSEL,edi,0
	                                    invoke SendMessage,TABHANDLE,TCM_GETCURSEL,0,0
	                                    mov tabIndex, edi	                                    
	                                    .endif
	                                .endif
	                            .endif	                  
	             .elseif edi==SB_LINERIGHT || edi==SB_PAGERIGHT || edi==SB_THUMBTRACK && eax > 50
	                            invoke SetScrollPos,HS_HANDLE,SB_CTL,eax,FALSE
	                            invoke SendMessage,TABHANDLE,TCM_GETITEMCOUNT,0,0
	                            .if eax!=0
	                                mov esi,eax
	                                invoke SendMessage,TABHANDLE,TCM_GETCURSEL,0,0
	                                .if eax!=-1h || eax!=0h
	                                    mov edi, eax
	                                    add edi, 1h
	                                    .if edi==0h || edi < esi
	                                    invoke SendMessage,TABHANDLE,TCM_SETCURSEL,edi,0
	                                    invoke SendMessage,TABHANDLE,TCM_GETCURSEL,0,0
	                                    mov tabIndex, edi 
	                                    .endif
	                                .endif
	                            .endif	 	             
	           .endif
	      .endif

HScroller.rar

Thank you

Link to comment

Hi Ted,

yes I have seen this too already.The problem I got is again some calculations as always.So yesterday I got something working after long testing and the scroller gets adjusted and updated correctly with the lenght of the tabs (dynamicly) so thats good now so far.Just need to update the nMax parameter.Now its working good but not so perfect like the scroller from notepad or Listviews itself.I mean if I move the thumbtrack very quick from one side to the other then it will mostly not reach the first or last tab.No idea why its so.If I scroll a bit slower then all is working good.A other problem what I have is that I cant calc / set the thunbtrack lenght anyhow so my is always same also if I add or remove tabs.Somehow I have to set the nPage for this but dont get it working correctly.I attach my latest test which works good so far so I think with that result I can live so far.Just test it but remember if you are moving the scroller too quick then it stops mostly somewhere before and sroller jumps back same with tab position.Maybe the scrollbar is too small for this or something no idea.

HScroller2.rar

greetz

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...