Programming implementation of internal COM plug-ins in Access2000

xiaoxiao2021-03-06  41

Keyword COM original author Name Xu Jing Zhou Article Original Source Future Studio (Future Studio)

Introduction to programming implementation of internal COM plug-ins in Access 2000

Reader Rating 10 Ratings 2

Programming internal COM plug-in under the body of Access2000 achieve Author: Xu Jing Zhou download the sample code introduction here, we still have to achieve internal COM plug-in Access2000 use VC6 in the ATL, as for the basic principles and detailed implementation methods and procedures, you can see the front My article Wait, here only indicate that it is different from the internal COM plug-ins (such as Word2000, Excel2000, PowerPoint2000, Outlook2000) in other OFFICE2000, articles and sample code Find in http://www.vckbase.com website. Below is the effect of the ACCESS2000 COM plug-in sample code running: Specific implementation Open VC6.0, select ATL COM AppWizard in the new project, enter AccessAddin in the right project name, click Finish button to complete the project creation. Next, select the menu INSERT-> New ATL OBJEC item, select the corresponding Objects corresponding to the right of Objects corresponding to the appropriate Objects in the pop-up, click Next, enter acceaddin in the pop-up dialog box, point OK to complete Insert an ATL object. Then by importing the model library, the right click on the CACCEADDIN class in ClassView in the CACCEADDIN class in ClassView, select the Implement Interface item in the pop-up. Click Add Typelib in the Pop-up Implementation Interface dialog box. In the pop-up Browse Type Libraries dialog box, scroll down the Microsoft Add-in Designer (1.0) sub-item, point OK button. Select the _idtextensibility2 interface in the pop-up list dialog, point the OK button to complete the import. The system will automatically generate the five required number of interfaces mentioned above. Let's take a look at the difference between them.

First point: Registration type information Different (* .RGS), below the contents of the file accedin.rgs, add the code: HKCU {Software {microsoft {office {access {addins {'accessaddin.accedin' {VAL FriendlyName = S 'Access2000 plug-in' val description = s 'Using ATL development Access2000 internal plug-in' val loadingbehavior = d '00000003' VAL commandlinesafe = d '0000000000'}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} The import library of the type in. Hye The source code will be different, and the following code can be added to STDAFX.H.

#pragma Warning (Disable: 4146) // Temporary Shielding Compile 4146 Warning Information // Import Access2000 Required Type Library ADO, DAO, VBE, OFFICE and Access libraries (specific path can be set according to actual conditions, Jingzhou Xu) # Import "D: // Program files // Common files // system // ado // msado21.tlb" NO_NAMESPACE / RENAME ("EOF", "AdoEOF") #import "D: // Program files // Common files / / Microsoft Shared // DAO // Dao360.dll "Rename (" EOF "," Endoffile ") / Rename (" Bof "," Begoffile ") # import" E: // Program Files // Microsoft Office // Office / /mso9.dll "Rename_NameSpace (" Office ") Using Namespace Office; #import" D: // Program files // circon files // microsoft shared // vba // vba6 // vbe6ext.olb "rename_namespace (" VBE6 ") using namespace VBE6; #import "E: // Program Files // Microsoft Office // Office / MSACC9.OLB" named_guids, rename_namespace ( "MSACCESS") using namespace MSACCESS; #pragma warning (default: 4146) // compile-time recovery 4146 Warning Information The third point of the Access 2000 does not have an ActiveExplorer object, so it is necessary to obtain the Commandbars directly from the _application to the _Application without the Outlook2000.

Source modification section as shown below: // unloaded when installed plug-in processing, jingzhou xu STDMETHOD (OnConnection) (IDispatch * Application, ext_ConnectMode ConnectMode, IDispatch * AddInInst, SAFEARRAY * * custom) {CComPtr spCmdBars; / / Access Interface application _Application CComQIPtr spApp (application); ATLASSERT (spApp); // Get CommandBars interfaces HRESULT hr = spApp-> get_CommandBars (& spCmdBars); if (FAILED (hr)) return hr; ATLASSERT (spcmdbars); // Add a toolbar and its previous bitmap button CCOMVARIANT VNAME ("New Access 200 Tool Bar Plugin"); ccomptrmdbar; spnewcmdbar; // New Toolbar position CCOMVARIANT VPOS ( 1); ccomvariant vTemp (Variant_true); // Temporary CCOMVARIANT VEMPTY (vt_e_paramnotfound, vt_error); // Add a toolbar with add method and let spnewcmdbar point to it spnewcmdbar = spcmdbars-> add (vname, vpos, vempty , vTemp); // Get the CommandBarControls of the new toolbar, thus add button CComptr spBarControls; spBarControls = spNewCmdBar-> GetControls (); ATLASSERT (spBarControls); // MsoControlType :: msoControlButton = 1 CComVariant vToolBarType (1); // show the toolbar CComVariant vShow (VARIANT_TRUE); CComPtr spNewBar; // add the first button in the Add method with CommandBarControls, point to it and let spNewBar spNewBar = spBarControls-> Add (vToolBarType, vEmpty, vEmpty, vEmpty, vShow); ATLASSERT (spNewBar); // Specify the _commandbarbutton interface for each button, can specify ccomqiptr

转载请注明原文地址:https://www.9cbs.com/read-76615.html

New Post(0)