INTRODUCTION TO COM.DOC

Similar documents
untitled

概述

epub83-1

Microsoft PowerPoint - ch6 [相容模式]

VB程序设计教程

ebook50-15

,, 1 ( ) 1 / CurrentSeries Int ConnectionString CString Style3D BOOL IsContinue Graph BOOL LegendType Int SeriesName CString SeriesColor OL E

ebook50-11

Microsoft Word - template.doc

AL-M200 Series

Microsoft Word - Learn Objective-C.doc

WinMDI 28

新时期共青团工作实务全书(三十九)

1.ai

高雄市左營國民小學八十九學年度第一學期一年級總體課程教學進度表

Microsoft PowerPoint - OPVB1基本VB.ppt

提问袁小兵:

CANVIO_AEROCAST_CS_EN.indd

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

ebook140-8

untitled

2/80 2

範本檔

mvc

<4D F736F F F696E74202D20312EB9FEB6FBB1F5B9A4D2B5B4F3D1A7D5E7C1BCA3BAC3E6CFF2D1D0BEBFC9FAB8B4CAD4B5C4BDE1B9B9BBAFC3E6CAD4BFBCBACBCCBDCBF7D3EBCAB5BCF92E BBCE6C8DDC4A3CABD5D>

Windows XP

PTS7_Manual.PDF

Outline USB Application Requirements Variable Definition Communications Code for VB Code for Keil C Practice

RunPC2_.doc

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

InstallShield InstallShield InstallShield Windows Installer ISWI ISWI InstallShield InstallShield InstallShield Windows Installer WI In

ebook50-14

Microsoft Word - ch04三校.doc

C/C++程序设计 - 字符串与格式化输入/输出

錄...1 說...2 說 說...5 六 率 POST PAY PREPAY DEPOSIT 更

Microsoft Word - 3D手册2.doc

科学计算的语言-FORTRAN95

新・解きながら学ぶJava

高尔夫赌博现金棋牌,能赚现金的棋牌游戏 街机赌博游戏 真钱的棋牌游戏,30

EJB-Programming-3.PDF

Business Objects 5.1 Windows BusinessObjects 1

(i) (ii) (iii) (iv) 380,000 [ ] , , % % % 5.5% 6.5%

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1.

Chapter 9: Objects and Classes

Microsoft Word - 苹果脚本跟我学.doc

What You Can Find with SciFinder Scholar SciFinder Scholar Area Information Available in SciFinder Scholar Document Title Information Author/inventor

國家圖書館典藏電子全文

untitled

IBM Rational ClearQuest Client for Eclipse 1/ IBM Rational ClearQuest Client for Ecl

基于UML建模的管理管理信息系统项目案例导航——VB篇

ebook14-4

1. 2. Flex Adobe 3.

Tel: Fax: TTP-344M/246M /

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor

行业

Eclipse C C++, or

CHAPTER VC#

AL-MX200 Series

穨ac3-3.PDF

<4D F736F F D20A4BAA4E52DA4A4B2A3AEF8B64FAF53BC782E646F63>

Oracle Oracle Solaris Studio IDE makefile C C++ Fortran makefile IDE Solaris Linux C/C++/Fortran Oracle IDE "P

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

C/C++ - 字符输入输出和字符确认

IP Encoder 1 channel.book

Text 文字输入功能 , 使用者可自行定义文字 高度, 旋转角度 , 行距 , 字间距离 和 倾斜角度。

untitled

untitled

CC213

Microsoft Word - 01.DOC

Strings

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM

IP505SM_manual_cn.doc

Microsoft Word - Functional_Notes_3.90_CN.doc

FY.DOC

行业

關於本書 l 3 PhoneGap Appcelerator Titanium Sencha Touch (wrapper framework) Native App PhoneGap Build Native App Hybrid App Java Objective-C Android SDK

<ADB6ADB1C25EA8FAA6DB2D4D56432E706466>

Microsoft Word - SupplyIT manual 3_cn_david.doc

untitled

untitled

穨文件1

C/C++ - 函数

Microsoft Word - 第3章.doc

概述

EJB-Programming-4-cn.doc

Microsoft Word - CIN-DLL.doc

Microsoft Word - OPIGIMAC 譯本.doc

audiogram3 Owners Manual

( 表 1) 學 校 基 本 資 料 學 校 類 型 新 竹 市 東 區 新 竹 國 小 班 級 數 55 校 址 新 竹 市 興 學 街 106 號 電 話 傳 真 網 址

例 度 讀 讀 不 不 來 念 來 了 讀 不 不 讀 不 讀行 利 了 說 更 了 讀

行业

