Presentation is loading. Please wait.

Presentation is loading. Please wait.

VC 程式設計 Base I 報告者:Jerry Chen TEL:

Similar presentations


Presentation on theme: "VC 程式設計 Base I 報告者:Jerry Chen TEL:"— Presentation transcript:

1 VC 程式設計 Base I 報告者:Jerry Chen TEL:0939-109232

2 Contents 重要資料介紹 基本名詞與概念介紹 程式開發環境安置與範例 Q&A

3 參考 Thinking in C++ 2nd edition Volume 2: Standard Libraries & Advanced Topics

4 參考

5 好書介紹 程式設計領域裡,每個人都想飛,但是還沒有學會走之前,跑都別想! (深入淺出/侯俊傑)

6 重要參考介紹#2 對航海的人來說,擱淺的船就是燈塔!(荷蘭諺語)

7 基本名詞介紹 類別(Class) 物件(Object) 成員函數(Member function)
成員變數(Member variable) 動態連結(Dynamic link library)

8 類別 & 物件 類別(Class) 物件(Object) 8

9 類別 & 物件

10 程式重複使用-方法1 指定物件 寫程式如堆積木,可以重複使用是很重要的! 最簡易的方法是指另這個類別物件。 Light我們稱為類別。
Light it; Light A; Light我們稱為類別。 上訴的it或A物體,我們稱為Light類別的物件。

11 程式重複使用-方法2 加入成員物件 在自己的類別(Class)中加入所需的成員物件(member Object)

12 程式重複使用-方法3 繼承 繼承(Inheritance)
一個子類別繼承父類別(Super class)我們稱為延生類別(Derived class)、或繼承類別(Inherited class)、或子類別(Sub class)、或後代類別(Child class) 如果子類別繼承了一個以上的父類別,則稱為Multiple Inheritance(多重繼承)。 一個形狀類別中有許多功能,可以被新的圓形、方形、三角形等類別繼承來使用。

13 成員函數(Member function) 成員變數(Member variable)
函數 & 變數 成員函數(Member function) 成員變數(Member variable)

14 添加新函數 在三角形類別中,建立出新的功能,例如垂直翻轉成員函數(Member function)、水平翻轉成員函數。

15 Override function 子類別重新定義它所能看到的父類別中的method(如public, protected) 稱為覆寫(Override)。

16 宣告 & 定義 所有C語言都需要宣告與定義才能使用。 宣告(Declaration) : 定義(Definition):
宣告的用意在於把變數或函數的名稱告知編譯器(Compiler)。 宣告檔(Header file),通常以.h作為附檔名! 定義(Definition): 讓編譯器(Compiler)瞭解這個變數或函數已經存在於程式中的某個位置。也是讓編譯器製造出儲存空間給該變數或函數。

17 宣告 & 定義 函數宣告構造(Function declaration syntax)
變數宣告構造 (Variable declaration syntax)

18 宣告 & 定義

19 動態連結(Dynamic link library)
Windows三大動態連結檔 協力廠商提供的動態連結檔

20 Windows中的 三大動態連結檔 GDI32.dll (GDI32.lib) User32.dll (User32.lib)
Kernel32.dll (Kernel32.lib) Commdlg.dll (Comdlg32.lib) Toolhelp.dll (TH32.lib) 20

21 協力廠商提供的 動態連結檔 PCI_M314.dll (先達, Motion) PISODIO.dll (泓格, IO)
MultiCam.dll, EObjMs60d.dll…(Euresys, Vision) MapPro.dll (威嘉, Barcode transfer)

22 綜合範例 Lighting Class

23 ComLighting 範例

24 CComPort 範例

25 MFC Fundamentals & Architecture
25

26 What Is MFC? MFC Collections, Miscellaneous Classes Base MFC Classes
OLE Classes ODBC Classes Win32 API (SDK) OLE ODBC Windows Base OS Services Windows OS Service Extensions

27 MFC 構造 (Architecture) The Application Framework CWinApp Class
CFrameWnd Class Documents and Views Document/View Interaction MFC Document Templates

28 The Application Framework
CWinApp CFrameWnd CDocument CView CDocTemplate MYAPP.EXE

29 Documents and Views Document Possible Views Data 17 98 16 87 56 85 44
17 98 16 87 56 85 44 66 72 19 71 11 45 95 80 51 35 92 56 85 44 66 72 19 71 11 45 95 Possible Views

30 Document/View Interaction (for SDI)
View Object UpdateAllViews , GetNextView GetDocument Document Object GetActiveView GetActiveDocument  AfxGetMainWnd()  AfxGetApp() Frame Object

31 General Approach to MFC Programming
CObject Framework classes CCmdTarget CWinThread CDocTemplate CWnd CDocument CWinApp CFrameWnd CView CDialog CYourApp CMainFrame CYourView CYourDlg CYourDoc

32 Icon Resource

33

34 程式開發環境安置 安裝VC 設定關連環境 程式製作

35

36 安裝VC

37

38 索取序號 事實上,當你安裝完成後還需要做一個動作:註冊。不用擔心,這只是微軟的一個驗證程序而已,過程完全免費。

39 環境設定

40 Visual C++ 範例 Hello Word範例 40

41

42

43

44

45

46 Debug Tools in Visual C++
Standard Build (F7) Build controls Go (F5) Step over (F10) Watch Debug Step Into (F11) WizardBar

47

48 ClassWizard (Ctrl+W)

49 .H file .CPP file class CFirstView : public CView { ...
{ ... / Generated message map functions protected: //{{AFX_MSG(CFirstView) afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; .CPP file BEGIN_MESSAGE_MAP(CFirstView, CView) //{{AFX_MSG_MAP(CMainFrame) ON_WM_LBUTTONDOWN() //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP()

50 void CTest1View::OnLButtonDown(UINT nFlags, CPoint point)
{ // TODO: Add your message handler code here and/or call default CString sOutput; sOutput.Format("x=%d, y=%d",point.x,point.y); CClientDC dc(this); dc.TextOut(point.x,point.y,sOutput); CView::OnLButtonDown(nFlags, point); }

51

52

53 Q&A


Download ppt "VC 程式設計 Base I 報告者:Jerry Chen TEL:"

Similar presentations


Ads by Google