OLE Browser control properties (OpenInsight 32-bit)
At 09 SEP 2020 10:36:56AM Nick Stevenson wrote:
Hi folks
OI9.4
I am using a standard OI window OLE control (Shell.Explorer) to display various images.
Works fine.
You can use Ctrl- and Ctrl+ to resize the image in the control.
How can I set the size the of the image to fit the control once I have loaded the image using:
Call Send_Message(@window:'.BROWSER', 'Navigate2', fullfileName)
tia
Nick
At 09 SEP 2020 12:26PM bob carten wrote:
can you try the equivalent of the f11 key?
I think it would be something like
el =OleGetProperty( @window:'.BROWSER', 'document.documentElement') oleCallMethod(el, 'requestFullScreen')
At 09 SEP 2020 03:20PM Nick Stevenson wrote:
Hi Bob
I get a message "Error loading oleGetProperty" - I think this function needs an object rather than a controlID. So I'm stuck
figuring out what to use in OleCreateInstance if that is the case.
So looking at the iWebBrowser2 methods in https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752094(v=vs.85) I can get the method "GoHome" to work but cannot get "FullSCreen" to work.
Call Send_Message(@window:'.BROWSER', 'GoHome') works great!
Call Send_Message(@window:'.BROWSER', 'FullScreen', 1') does nothing.
But maybe I'm barking up the wrong tree - this is an area I am very unfamiliar with.
At 10 SEP 2020 04:19PM Carl Pates wrote:
Nice,
As you're already playing with the IWebBrowser2 interface take a look at the ExecWB method and see if any of those commands help you.
I suspect that the best way forward would be to load a HTML page into the browsercontrol and then load your image into that - then you can have full control over the image though HTML/JS.
At 11 SEP 2020 05:04AM Nick Stevenson wrote:
Hi Carl
Please forgive my ignorance on this subject, I am not really familiar with the OLE concept in OI and so I just need some basics to get going with it.
I have a window with an OLE control on it, called BROWSER (Class Shell.Explorer)
I use Call Send_Message(@window:'.BROWSER', 'Navigate2', fullfileName) to display an image into that control. All good.
So now to use the ExecWB method do I use the same Send_Message subroutine, for example:
Call Send_Message(@window:'.BROWSER', 'ExecWB', 'OLECMDID_OPTICAL_ZOOM', '10')Or do I need to use the OLECallMethod function, in which case I need to create an object instance:
oleObj = OleCreateInstance('INTERNETEXPLORER.APPLICATION.1')ReturnValue = OleCallMethod(oleObj, 'ExecWB', 'OLECMDID_OPTICAL_ZOOM','10')(But I don't see how this relates to the BROWSER control).Neither of these methods work for me so obviously I'm on the wrong track completely.
I'd be grateful if you could just point me in the right direction.
Thanks
Nick
At 11 SEP 2020 05:35AM Carl Pates wrote:
Hi Nick,
The ExecWB commands are equated numeric constants rather than strings - here's an insert from v10 that defines them:
compile insert msWin_OLECMDID_Equates /* ** Copyright (C) 2016 Revelation Software Inc. All Rights Reserved ** Author Mr C Date May 2016 Purpose OLECMDID constants Comments ======== Amended Date Reason ======= ==== ====== */ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// #ifndef _MSWIN_OLECMDID_EQUATES_ #define _MSWIN_OLECMDID_EQUATES_ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// equ OLECMDID_OPEN$ to 1 equ OLECMDID_NEW$ to 2 equ OLECMDID_SAVE$ to 3 equ OLECMDID_SAVEAS$ to 4 equ OLECMDID_SAVECOPYAS$ to 5 equ OLECMDID_PRINT$ to 6 equ OLECMDID_PRINTPREVIEW$ to 7 equ OLECMDID_PAGESETUP$ to 8 equ OLECMDID_SPELL$ to 9 equ OLECMDID_PROPERTIES$ to 10 equ OLECMDID_CUT$ to 11 equ OLECMDID_COPY$ to 12 equ OLECMDID_PASTE$ to 13 equ OLECMDID_PASTESPECIAL$ to 14 equ OLECMDID_UNDO$ to 15 equ OLECMDID_REDO$ to 16 equ OLECMDID_SELECTALL$ to 17 equ OLECMDID_CLEARSELECTION$ to 18 equ OLECMDID_ZOOM$ to 19 equ OLECMDID_GETZOOMRANGE$ to 20 equ OLECMDID_UPDATECOMMANDS$ to 21 equ OLECMDID_REFRESH$ to 22 equ OLECMDID_STOP$ to 23 equ OLECMDID_HIDETOOLBARS$ to 24 equ OLECMDID_SETPROGRESSMAX$ to 25 equ OLECMDID_SETPROGRESSPOS$ to 26 equ OLECMDID_SETPROGRESSTEXT$ to 27 equ OLECMDID_SETTITLE$ to 28 equ OLECMDID_SETDOWNLOADSTATE$ to 29 equ OLECMDID_STOPDOWNLOAD$ to 30 equ OLECMDID_ONTOOLBARACTIVATED$ to 31 equ OLECMDID_FIND$ to 32 equ OLECMDID_DELETE$ to 33 equ OLECMDID_HTTPEQUIV$ to 34 equ OLECMDID_HTTPEQUIV_DONE$ to 35 equ OLECMDID_ENABLE_INTERACTION$ to 36 equ OLECMDID_ONUNLOAD$ to 37 equ OLECMDID_PROPERTYBAG2$ to 38 equ OLECMDID_PREREFRESH$ to 39 equ OLECMDID_SHOWSCRIPTERROR$ to 40 equ OLECMDID_SHOWMESSAGE$ to 41 equ OLECMDID_SHOWFIND$ to 42 equ OLECMDID_SHOWPAGESETUP$ to 43 equ OLECMDID_SHOWPRINT$ to 44 equ OLECMDID_CLOSE$ to 45 equ OLECMDID_ALLOWUILESSSAVEAS$ to 46 equ OLECMDID_DONTDOWNLOADCSS$ to 47 equ OLECMDID_UPDATEPAGESTATUS$ to 48 equ OLECMDID_PRINT2$ to 49 equ OLECMDID_PRINTPREVIEW2$ to 50 equ OLECMDID_SETPRINTTEMPLATE$ to 51 equ OLECMDID_GETPRINTTEMPLATE$ to 52 equ OLECMDID_PAGEACTIONBLOCKED$ to 55 equ OLECMDID_PAGEACTIONUIQUERY$ to 56 equ OLECMDID_FOCUSVIEWCONTROLS$ to 57 equ OLECMDID_FOCUSVIEWCONTROLSQUERY$ to 58 equ OLECMDID_SHOWPAGEACTIONMENU$ to 59 equ OLECMDID_ADDTRAVELENTRY$ to 60 equ OLECMDID_UPDATETRAVELENTRY$ to 61 equ OLECMDID_UPDATEBACKFORWARDSTATE$ to 62 equ OLECMDID_OPTICAL_ZOOM$ to 63 equ OLECMDID_OPTICAL_GETZOOMRANGE$ to 64 equ OLECMDID_WINDOWSTATECHANGED$ to 65 equ OLECMDID_ACTIVEXINSTALLSCOPE$ to 66 equ OLECMDID_UPDATETRAVELENTRY_DATARECOVERY$ to 67 /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // OLECMDEXECOPT constants equ OLECMDEXECOPT_DODEFAULT$ to 0 equ OLECMDEXECOPT_PROMPTUSER$ to 1 equ OLECMDEXECOPT_DONTPROMPTUSER$ to 2 equ OLECMDEXECOPT_SHOWHELP$ to 3 /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // OLECMDDF constants equ OLECMDF_SUPPORTED$ to 0x1 equ OLECMDF_ENABLED$ to 0x2 equ OLECMDF_LATCHED$ to 0x4 equ OLECMDF_NINCHED$ to 0x8 equ OLECMDF_INVISIBLE$ to 0x10 equ OLECMDF_DEFHIDEONCTXTMENU$ to 0x20 /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// #endif /////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////Regards
At 11 SEP 2020 06:25AM Nick Stevenson wrote:
Thanks Carl,
That's a great help, thanks.
I still cannot get ExecWB to do anything.
trying to set zoom percentage to 10% Call Send_Message(@window:'.BROWSER', 'ExecWB', 63, 10) trying to bring up print preview
Call Send_Message(@window:'.BROWSER', 'ExecWB', 50)
Nick
At 11 SEP 2020 07:06AM Carl Pates wrote:
Nick,
It might be the fact that you're loading a "raw" image rather than a HTML document that references the image, and TBH, without digging into this further, I don't know. You could try that yourself and see if there's any difference?
Here's some sample code from an old Rev Conference presentation I did that shows the Print Preview window - note that it uses the QueryStatusWB method to check if the operation can be performed first.
equ OLECMDID_PRINTPREVIEW$ to 7 wbStatus = send_Message( @window : ".OLE_WB", | "OLE.QueryStatusWB", | OLECMDID_PRINTPREVIEW$ ) if bitAnd( wbStatus, 2 ) then call send_Message( @window : ".OLE_WB", | "OLE.ExecWB", | OLECMDID_PRINTPREVIEW$, 0 ) end
At 11 SEP 2020 07:36AM Nick Stevenson wrote:
Hi Carl
That's brilliant. I can now see that OLECMDID_OPTICAL_ZOOM is not allowed, either with an html document or with an image. So a dead-end. I'll have to find another method to resize the image.
Thanks so much for you help, it's now starting to make sense.
Regards
Nick
At 11 SEP 2020 08:45AM bob carten wrote:
Hi Nick,
Following up on what Carl mentioned earlier, you could start with a template with an image tag sized at 100% in it, load that into the browser control and then set the src property to the location of the image.
I have an example from OI10 using the chromium control, see below.
For OI9, I would swap tin the image path, osWrite the template to the %temp% folder, then Send_message 'Navigate2' to open the file.
[code
]UpdateImage:
Use an HTML template preconfigured with references to the JQPLot components in the O4W folder
Expect a the calling section to load a variable named "content" with a javascript function named rti_displayit
The function looks like
rti_displayit(p1,p2) { instructions to display the graph } * status = true$ * Preserve the content. Will use this on the size event to know if window should redisplay If Assigned(content) Else content = null$ Set_Property(atWindow, udp_content$, content) ControlName = atWindow:".OLE_WB" html = null$ * Retrieve the HTML template * It is a base HTML form with references to all of the JQPLot plugins * We will swap in a javascript function named rti_displayit which define and displays the specific graph * * The html template is stored as an stproc insert * I used IFDEFS to escape non-basic script without causing compile errors * Get the text of the insert call Set_Status(0) reposID = @appid1<1>:"*STPROCINS**IMAGE_HTML_TEMPLATE" work = Repository('ACCESS', reposId) If Get_Status(unused) Then call Set_Status(0) work = null$ End * Parse out the HTML from inside the #IFDEF / #ENDIF start_token = "<html>" end_Token = "</html>" start_pos = indexc(work,start_token,1) end_pos = indexc(work,end_token,1) + Len(end_token) html_len = end_pos-start_pos html = work[start_pos,html_len] * Swap in the location * This code assumes your template has <img src="%IMAGEPATH%"/> in it If content != null$ Then Swap "%IMAGEPATH%" with image_path in html End * Set the baseFileUrl property * The chromium control will use this as the starting point for all relative references * Use ".\O4W\templates\" so that relative paths for scripts will be correct * For example * <script type="text/javascript" src="../plugins/jqplot/plugins/jqplot.dateAxisRenderer.js"></script> * will resolve to the correct location under .\O4W * Get current Oi folder oiHome = drive() If oiHome[-1,1] != '\' Then * sometimes windows appends '\', sometimes it doesn't oihome := '\' end * Set the browser so that all relative references are from here baseFileURL = "file:":oihome:"O4W/Templates/"Convert '\' To '/' In baseFileUrl
Load our html into the control
Ensure that the chrome control is readyLooprs = Get_Property(ControlName, "isReady")While rs = "0"call yield()Repeatexec_method( ControlName, "setHTML", html, baseFileURL)Call Set_Status(0)Return
</code>
At 11 SEP 2020 10:24AM Nick Stevenson wrote:
Thanks Bob, that's a clever way round the problem. I think it's worth a try…
I need to be careful regarding images as they could be pdfs.
Thanks for your trouble on this.
Nick