管道建模基础.ppt

Microsoft Word _4

郑州大学(下).doc

厨房小知识(六)

广 东 纺 织 职 业 技 术 学 院 发 展 党 员 公 示 制 实 施 办 法 关 于 推 荐 优 秀 团 员 作 为 党 的 发 展 对 象 工 作 的 意 见 后 勤 管 理 工 作 广 东 纺 织 职 业 技 术 学 院 新 引 进 教 职 工 周 转 房 管 理


游戏攻略大全(五十).doc

Transcription:

How About COM & ActiveX Control With Visual C++ 6.0 Author: Curtis CHOU mahler@ms16.hinet.net This document can be freely release and distribute without modify.

ACTIVEX CONTROLS... 3 ACTIVEX... 3 MFC ACTIVEX CONTROLWIZARD... 3 MFC ACTIVEX CONTROLS WIZARD... 4 MFC... 4... 5 ACTIVEX... 5 ONDRAW... 5 ONDRAW()... 6 ACTIVEX... 6 (STOCK PROPERTIES)... 6... 6 CLASSWIZARD... 9... 9... 10 GET/SET METHOD...11... 12... 13... 14 ACTIVEX... 16... 16 CLASSWIZARD... 16 CLASSWIZARD... 16 ACTIVEX (ACTIVEX CONTROL EVENT)... 18... 18... 18 (CUSTOM EVENT)... 20 ACTIVEX... 20 ACTIVEX... 20... 22... 24... 26... 27... 30 2 34 MFC

ActiveX Controls ActiveX MFC ActiveX ControlWizard 1. File -> New -> Project 2. Choose MFC ActiveX Control Wizard 3. 99 run-time license Help File 3 34 MFC

4. Window MFC ActiveX Controls Wizard Control module DLL CyyyApp Control CyyyCtrl Property Page CYyyPropPage MFC MFC COleControl ActiveX 4 34 MFC

COleControl CWnd Window Registry HKEY_CLASSES_ROOT HKEY_CLASSES_ROOTCLSID 128bit GUIDGlobal Unique Identifier DLL RegSvr32.exe DLL ActiveX OnDraw(CDC* pdc, const CRect& rcbounds, const CRect& rcinvalid) ; pdc drawing DC rcbounds rcinvalid MFC COleControl::InvalidateControl CWnd::Invalid OnDraw WMPAINT COleControl::OnPaint() DC OnDraw() COleControl::OnDraw() VB WM_PAINT COleControl::OnDraw() 5 34 MFC

ActiveX OnDraw() Active (InActive) (FrameWork) OnDraw() OnDraw() (0,0) DCDevice Context (0,0)DC (Stock Properties) ActiveX BackColor BorderStyle FillColor Font Enabled Text Caption VC ClassWizard 6 34 MFC

1. ClassWizard (Ctrl + W) 2. Automation (Control Class) Add Property 7 34 MFC

3. External name OK 4. ClassWizard 8 34 MFC

ClassWizard ActiveX ClassWizard COleControl::InvalidateControl() InvalidateControl InvalidateControl OnForeColorChanged() VC Dispatch map entry macro DISP_PROPERTY_NOTIFY (Member Variable) DISP_PROPERTY 9 34 MFC

Get/Set Method DISP_PROPERTY_EX DISP_PROPERTY_PARAM Get Set ActiveX Dispatch map entry macro 1. ClassWizard 2. Automation class name Add Property 3. External name 4. Type 5. Implementation Member Variable Get/Set Method 6. OK ClassWizard OK 10 34 MFC

Get/Set Method Get/Set Get : Set : Add Property 11 34 MFC

Add Property ClassWizard Edit Code Read-Only Write-Only Get Set Read-Only Set Write-Only Get 12 34 MFC

Get/Set Method Add Property Parameter List 15 13 34 MFC

MFC COleControl::GetAmbientProperty() Dispatch ID Dispatch ID OleCtl.h COleControl function AmbientBackColor AmbientDiaplayName AmbientFont AmbientForeColor AmbientLocaleID AmbientTextAlign AmbientUserMode AmbientUIDead ID Dispatch ID OleCtl.h OleCtl.h #define DISPID_AUTOSIZE (-500) #define DISPID_BACKCOLOR (-501) #define DISPID_BACKSTYLE (-502) #define DISPID_BORDERCOLOR (-503) #define DISPID_BORDERSTYLE (-504) #define DISPID_BORDERWIDTH (-505) #define DISPID_DRAWMODE (-507) #define DISPID_DRAWSTYLE (-508) #define DISPID_DRAWWIDTH (-509) 14 34 MFC

