How to upgrade the activex control in your program

After uninstall the old version and install the upgrade version, follow steps.

For HTML, PHP, ASp, JSP, ASP.NET application, you need change the version number in the Object tag.

<object classid=”clsid:6BA21C22-53A5-463F-BBE8-5CF7FFA0132B” id=”OA1″ width=”674″ height=”500″ codebase=”http://www.ocxt.com/download/officeviewer.cab#6,0,612,1“>

For VC project, you need go to the form and delete the component. Then delete the OfficeViewer1.h and OfficeViewer1.cpp file from your project. Save project then add the Edraw Office Viewer Component from the Toolbox. Then create a blank VC project based on Dialog. Add Edraw office Viewe Component to the Toolbox. Drag it to the dialog. Add variable for the component. You can find the OfficeViewer1.h and OfficeViewer1.cpp file in the new project. Copy the two files to your exsit project. Add exsit items…

For VB project, you need modify these files.

In OfficeViewer.frm

Object = “{F6F03022-1646-4426-A912-1F26464E81AB}#6.0#0″; “officeviewer.ocx”

In OfficeViewer.vbp

Object={F6F03022-1646-4426-A912-1F26464E81AB}#6.0#0; officeviewer.ocx

For C# or VB.NET project, you need delete the component from your form. Then delete the AxOfficeViewer and OfficeViewer references. Then right click the Toolbox and choose item… In the popup Choose Toolbox Items dialog click the COM Component. Then click the Browse… In the Edraw Office Viewer  component install folder, choose the officeviewer.ocx. Then click OK. Drag the component to your form.

ActiveX controls running in the IE process cannot install updates themselves

When IE is in Protected Mode on Windows Vista, ActiveX controls running in the IE process cannot install updates themselves. This is because IE and ActiveX controls do not have write access to most locations in the file system or registry under Protected Mode. As a result, it’s best to use a separate executable to download and install the update. You can further protect users against “man-in-the-middle” attacks by using an SSL connection to download updates. For more information on Protected Mode see the technical article Understanding and Working in Protected Mode.

Similar to the initial install process, your executable will need administrative privileges to install updates for all users on the machine.  To request administrative privileges on Windows Vista, create an application manifest for your executable with the following requested execution level:

<requestedExecutionLevel
level=”requireAdministrator”/>

Note that Windows Vista will see the requested execution level and display a User Account Control (UAC) dialog so the user can elevate the update executable out of Protected Mode.

Pass optional parameters when you call a function in Visual C++

When you call a method that has optional parameters from Visual C++, you cannot omit the optional parameters. You need to pass a special VARIANT instead.

Some methods have “optional” parameters. In Visual Basic, you can omit them when calling the method. However, when calling with Visual C++, you have to pass a special VARIANT whose .vt field has the value VT_ERROR and .scode field has the value DISP_E_PARAMNOTFOUND. That is:

VARIANT varOpt;
varOpt.vt = VT_ERROR;
varOpt.scode = DISP_E_PARAMNOTFOUND;
OfficeViewer1.OfficeProtectDocument(varOpt);

Print MS Word Document to the special printer

When you use the PrintOut method to print the word document with the  component, you maybe get the follow error.

This error can appear if a default printer has not been designated or if the application is unable to locate an existing default printer. To correct this problem, try one of the following in Microsoft Windows:
If a printer is not available in the Print dialog box, add a printer.
If the application cannot find an existing printer that is already installed, set the printer as the default printer.
If a default printer is installed but the application is unable to use it, uninstall the printer driver, and then install the latest version of the printer driver.
If the printer is on a print server, make sure the printer is available, the network is functioning, the server is not stalled, the printer is not out of paper, or the printer is not suspended by the administrator. Printing issues associated with a network printer are best handled by your local network administrator.
For more information about setting up and troubleshooting printer connections, see Windows Help and Support. (Click the Start button, and then click Help and Support.)

Word cannot print. There is no printer installed.

There are some solutions for it.

1. Call the ShowDialog 4 to use the default printer.

2. Word:
    CWordApplication app(m_wnd.get_Application()); 
    CString strOldPrinter = app.get_ActivePrinter();
    app.put_ActivePrinter(strPrinter); 
    app.PrintOut(varFalse, varOptional, varOptional, varOptional,
        varOptional, varOptional, varOptional, varOptional, varOptional,
        varOptional, varOptional, varOptional, varOptional, varOptional,
        varOptional, varOptional, varOptional, varOptional, varOptional); 
    app.put_ActivePrinter(strOldPrinter);

Hide the Office ActiveX Control in Runtime

If you would like to hide the EDraw Office Viewer ActiveX Control in runtime, you need call the “OfficeObjectVisable” method.

For example: axOfficeViewer1.OfficeObjectVisable = false;

The follow code will lead to an error in C#.

axOfficeViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
axOfficeViewer2.Visible = false;
axOfficeViewer3.Visible = false;

PDF Viewer Component – Disables the Save, Print, Copy Buttons

DisableSaveToolbarButton
Function: boolean DisableSaveToolbarButton (boolean bDisable);
Description: Disables the Save button at the toolbars. The method must be call after the PDF file opened.

DisablePrintToolbarButton
Function: boolean DisablePrintToolbarButton ();
Description: Disables the Print button at the toolbars. The method must be call after the PDF file opened.

