Active X, Again; Sorry Jose

Started by Brad Warmuskerken, October 21, 2004, 01:22:22 PM

Previous topic - Next topic

Jose Roca

To use ActiveX controls with FireFly is easy. Simply follow the steps explained in the help file ("Working with OCX/ActiveX Controls"). The difficult part is that you have to learn how to use a particular control (i.e. to read the documentation). I can give help to solve general problems and give workarounds, but to make detailed examples implies that I will need to have the controls installed in my computer and expend a lot of time learning how to use them. I have posted several examples in the PB forums from where you can extract the relevant code, but the most important is to learn COM programming and this takes time and patience.

An example of how to load an excel sheet in your dialog.

1. In the Tools window, double-click on the OCX/ActiveX control or click on the tool once and then draw the size of your control on the Form.

2. Click on the OCX_ProgID property, select in the browser SHDOCVW.DLL (Microsoft Internet Controls) and click the "Shell.Explorer" ProgID. This will create an instance of Internet Explorer.

3. In the FORM1_WM_CREATE event put the following code:

  Dim vVar As Variant
  ' // Load an excel sheet - Remember to change the path
  vVar = "D:\Archivos de Programa\Microsoft Office\Office10\3082\VBAList.xls"
  Object Call DISPATCH_FORM1_OCXCONTROL1.Navigate(vVar)

That's all. Instead of putting the code in the WM_CREATE event you can, for example, put a button in the form to call the OpenFileDialog and then fill vVar with the selected file and call the Navigate method.

How it works: Excel sheets are Ole controls. To host an Ole control we need an Ole container. Internet Explorer is an Ole container, so we begin hosting an instance of Internet Explorer in our dialog and then we use the Navigate method of IE to load the Excel sheet.

I don't like IE as a web browser, but the browser component can be used to embed many kinds of documents in our dialogs, such excel sheets, word documents, html pages, pictures, etc.

Jose Roca

I have posted a small tutorial to use the Microsoft Common Dialog Control.
http://www.planetsquires.com/forums/viewtopic.php?t=1165
If I find the time I will post other tutorials to show how to use other controls that come with Visual Studio, like the Masked Edit control.