Development and Application of ActiveX Controls

Source: Internet
Author: User

1. Development:

Other parts are omitted:

Void CActiveXCtrl: OnDraw (
CDC * pdc, const CRect & rcBounds, const CRect & rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
OLE_COLOR ole_color_back = GetBackColor ();
OLE_COLOR ole_color_for = GetForeColor ();
COLORREF color_back = TranslateColor (ole_color_back );
COLORREF color_for = TranslateColor (ole_color_for );

CBrush brush (color_back );
Pdc-> FillRect (rcBounds, & brush );
Pdc-> SetBkMode (TRANSPARENT );
Pdc-> SetTextColor (color_for );

CTime time = CTime: GetCurrentTime ();
CString str = time. Format ("% H: % M: % S ");
Pdc-> TextOut (0, 0, str );

}

Void CActiveXCtrl: OnTimer (UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Invalidate (); // you can also use COleControl: InvalidateControl

COleControl: OnTimer (nIDEvent );
}

Int CActiveXCtrl: OnCreate (maid) // reload the ON_CREATE message
{
If (COleControl: OnCreate (lpCreateStruct) =-1)
Return-1;

SetTimer (1,1000, NULL );
Return 0;
}

2. Use:

Registration is required first. For example, enter regsvr32 C: \ Users \ Administrator \ Desktop \ ActiveX Control \ Debug \ ActiveX Control. ocx

(Anti-Registration: regsvr32/u C: \ Users \ Administrator \ Desktop \ ActiveX Control \ Debug \ ActiveX Control. ocx)

For example, use in HTML: Write tags in it: (you can also useActivex control pad, dreamweaver, and other tools insert controls into webpages)

<Object id = "ActiveX1" WIDTH = 100 HEIGHT = 51

CLASSID = "CLSID: B6A3DF15-8C2E-4B7D-A493-BC816224598A">
<Param name = "_ Version" VALUE = "65536">
<Param name = "_ ExtentX" VALUE = "2646">
<Param name = "_ ExtentY" VALUE = "1323">
<Param name = "_ StockProps" VALUE = "0">
</OBJECT>

Each ActiveX Control has a corresponding CLSID, which is unique. You can use the CLASSID attribute of an OBJECT to specify the ActiveX Contorl ID to find the corresponding ActiveX Control.


ACTIVEXCONTROL PAD

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.