C # ActiveX screenshot printing Control

Source: Internet
Author: User

C # reference for ActiveX control development:

Http://www.cnblogs.com/zhf/archive/2009/03/02/1401299.html

Http://www.cnblogs.com/homer/archive/2005/01/08/88780.html

 

C # For details about ActiveX development, see the above two articles.

1. to implement a script to call the ActiveX method, you must define the method into an interface (this interface uses a unique GUID and cannot be the same as the GUID of the ActiveX control ), then, the ActiveX method is used to implement the method in this interface in the control class.

2. When using the WebBrowser control in ActiveX, you cannot drag it out of the Toolbox directly. You only need to declare a WebBrowser object and instantiate it when necessary. Otherwise, ActiveX cannot be used normally. Even if there is no problem during local testing, you will find that the WebBrowser object has been released on the page.

3. In Windows 7, you must run VS as an administrator and set the COM automatic registration to complete the process smoothly.

 

Take my code as an example:

Code
 Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Drawing;
Using System. Data;
Using System. Text;
Using System. Windows. Forms;
Using System. Runtime. InteropServices;

Namespace EstatePrintMapActiveX
{
// Control class. GUID can be generated in the tool. The GUID here is the CLASSID used to reference the control on the page.
// ComVisible (true) sets whether to automatically register the control, set "register for COM" under "generate" in project properties to check the check box for automatic local registration (windows7 needs to run this project as an administrator)
[Guid ("rj1e5a8-b698-4e57-8b56-b5b06b69ff4d"), ProgId ("EstatePrintMapActiveX. UserControl1 "),
ClassInterface (ClassInterfaceType. None), ComVisible (true)]
Public partial class UserControl1: UserControl, IMonitor, IObjectSafety
{
# Region IObjectSafety member implementation

Public void GetInterfacceSafyOptions (int riid, out int pdwSupportedOptions, out int pdwEnabledOptions)
{
PdwSupportedOptions = 1;
PdwEnabledOptions = 2;
}

Public void SetInterfaceSafetyOptions (int riid, int dwOptionsSetMask, int dwEnabledOptions)
{
Throw new NotImplementedException ();
}

# Endregion

System. Windows. Forms. WebBrowser webBrowser;

Bool isDetailPrint = false; // multiple copies are printed by default.
String stringUrl; // the URL of the page to be printed

Public UserControl1 ()
{
InitializeComponent ();
}

// Method for JS call (must be defined in the IMonitor interface, and the interface name can be customized)
Public void SetUrlText (string strUrl, string hPa)
{
If (HPA = "1 ")//
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.