#define DISPID_FILLCOLOR (-510) #define DISPID_FILLSTYLE (-511) #define DISPID_FONT (-512) #define DISPID_FORECOLOR (-513) #define DISPID_ENABLED (-514) #define DISPID_HWND (-515) #define DISPID_TABSTOP (-516) #define DISPID_TEXT (-517) #define DISPID_CAPTION (-518) #define DISPID_BORDERVISIBLE (-519) #define DISPID_APPEARANCE (-520) 15 34 MFC

ActiveX ClassWizard DoClick Refresh DoClick() COleControl::DoClick() Refresh() CWnd::Invalidate() ClassWizard 1. ClassWizard Automation 2. Class Add Method 3. External name 4. OK Edit ClassWizard 1. ClassWizard Automation 16 34 MFC

2. Class Add Method 3. External name 4. Internal name 5. (Return Type) 6. Parameter 7. OK Edit 17 34 MFC

ActiveX (ActiveX Control Event) 15 ActiveX Control (Handler)COleControl Event Click DbClick Error KeyDown KeyUp MouseDown MouseUp MouseMove Click 1. ClassWizard 2. ActiveX Event CLASS NAME 18 34 MFC

3. [Add Event] External name 4. OK BEGIN_EVENT_MAP(CClockCtrl, COleControl) //{{AFX_EVENT_MAP(CClockCtrl) EVENT_STOCK_CLICK() //}}AFX_EVENT_MAP END_EVENT_MAP() 19 34 MFC

(Custom Event) 1. ClassWizard ActiveX Event 2. [Add Event] 3. External Name 4. Internal name FireXxxxXxxx 5. Parameter 6. OK EVENT MAP EVENT_CUSTOM() BEGIN_EVENT_MAP(CClockCtrl, COleControl) //{{AFX_EVENT_MAP(CClockCtrl) EVENT_CUSTOM("TestIt", FireTestIt, VTS_I2) EVENT_STOCK_CLICK() //}}AFX_EVENT_MAP END_EVENT_MAP() ActiveX ActiveX 20 34 MFC

VB ActiveX MFC Dialog Class 21 34 MFC

(Property Page) 1. Dialog DIALOG 2. DIALOG ActiveX 3. ClassWizard Dialog Class 4. Member Variable Control ID [Add Variable] 22 34 MFC

23 34 MFC

DoDataExchange DDX(Do Data Exchange) OK DoDataExchange() void CDialog2::DoDataExchange(CDataExchange* pdx) { } CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDialog2) DDX_Text(pDX, IDC_EDIT1, m_test1); //}}AFX_DATA_MAP DDX MFC Property Dialog DoDataExchange() DDP DDP_Text(pDX, IDC_CAPTION, Caption ) pdx IDCCAPTION IDCatpion ActiveX Caption DDP DDP_CBIndex combo box 24 34 MFC

DDP_CBString DDP_CBStringExact DDP_Check DDP_LBIndex DDP_LBString DDP_LBStringExact DDP_Radio DDP_Text combo box combo box Check Box list box list box list box Radio Button 25 34 MFC

DDP //{{AFX_DATA_MAP(CAlarmPropPage) DDP_Text(pDX, IDC_ALARM_HOUR, m_alarmhour, _T("AlarmHour") ); DDX_Text(pDX, IDC_ALARM_HOUR, m_alarmhour); DDV_MinMaxInt(pDX, m_alarmhour, 0, 23); DDP_Text(pDX, IDC_ALARM_MINUTE, m_alarmminute, _T("AlarmMinute") ); DDX_Text(pDX, IDC_ALARM_MINUTE, m_alarmminute); DDV_MinMaxInt(pDX, m_alarmminute, 0, 59); DDP_Text(pDX, IDC_ALARM_SOUND, m_alarmsound, _T("AlarmSound") ); DDX_Text(pDX, IDC_ALARM_SOUND, m_alarmsound); DDP_Text(pDX, IDC_ALARM_COMMAND, m_alarmcommand, _T("AlarmCommand") ); DDX_Text(pDX, IDC_ALARM_COMMAND, m_alarmcommand); DDP_Check(pDX, IDC_ALARM_SET, m_balarmset, _T("AlarmSet") ); DDX_Check(pDX, IDC_ALARM_SET, m_balarmset); DDP_CBIndex(pDX, IDC_ALARM_TYPE, m_alarmtype, _T("AlarmType") ); DDX_CBIndex(pDX, IDC_ALARM_TYPE, m_alarmtype); //}}AFX_DATA_MAP DDP_PostProcessing(pDX); MFC Font chooser Pricture chooser Color chooser Class ID CLSID_CFontPropPage CLSID_CPicturePropPage CLSID_CColorPropPage CXxxCtrl BEGIN_PROPPAGEIDS(CClockCtrl, 3) PROPPAGEID(CClockPropPage::guid) PROPPAGEID(CAlarmPropPage::guid) PROPPAGEID(CLSID_CColorPropPage) END_PROPPAGEIDS(CClockCtrl) 26 34 MFC

