Discussions related to Visual Prolog
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

How to scroll dynamically an AcroPDFControl ?

Unread post by Tonton Luc »

Hi,

I try to scroll dynamically an acroPDFControl without succes.
The acroPDF control named acroPDFControl_ctl and it is in a form.

Here is my code :

Code: Select all

facts     pdfBrowser1 : iAcroAXDocShim_import := uncheckedConvert(iAcroAXDocShim_import,null).     si_upd:integer:=0.   clauses     onShow(_Source, _Data):-         acroPDFControl_ctl:setSubClassHandler(action_sub,false),         pdfBrowser1 := acroPDFControl_ctl :get_IAcroAXDocShim_import(),         ouvrir_nouvo_pdf()         .   clauses ouvrir_nouvo_pdf():-     if not(pdfBrowser1=uncheckedConvert(iAcroAXDocShim_import,null)) then         pdfBrowser1 : setShowToolbar(true()),         pdfBrowser1 : setShowScrollbars(true()),         _R2 = pdfBrowser1:loadFile(taskWindow::nom_pdf()),         if not(taskWindow::nom_pdf() = "") then             pdfBrowser1:gotoNextPage(),             pdfBrowser1:gotoNextPage(),             pdfBrowser1:setView("FitB") %%Fit/FitH/FitV/FitB/FitBH/FitBV         end if     end if.   predicates action_sub:eHandler.   clauses action_sub(_Win,e_MouseMove(_Pnt,_ShiftCtrlAlt,_Buttons))=0:-     if si_upd = 0 then         RCT = vpi::wingetClientRect(acroPDFControl_ctl:getVpiWindow()),         OBJ = acroPDFControl_ctl : getActiveXContainer(),         if OBJ2 = OBJ :  tryGetOleControlContainerSite() then             _ = OBJ : onPosRectChange(RCT,OBJ2:getIPSite())         end if,         si_upd := 1     end if,     !.
I've tried gui_native::scrollWindowEx or gui_native::scrollWindow but the result is not ok (but I'm not sure of my code, specially the NullRect ???).
Here is a part of my code :

Code: Select all

clauses activer_barre_vert():-     OBJ = acroPDFControl1_ctl : getActiveXContainer(),     Hdl = OBJ:getWindow(),     Lst_Hdl = vpi::winGetChildWindows(Hdl),     foreach Cpt = std::fromTo(0,list::length(Lst_Hdl)-1) do         Hdl_ss_Ctrl = list::nth(Cpt,Lst_Hdl),         Titre_Classe = string::create(255),         _ = gui_native::getClassName(Hdl_ss_Ctrl,Titre_Classe,255),             if Titre_Classe = "ScrollBar",                 Lg = gui_native::getWindowLong(Hdl_ss_Ctrl,gui_native::gwl_style),                 Total = gui_native::ws_child + gui_native::ws_visible + gui_native::sb_vert,                 Lg = Total then                     NullRct = uncheckedConvert(vpiDomains::rct, 0),                     Pos = vpi::winGetScrollPos(Hdl_ss_Ctrl,sb_Ctl),                     Parent = vpi::winGetParent(Hdl_ss_Ctrl),                     R_scrollWindowEx = gui_native::scrollWindowEx(Parent,0,100,NullRct,NullRct,0,NullRct,gui_native::sw_invalidate) % not ok %                    _ = gui_native::setScrollPos(Hdl_ss_Ctrl,sb_Ctl,Pos+100,gui_native::sw_invalidate) %                    vpi::winSetScrollPos(Hdl_ss_Ctrl,sb_Ctl,Pos + 100),%vpi::winInvalidate(Hdl_ss_Ctrl) %                    vpi::winSetState(Hdl_ss_Ctrl,[wsf_visible]) %                    _ = vpi::winSendEvent(Hdl_ss_Ctrl,e_VScroll(sc_ThumbTrack,Pos+100)),vpi::winInvalidate(Hdl_ss_Ctrl) %                    Parent = vpi::winGetParent(Hdl_ss_Ctrl), %                    _ = vpi::winSendEvent(Parent,e_VScroll(sc_PageDown,Pos+100))%,vpi::winInvalidate(Hdl_ss_Ctrl) %                    Parent = vpi::winGetParent(Hdl_ss_Ctrl),vpi::winUpdate(Parent) %vpi::winInvalidate(Parent) %                    _ = vpi::winSendEvent(Parent,e_update(vpi::winGetClientRect(Parent))) %                    _ = vpi::winSendEvent(Parent,e_VScroll(sb_Vert,Pos+100)) /*                     Rect = vpi::winGetClientRect(Hdl),Rect = rct(Gauch,Haut,Droit,Bas),                     New_rect = rct(Gauch,Haut+100,Droit,Bas+100), %                    R_scrollWindow = gui_native::scrollWindow(Hdl,0,100,New_rect,NullRct)%,vpi::winInvalidate(Hdl) % not ok %                    R_scrollWindow = gui_native::scrollWindow(Hdl,0,100,NullRct,New_rect)%,vpi::winInvalidate(Hdl) % not ok %                    R_scrollWindow = gui_native::scrollWindow(Hdl,0,100,New_rect,New_rect)%,vpi::winInvalidate(Hdl) % not ok %                    R_scrollWindow = gui_native::scrollWindow(Hdl,0,100,New_rect,Rect)%,vpi::winInvalidate(Hdl) % not ok %                    R_scrollWindow = gui_native::scrollWindow(Hdl,0,100,Rect,New_rect)%,vpi::winInvalidate(Hdl) % not ok %                    R_scrollWindow = gui_native::scrollWindow(Hdl,0,100,Rect,Rect)%,vpi::winInvalidate(Hdl) % not ok                     R_scrollWindow = gui_native::scrollWindow(Hdl,0,100,NullRct,NullRct)%,vpi::winInvalidate(Hdl) % not ok %                    ScrollFlags = bit::bitOr(gui_native::sw_erase,gui_native::sw_invalidate,gui_native::sw_scrollchildren), %                    ScrollFlags = bit::bitOr(gui_native::sw_invalidate,gui_native::sw_scrollchildren), %                    R_scrollWindowEx = gui_native::scrollWindowEx(Hdl,0,100,NullRct,NullRct,0,NullRct,gui_native::sw_invalidate) */             end if     end foreach,     !.
Any :idea:
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

That will not work (as you have discovered).

scrollWindow and scrollWindowEx are primitives intended to implement the scrolling of a window, i.e. when you are drawing/writing the window contents. They will move the pixels of a region to another region and you will then draw/write the remaining area, instead of redrawing/rewriting the entire window. So they are primitives for accelerating the drawing/writing when scrolling.

What you need is to ask the acroPDFControl to scroll its contents. If the control have a scrollbar you could potentially simulate a mouse click in this scrollbar, but normally you would do such things by some dedicated predicate/function in the controls API.

I am not familiar with the acroPDFControl, so I don't know how it is done. But I guess that other people have done it using other programming languages, so a broad Internet search may give you the clues to how to do it.
Regards Thomas Linder Puls
PDC
Post Reply