Article ID 1657
Article Title INFO: Uniformity of images displayed in VDF applications (JPEG)
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=1657
KBase Category Visual DataFlex
Date Created 08/07/2002
Last Edit Date 10/30/2008


Article Text
Uniform Placement Of Graphics Files In Visual Dataflex Using Internet Explorer Controls

It is quite easy to incorporate JPEG, GIF, and even PNG image files to display in a control in Visual Dataflex.  The graphics can be displayed neatly and in proportionately within the display window.  The only drawbacks of this method are that Internet Explorer must be installed on the computer running the VDF program and a temporary one line HTML file must be written to give the attributes of the image you are going to display.  I write to the same file each time, and write it on the Client's Windows Temp Directory on their C: Drive because its just temporarily needed.

Installing the Microsoft Internet Controls
1.Open the Studio and select File > New > Class from the menu, double-click on "Import COM ActiveX".
2.The Control should be listed as "Microsoft Internet Controls" (The version I used was 1.1)
3.You may want to select or create a Palette for the controls to appear in the controls palette. I just used the default ActiveX palette.
4.Click the "OK" button and the controls will then be added to the palette you have chosen.

Using the Microsoft Internet Controls to Display Images
1.In the Controls Palette, select the tab where you placed the Microsoft Internet Controls.
2.There should be a cWebBrowser control in there.  This is what we need to work with.
3.Draw a cWebBrowser on your View.  The default object name will be something like oWebBrowser1.  This is what I'm going to use in this example but you may name it anything you like.
4.When you want to display an image to the cWebBrowser control, you will have to output the appropriate HTML to send to the control.  Here is an example that will display an image in the control, centered with the height filling 100% of the cWebBrowser object it is sent to.

direct_output "c:\test.html"
writeln '<body scroll="no" oncontextmenu="return false">'
writeln '<center><img src="c:\testimg.jpg" height="100%"></center>'
writeln '</body>'
close_output

For simplicity of the example, I hardcoded all of the values and attributes to the HTML file.  You may want to build a string and write it instead if some of the values are dynamic such as the name of the image to be displayed and the percentage or pixel size you wish to view it.

It is also possible to make the width fill the window instead of the height by using width="100%" in place of the height="100%" attribute.  If you use them both the image will stretch to fill the size of the cWebBrowser control you send it to.  If you would rather specify a pixel size instead of a percentage of the available window size, if you just leave out the "%" sign in the width and height attributes it will interpret the size in pixels rather than a percentage of the overall window size.

5.To display the HTML file we created to the cWebBrowser control, use the following code.  Remember, my cWebBrowser object is called oWebBrowser1.

Send ComNavigate to oWebBrowser1 "c:\test.html" 0 0 0 0

All of this worked out quite nicely, and definitely produced the type of results we were looking for in our situation.  Quality of the images displayed in the VDF program were a definite issue in this project, and having to resize and resave all of the images so they would fit properly in any average ActiveX Image Display control and still look equally well would not be an option, especially because this picture project would be on-going and a permanent solution that required no image editing had be be developed.  This solution provided the uniformity we were looking for and was quite simple to implement.


Contributed By:
John Hulsman
Company: Jasper Engines & Transmissions
email: jhulsman@jasperengines.com
Web Site: http://www.jasperengines.com


Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2024 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.