ScrollBars of Webgadget

Just starting out? Need help? Post your questions and find answers here.
Aeroschmelz
User
User
Posts: 25
Joined: Mon Apr 12, 2004 9:14 am

ScrollBars of Webgadget

Post by Aeroschmelz »

Hi Guys,

is it possible to change the scrollbar position of a webgadget ?

Thanks in advance
Aero
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post 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.
Aeroschmelz
User
User
Posts: 25
Joined: Mon Apr 12, 2004 9:14 am

Post by Aeroschmelz »

Can i not use something like this:

SetScrollPos_(GadgetID(gadget),#SB_VERT,y,1)
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post 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
Aeroschmelz
User
User
Posts: 25
Joined: Mon Apr 12, 2004 9:14 am

Post 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_ ?
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

Sparkie,

Even though it exist a better answer your code samlpe is nice and simple.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post 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
Aeroschmelz
User
User
Posts: 25
Joined: Mon Apr 12, 2004 9:14 am

Post 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
Last edited by Aeroschmelz on Tue May 04, 2004 3:58 pm, edited 1 time in total.
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Aeroschmelz
User
User
Posts: 25
Joined: Mon Apr 12, 2004 9:14 am

Post 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()" > 
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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 ...
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Aeroschmelz
User
User
Posts: 25
Joined: Mon Apr 12, 2004 9:14 am

Post by Aeroschmelz »

I thought so ;-)
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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')")
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Aeroschmelz
User
User
Posts: 25
Joined: Mon Apr 12, 2004 9:14 am

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