DisableCopyToolbarButton
Function: boolean DisableCopyToolbarButton ();
Description: Disables the Copy button at the toolbars. The method must be call after the PDF file opened.

DisableSpecialToolbarButton
Function: boolean DisableSpecialToolbarButton(BSTR nameButton);
Description: Disables the special button at the toolbars. The method must be call after the PDF file opened.
Params:
nameButton: If you want to disable the special button at the toolbars, you need know the button’s name in the Adobe Reader. For examples: the Save button has a name as “SaveFileAs”. You can also use the follow values: Save, Print, CreatePDF, SendMail, Collaborate, Search, Copy.

Events in the PDF Viewer Component

PDF Viewer Component Events

1. Ready to Open Document Event
Event: HRESULT NotifyCtrlReady();
Description: Ready to open document.
When the component finished the initialization the NotifyCtrlReady event is raised. The event allows you to open a new document after the component has released all the resources are ready to open a new document.
HTML + JScript
&lt;html&gt;
&lt;script language=javascript id=clientEventHandlersJS&gt;
function NotifyCtrlReadyEvent ()
{
PDFViewer1.Open “http://www.ocxt.com/demo/sample.pdf”
}
&lt;/script&gt;

&lt;body&gt;
&lt;object classid=”clsid: 44A8091F-8F01-43B7-8CF7-4BBA71E61E04 ” id=”PDFViewer1″ width=”657″ height=”452″&gt;
&lt;param name=”Toolbars” value=”0″&gt;
&lt;/object&gt;
&lt;/body&gt;

&lt;script language=”JScript” for=PDFViewer1 event=” NotifyCtrlReady ()”&gt;
NotifyCtrlReadyEvent ();
&lt;/script&gt;
&lt;/html&gt;

2. Document Opened Event
Event: void OnDocumentOpened([in] BSTR FileName);
Description: Called when document is opened or new document added.
Every time a user opened a file successfully, the OnDocumentOpened event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
&lt;script language=”JScript” for=PDFViewer1 event=” OnDocumentOpened(FileName)”&gt;
OnDocumentOpenedEvent(FileName);
&lt;/script&gt;
&lt;script language=javascript&gt;
function OnDocumentOpenedEvent(FileName)
{
Alert(“Respond the Document Opened Event.”);
}
&lt;/script&gt;

3. Document Close Event
Event: void OnDocumentClosed();
Description: Called when document is closed.
Every time a user closed a file successfully, the OnDocumentClosed event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
&lt;script language=”JScript” for= PDFViewer1 event=” OnDocumentClosed()”&gt;
OnDocumentClosedEvent();
&lt;/script&gt;
&lt;script language=javascript&gt;
function OnDocumentClosedEvent()
{
Alert(“Respond the Document Close Event.”);
}
&lt;/script&gt;

4. Before Document Closed Event
Event: void BeforeDocumentClosed( [in,out] VARIANT* Cancel);
Description: Called before document is closed (may be canceled).
Every time before a user closed a document the OnActivationChange event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
&lt;script language=”JScript” for= PDFViewer1 event=” BeforeDocumentClosed (Cancel)”&gt;
OnBeforeDocumentClosedEvent(GoingActive);
&lt;/script&gt;
&lt;script language=javascript&gt;
function OnBeforeDocumentClosedEvent (GoingActive)
{
Alert(“Respond the Before Document Closed Event.”);
}
&lt;/script&gt;

5. Before Document Saved Event
Event: void BeforeDocumentSaved( [in,out] VARIANT* Cancel);
Description: Called before document is saved (may be canceled).
Every time a user opens a new document or closes a document the OnActivationChange event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
&lt;script language=”JScript” for= PDFViewer1 event=” BeforeDocumentSaved( Cancel)”&gt;
OnBeforeDocumentSavedEvent(GoingActive);
&lt;/script&gt;

&lt;script language=javascript&gt;
function OnBeforeDocumentSavedEvent ( Cancel)
{
Alert(“Respond the Before Document Saved Event.”);
}
&lt;/script&gt;

6. Before Right Click the Window
Event: HRESULT OnWindowBeforeRightClick();
Description: Called before right click the component. The event needs the DisableViewRightClickMenu method or DisableToolbarRightClickMenu method is called.

7. Before Double Click the Window
Event: HRESULT OnWindowBeforeDoubleClick ();
Description: Called before double click the component.

8. Before Download File
Event: HRESULT BeforeDownloadFile ();
Description: Called before downloading the file.

9. Download File Completed
Event: HRESULT DownloadFileComplete ();
Description: Called when the file was downloaded completely.

PDF Viewer Component – Disables the Hot Keys such as Save, Copy, Print.

Enable the developers to disables the Hot Keys such as Save, Copy, Print in the PDF Viewer Component.
Function: void DisableHotKeyPrint();
  void DisableHotKeySave();
  void DisableHotKeyCopy();
  void DisableHotKeyShowBookMarks();
  void DisableHotKeyShowThumnails();
  void DisableHotKeyShowToolbars();
  void DisableHotKeySearch();
Description: Disables the hotkeys at the Adobe Reader.

PDF Viewer Component – Disable File Toolbar

Function: boolean DisableFileToolbar (boolean bDisable);
Description: Disables the File toolbars. The method must be call after the PDF file opened.

PDF Viewer Component – Disable View Right Click Menu

Function: boolean DisableViewRightClickMenu (boolean bDisable);
Description: Disables the right click menu at the view. The method must be call after the PDF file opened.