View previous topic :: View next topic |
Author |
Message |
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Feb 13, 2006 1:51 am Post subject: Scrollbar position checking? |
|
|
Many of you have probably seen license agreement dialogs where the "Accept Button" dosen't activate until the the user scrolls to the bottom of the license agreemnent. I would like to have this functionallity in some of my apps.
I'm sure there is probably more than one way to do this, but hoping someone knows an easy way.
Thanks in advance,
Aslan |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Feb 13, 2006 4:38 am Post subject: |
|
|
You can probably use EM_GETTHUMB.
Code: | %P = @sendmsg(@win(~EDIT1),$0BE,0,0) |
You'll have to test it to see what result you actually want. It will return the current position of the scroll box of your edit control.
After you find what value you are looking for(probably something like 100), you can use a timer to check it every half-second or so, if %P equals the value you want, enable the Accept button. _________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Feb 13, 2006 2:47 pm Post subject: |
|
|
Will this work with a list element? |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Feb 13, 2006 3:24 pm Post subject: |
|
|
Using the following code %P always equals "0"
To test you'll need to create upgrade.txt with enough lines to cause the scrollbar to be needed.
Code: | Title Comm Setup
DIALOG CREATE,Comm Setup,-1,0,546,220,NOSYS
DIALOG ADD,STYLE,STYLE2,,8,BL
DIALOG ADD,STYLE,STYLE1,,,BC,BLACK,F29A15
DIALOG ADD,BUTTON,OK,185,469,64,24,INSTALL
DIALOG ADD,EDIT,EDIT1,12,195,338,160,,,MULTI,WRAP,SCROLL,STYLE2
DIALOG ADD,LINE,LINE1,11,14,167,197
DIALOG SHOW
List create,1
List Loadfile,1,upgrade.txt
Dialog set,EDIT1,@text(1)
:Evloop
Repeat
%P = @sendmsg(@winexists(~EDIT1),$0BE,0,0)
If @greater(%P,0)
Info %P
End
wait 0.5
%E = @event()
If %E
goto %E
End
Until %E
:OKBUTTON
#Do something
:Close
exit
|
|
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Feb 13, 2006 3:25 pm Post subject: |
|
|
No that's for edit/richedit only, you can use LB_GETTOPINDEX for listboxes.
It returns the visible item at the top of the listbox, which is 0 before the listbox is scrolled, and an item toward the bottom if the user scrolls to the bottom.
Code: | %P = @sendmsg(@win(~LIST1),$018E,0,0) |
So if your list has 100 items, and you can see 20 at a time or so, then you'd want to enable the Accept button if the above returns > 78. _________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Feb 13, 2006 3:44 pm Post subject: |
|
|
Hey SS again thanks for your help.
In the post above your last one I used a multi/edit.
Can you see anything wrong with the code?
%P = 0 no matter where the scroll thumb is. |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Feb 13, 2006 4:18 pm Post subject: |
|
|
It's probably more effecient to use a timer event, but it should still work.
For some reason the built in @sendmsg apparently doesn't work with all messages. If you have VDS 5, you should try it with the API SendMessage function.
Code: |
LOADLIB user32.dll
%%hwnd = @strdel(@winexists(~EDIT1),1,1)
%P = @lib(user32,SendMessageA,INT:,%%hwnd,$0BE,0,0)
|
_________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Feb 13, 2006 4:43 pm Post subject: |
|
|
The edit thumb position must not work with a VDS editbox.
LB_GETTOPINDEX does work though.
This will work with any text file, as it calculates what item should be at the top, if the user scrolls to the bottom.
Don't forget to change %%file to your license file.
Code: |
%%file = c:\Mp3-List.txt
REM The height of your listbox, used to see how many items are visible
%%LBHeight = 170
DIALOG CREATE,New Dialog,-1,0,316,214
REM *** Modified by Dialog Designer on 2/13/2006 - 11:19 ***
DIALOG ADD,LIST,LIST1,14,22,274,%%LBHeight
DIALOG ADD,BUTTON,Accept,190,110,80,22,Accept
DIALOG SHOW
DIALOG DISABLE,Accept
list loadfile,LIST1,%%file
:Timer
%P = @sendmsg(@winexists(~LIST1),$018E,0,0)
REM Get the height of an item in pixels.
%O = @sendmsg(@winexists(~LIST1),$01A1,0,0)
REM Subtract 2 from LBHeight and divide by the height of an item.
REM This gives you the amount of items visible.
%%visibleItems = @format(@fdiv(@fsub(%%LBHeight,2),%O),.0)
REM Then subtract that from the actual amount of items in the listbox.
%O = @sendmsg(@winexists(~LIST1),$018B,0,0)
REM Subract 1, just in case.
%%lowestItem = @fsub(@fsub(%O,%%visibleItems),1)
REM This gives you the item to look for, to make sure the user scrolled to the bottom.
if @greater(%P,%%lowestItem)
dialog enable,Accept
end
:Evloop
wait event,0.5
goto @event()
:AcceptBUTTON
:Close
exit
|
_________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Feb 13, 2006 4:50 pm Post subject: |
|
|
That worked quite nicely SS
Thanks again |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Feb 13, 2006 5:13 pm Post subject: |
|
|
No problemo. _________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
kOt Contributor
Joined: 19 Jan 2004 Posts: 89 Location: Fyffe, AL
|
Posted: Tue Feb 28, 2006 7:11 pm Post subject: |
|
|
Im using a table and trying to achieve this..
Used every suggestion here and %P is always zero
This is what im trying to do.
1. Located position of scrollbar
2. Update my table with new information
3. Seek to location found in 1. _________________ Visual Dialogscript 5 |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Tue Feb 28, 2006 7:25 pm Post subject: |
|
|
A table control is not a "list", even though VDS pretends it is. A table is a "list-view", so it needs to be handled differently, when I get some time I will try and convert it over. _________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Mar 01, 2006 4:46 am Post subject: |
|
|
If you get the item that was selected before you do your updating, you
might try sending LVM_ENSUREVISIBLE to the table afterwards. It scrolls the table so that the selected item is in view.
Code: |
REM LVM_ENSUREVISIBLE = $01013
%%SelectedItem = <Previously selected item here>
%P = @sendmsg(~Table1,$01013,%%SelectedItem,0)
|
_________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
kOt Contributor
Joined: 19 Jan 2004 Posts: 89 Location: Fyffe, AL
|
Posted: Wed Mar 01, 2006 12:48 pm Post subject: |
|
|
Thats a problem because i (more than not) do not have anything selected
i just scroll down to see what the information is _________________ Visual Dialogscript 5 |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Mar 01, 2006 3:56 pm Post subject: |
|
|
Because a List-View holds more than just text, it's a bit more complicated.
If you know pretty much how many items the user can see in your table at a time, this will probably work just fine for you:
Code: |
REM LVM_GETTOPINDEX = $01039
%%TopItem = @sendmsg(~Table1,$01039,0,0)
REM Add the amount of items a user can see to %P
%%TopItem = @fadd(%%TopItem,50)
REM Do your updates to the table
... Code here ...
REM Use ensurevisible to scroll near what should have been the bottom item before
REM LVM_ENSUREVISIBLE = $01013
%%ret = @sendmsg(~Table1,$01013,%%TopItem,0)
|
_________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|