1. 2. 3. 1. Property Page 2. Property Page 3. Property Class 4. Property Page 1. 2. IDD_PROPPAGE_Xxxx(Xxxx ) 3. child window thin border 4. TitleBar Visible 5. 250 x 62 250 x 110 compiler i.. ClassWizard 27 34 MFC

ii. COlePropertyPage iii. OK 1. String Table ID IDS_Xxxx_PPG Xxxx Property Page 2. IDS_Xxxx_PPG_CAPTION Xxxx 3. UpdateRegistry() AfxOleRegisterPropertyPage BOOL CXxxx::CXxxxFactory::UpdateRegistry(BOOL bregister) { // TODO: Define string resource for page type; replace '0' below with ID. if (bregister) return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),m_clsid, IDS_Xxxx_PPG ); else return AfxOleUnregisterClass(m_clsid, NULL); } 4. COlePropertyPage() ID CXxxx::CXxxx() : { } COlePropertyPage(IDD, IDD_Xxxx_PPG_CAPTION) //{{AFX_DATA_INIT(CXxxx) // NOTE: ClassWizard will add member initialization here // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_DATA_INIT 28 34 MFC

5. map 29 34 MFC

1. ROC 2. 3. Class ClassWizard ROC m_broc BOOL 4. OK CLASSWIZARD EDIT CODE OnRocChanged() InvalidateControl() void CROCCtrl::OnROCChanged() { // TODO: Add notification handler code InvalidateControl(); SetModifiedFlag(); 30 34 MFC

} 5. CROCCtrl CString m_strroc ; CString m_strstd; 31 34 MFC

6. CROCCtrl::OnDraw // TODO: Replace the following code with your own drawing code. CBrush brush(rgb(128,128,0)) ; pdc->fillrect(rcbounds, &brush) ; int x = rcbounds.right / 3 ; int y = rcbounds.bottom / 4 ; if ( m_broc) pdc->textout(x, y, m_strroc) ; else pdc->textout(x, y, m_strstd) ; 7. CROCCtrl ClassWizard MESSAGE HANDLER WMCREATE OnCreate() WM_DESTROY OnDestroy(); 8. OnCreate() int CROCCtrl::OnCreate(LPCREATESTRUCT lpcreatestruct) { if (COleControl::OnCreate(lpCreateStruct) == -1) return -1; SetTimer(1, 1000, NULL) ; return 0; } 9. OnDestroy() void CROCCtrl::OnDestroy() { COleControl::OnDestroy(); KillTimer(1) ; } 10. ` TIMER ClassWizard WM_TIMER TIMER void CROCCtrl::OnTimer(UINT nidevent) { // TODO: Add your message handler code here and/or call default COleDateTime today = COleDateTime::GetCurrentTime() ; char year[5] ; char output[50] ; strcpy(output, " " ) ; itoa(today.getyear() - 1911, year, 10 ) ; 32 34 MFC

strcat(output, year ) ; strcat(output, "" ) ; m_strroc = output ; strcpy(output, " " ) ; itoa(today.getyear(), year, 10 ) ; strcat(output, year ) ; strcat(output, "" ) ; m_strstd = output ; } COleControl::OnTimer(nIDEvent); 11. Property Page 12. Resource Editor OlePropertyPage 13. IDD_PROPPAGE_SET String Table IDS_SET_PPG [ ] IDS_SET_PPG_CAPTION [ ] 14. ClassWizard CLASS CSetPropPage COlePropertyPage. UpdateRegistry() ID CROCCtrl Property Page Map 15. ClassWizard IDC_CHECK1 m_broc; BOOL 16. DDP CSetPropPage::OnDataExchange() void CSetPropPage::DoDataExchange(CDataExchange* pdx) { } // NOTE: ClassWizard will add DDP, DDX, and DDV calls here // DO NOT EDIT what you see in these blocks of generated code! //{{AFX_DATA_MAP(CSetPropPage) DDX_Check(pDX, IDC_CHECK1, m_broc); DDP_Check(pDX, IDC_CHECK1, m_broc, "ROC") ; //}}AFX_DATA_MAP DDP_PostProcessing(pDX); 33 34 MFC

34 34 MFC