Software Archive
Read-only legacy content
17061 Discussions

scrolling in QuickWin

challener
Beginner
413 Views
In the input/output window of my QuickWin application I would like to have the window automatically set the scroll bar to the bottom of the last line of text. I know that I can use the SendMessage with WM_VSCROLL, SB_LINEDOWN parameters to scroll down one line, and I know that the GetTextPosition routine will tell me how many lines of text I have, but I need to know where the scroll bar is in order to tell it how many lines to scroll up or down. I have not been able to get the GetScrollPos or SetScrollPos commands to work (do they only work in a complete Windows application?), or know if they would even do the trick for me if I could get them to work.
0 Kudos
4 Replies
Jugoslav_Dujic
Valued Contributor II
413 Views
They should do the trick -- perhaps you just didn't implemented them
right way? It should look something like this:

 
USE DFWIN 
USE MSFLIB 
 
INTEGER:: hChild 
INTEGER, PARAMETER:: iChildUnit = 11 
... 
OPEN(iChildUnit, FILE='USER',...) 
... 
hChild=GetHWNDQQ(iChildUnit) 
iSt=SetScrollPos(hChild, SB_VERT, newPosition, .TRUE.) 


Btw, did they fix the QW scrollbars so that the thumb is
proportional to visible portion of the data? If not, take
a look into SetScrollInfo(hChild, SB_VERT, SI, .TRUE.),
where SI is of type T_SCROLLINFO, which contains nMin,
nMax and nPage members.

HTH
Jugoslav
0 Kudos
challener
Beginner
413 Views
Thanks for the reply! I am probably being dense, but I still have problems. The SetScrollPos command does indeed move the position of the thumb in the scroll bar, but it doesn't actually scroll the text in the window. If I could get the GetScrollInfo command to work, then I could at least figure out how many lines up or down I need to go to reach the end of the text and then use the SB_LINEUP or SB_LINEDOWN to go there, although that seems a very indirect way to do what I want to do. When I include the statement:

TYPE (T_SCROLLINFO) si

the program compiles okay, but it doesn't recognize the variables si.nMin, si.nMax, or si.nPage. Instead I get the error, "This is not a field name that is defined in the encompassing structure" for each of them.

When I enter the Help Index, I cannot find any information about "T_SCROLLINFO." Instead, I find the "SCROLLINFO" structure defined with the nMin, nMax, nPage, etc. elements. However, when I include the statement,

TYPE (SCROLLINFO) si

in the program, I get the error message "This derived type name has not been declared." So, apparently I am not including the correct library or module or something?

Bill
0 Kudos
Jugoslav_Dujic
Valued Contributor II
413 Views
I misread your original post, so I posted the sample with SetScrollPos --
however, I don't see why GetScrollPos wouldn't work. Regarding the setting scrollbar position, you're right -- SetScrollPos only sets the thumb position -- sorry, it was long time ago since I worked with it. However,
you can use SendMessage with SB_THUMBPOSITION flag set to get
the window scrolled to the desired position:

 
iSt=SendMessage(hChild, WM_VSCROLL, SB_THUMBPOSITION + & 
ISHL(newPosition,16) , 0) 


> So, apparently I am not including the correct library or module or
> something?

You did (almost) everything OK -- this time, it's Compaq that's at fault.
It's their translation of C Win32 headers that's inconsistent, especially
of those that were inherited from Micro$oft FPS (there was
a lot of talk about it in this and the old Forum). The Win32 types are
always prefixed with T_ in DFWIN (and its "sub-modules"); member names
should be the same as described in help. However, they made an
exception for reasons unknown to me with SCROLLINFO: its members
are declared as Min, Max, Page etc., not nMin, nMax, nPage as in help.
So, proper declaration is T_SCROLLINFO, and it should be looked in help
under SCROLLINFO. Generally, it's always a good idea when using
a Win32 function or type to do a "Find in Files" in Program Files/.../DF/Include to take a look on type declaration or INTERFACE block.

Regards

Jugoslav
0 Kudos
challener
Beginner
413 Views
Thank you very much! It now works the way I had hoped. My final subroutine, if of any interest, is:

	Subroutine ResetScrollPosition  
    USE dflib  
	USE dfwin  
	IMPLICIT	NONE  
	TYPE		(RCCOORD)		textpos  
	TYPE		(T_SCROLLINFO)	si  
	INTEGER(2)	NumRows  
	INTEGER		status,win_handle,newPos  
	COMMON		/Handles/	win_handle,NumRows  
  
	Call GetTextPosition(textpos)  
	If (textpos.row.GT.20) then  
	  si.Size = sizeof(si)  
	  si.Mask = SIF_ALL  
	  status = GetScrollInfo(win_handle,SB_VERT,si)  
	  newPos = ISHL(NINT(si.Max*(textpos.row-20.0)/NumRows),16) + SB_THUMBPOSITION  
	  status = SendMessage(win_handle,WM_VSCROLL,newPos,0)  
	End if  
	Return  
	End  

NumRows is obviously the integer setting the number of rows in the window when originally created.
0 Kudos
Reply