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