Page 1 of 2
ScrollBars of Webgadget
Posted: Sun May 02, 2004 7:13 pm
by Aeroschmelz
Hi Guys,
is it possible to change the scrollbar position of a webgadget ?
Thanks in advance
Aero
Posted: Sun May 02, 2004 7:41 pm
by freedimension
IMHO only through the shown HTML-documents.
When I recall it right, there should be a possibility with the css-rule direction set to rtl in the body tag!? But be careful, the alignement of other elements will also change, this effect can be compensated by capsulating them within an div set to direction:ltr.
Posted: Mon May 03, 2004 7:39 pm
by Aeroschmelz
Can i not use something like this:
SetScrollPos_(GadgetID(gadget),#SB_VERT,y,1)
Posted: Mon May 03, 2004 9:16 pm
by freedimension
Well, the WebGadget is nothing but an embedded IE-Window. So it behaves like that and I've never heard that the user itself can choose as to where the scrollbars should go.
Try
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Scrollbar to the left</TITLE>
</HEAD>
<BODY style="direction:rtl">
<div style="direction:ltr">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci
tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo
consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse
molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et
accumsan et iusto odio dignissim qui blandit praesent luptatum zzril
delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit
amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod
tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad
minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl
ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse
molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et
accumsan et iusto odio dignissim qui blandit praesent luptatum zzril
delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum
soluta nobis eleifend option congue nihil imperdiet doming id quod mazim
placerat facer possim assum.
</div>
</BODY>
</HTML>
if you are the one writing the HTML to be shown
Posted: Tue May 04, 2004 8:19 am
by Aeroschmelz
I am working on a small programm, where i would like to define the viewable area of a html page with scroll parameters like this /X=100 /Y=100. It works with a scroll area gadget, but it looks a little bit strange with two sets of scrollbars. Is it not possible to manipulate the position of the scrollbars from within purebasic with an api command like setscrollPOS_ or setScrollWindow_ ?
Posted: Tue May 04, 2004 2:22 pm
by Sparkie
I'm sure there's a better way (IHTMLElement2 Interface?) to do this, but my knowledge doesn't reach that far.
Here's a JavaScript way of setting the scrollbars...
Code: Select all
#READYSTATE_UNINITIALIZED=0
#READYSTATE_LOADING=1
#READYSTATE_LOADED=2
#READYSTATE_INTERACTIVE=3
#READYSTATE_COMPLETE=4
page_loaded = #False
If OpenWindow(0, 0, 0, 650, 500, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Set scroll bars")
If CreateGadgetList(WindowID())
WebGadget(0,10,10,630,480,"http://www.purebasic.com")
WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(0), #GWL_USERDATA)
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
WebObject\get_ReadyState(@webState)
If webState = #READYSTATE_COMPLETE And page_loaded = #False
SetGadgetText(0,"javascript:window.scrollTo(50, 150)"); sets x, y scroll position
page_loaded = #True
EndIf
Until Event = #PB_EventCloseWindow
End
Posted: Tue May 04, 2004 2:41 pm
by fweil
Sparkie,
Even though it exist a better answer your code samlpe is nice and simple.
Rgrds
Posted: Tue May 04, 2004 3:20 pm
by freedimension
Ah, now I see what you were asking for. So I was on the wrong track all the time

kewl
I'm not sure if I can help you, but have you ever tried to get the window handle of the WebGadget and then simply call SetScrollPos() or the like?
Perhaps the Window with the Scrollbars isn't the same like the Window containing the WebGadget. In this case a) Fred could enlighten us or b) you could experiment a little with GetWindow()
Good luck
Posted: Tue May 04, 2004 3:31 pm
by Aeroschmelz
Thanks for the answers !! It works, but is really slow until something happens. Perhaps Fred does know the answer ? I thought the same about the handle and tried all variations of this code with all children under the gadget (looked into it with Winspector Spy), but it didn't worked either
Code: Select all
hwin=FindWindow_(0, "Webbrowser")
hwin = GetWindow_(hwin,#GW_child)
Do you see some potential to optimize this code:
Code: Select all
Repeat
Delay=(500)
Event = WindowEvent()
WebObject\get_Busy(@IsBusy.l)
If IsBusy
Loading.f=1
Else
Loading.f=0
Delay=(500)
UseWindow(0)
MoveWindow(WindowXPos.f,WindowYPos.f)
ResizeWindow(WindowWidth.f, WindowHeight.f)
AnimateWindow_(WindowID(0), 800, #AW_BLEND)
EndIf
WebObject\get_ReadyState(@webState)
If webState = 4 And page_loaded = #False
SetGadgetText(1,"javascript:window.scrollTo(50, 150)"); sets x, y scroll position
page_loaded = #True
EndIf
Until Loading=0 And page_loaded =#True
Posted: Tue May 04, 2004 3:57 pm
by fweil
...,
SetScrollPos_() returns false from API.
This means probably that WebGadget's scrollbars are not defined at the CreateWindow(Ex)_ level.
I don't know how to get scrollbar's handles then.
Rgrds
Posted: Tue May 04, 2004 4:00 pm
by Aeroschmelz
Is there also a possibility to get this java code working in the same way ?:
Code: Select all
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function BodyZoom()
{
top.location.href = "http://www.google.de"
document.body.style.zoom = 2
}
//-->
</SCRIPT>
</head>
<BODY ID="bd" OnLoad="BodyZoom()" >
Posted: Tue May 04, 2004 4:42 pm
by fweil
...,
I only remember the following is possible :
Code: Select all
url$="javascript:document.write('<BODY BGCOLOR=#000000 TEXT=#FFFF00><H1><U>Hello World</U></H1></BODY>'); document.close()"
setgadgettext(#WebGadget, url$)
But I guess it does not go well using head functions ...
Posted: Tue May 04, 2004 4:53 pm
by Aeroschmelz
I thought so

Posted: Tue May 04, 2004 6:15 pm
by Sparkie
Aeroschmelz wrote:Is there also a possibility to get this java code working in the same way ?:
Code: Select all
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function BodyZoom()
{
top.location.href = "http://www.google.de"
document.body.style.zoom = 2
}
//-->
</SCRIPT>
</head>
<BODY ID="bd" OnLoad="BodyZoom()" >
How about this for the zoom...
Code: Select all
SetGadgetText(0,"javascript:void(document.body.style.zoom='2.0')")
Posted: Tue May 04, 2004 6:54 pm
by Aeroschmelz
Sparkie, you are my Javascript god, you brought a big smile on my face, thanks a lot

Is it possible to merge the two commands into one, because i just realized, that it uses only one command at the time.