ActiveX 控制項的開發與應用

來源:互聯網
上載者:User

1.開發:

其他部分省略:

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();           //也可以用COleControl::InvalidateControl

COleControl::OnTimer(nIDEvent);
}

int CActiveXCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)          // 重載ON_CREATE訊息
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;

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

2.使用:

  先必須註冊:如在運行裡輸入:regsvr32  C:\Users\Administrator\Desktop\ActiveX控制項\Debug\ActiveX控制項.ocx

       (反註冊:regsvr32 /u C:\Users\Administrator\Desktop\ActiveX控制項\Debug\ActiveX控制項.ocx )

如在HTML中使用:在其中寫入標記:(還可以使用ACTIVEX CONTROL PAD 、dreamweaver等工具在網頁中插入控制項

<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>

每一個ActiveX Control都會有一個對應的CLSID,該ID是唯一的。通過OBJECT的CLASSID屬性指定ActiveX Contorl的ID,就可以找到相應的ActiveX Control


ACTIVEX CONTROL  PAD

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.