MFC 2/e PDF GBK mirror - anyway solution MFC 1/e MFC 2/e

Size: px
Start display at page:

Download "MFC 2/e PDF GBK mirror - anyway solution MFC 1/e MFC 2/e"

Transcription

1 2/e 1998/04 MFC 1/e Windows MFC MFC 2/e 1998/ UNALIS 3/e 2/e 2/e 3/e 3/e MFC 2/e MFC 3/e MFC MFC 2/e VC5+MFC42 VC6+MFC421 MFC 2/e 1

2 MFC 2/e PDF GBK mirror - anyway solution MFC 1/e MFC 2/e jjhou@ccca.nctu.edu.tw

3 dissecting MFC 2/e part1.pdf chap1~chap3 3,384,209 dissecting MFC 2/e part2.pdf chap4 2,448,990 dissecting MFC 2/e part3.pdf chap5~chap7 2,158,594 dissecting MFC 2/e part4.pdf chap8~chap16 5,171,266 dissecting MFC 2/e part5.pdf appendix A,B,C,D 1,527, the end 3

4 3 深入淺出 MFC 2nd Edition 309

5 310 第㆔篇淺出 MFC 程式設計

6 第 5 章總觀 Application Framework Application Framework Application Framework Application Framework Object Oriented 311

7 第㆔篇淺出 MFC 程式設計! Application Framework Application Framework Framework... MDI OLE ODBC Printing Preview C++ Microsoft MFC Borland OWL IBM OpenClass C Runtime Windows API Application Framework application object MFC CWinApp 312

8 第 5 章總觀 Application Framework 'new' ) Application Framework Application Framework ) Application Framework CASE Computer Aid Software Engineering tool Application Framework Integrated Development Environment IDE Microsoft Borland Symantec Watcom IBM Application Framework IC POP Application Framework MFC OWL OpenClass application object 313

9 第㆔篇淺出 MFC 程式設計 Application Framework Application Framework Application Framework MFC?! MFC MFC application object MFC CWinApp 5-1 MFC File/Open Application Framework Serialize Serialize UI UI UI application framework Application Framework -- C++ override C++ C++ MFC MFC C++ C++ 314

10 第 5 章總觀 Application Framework CMyWinApp theapp; // global object... BOOL CMyWinApp::InitInstance() CMultiDocTemplate* pdoctemplate; pdoctemplate = new CMultiDocTemplate( IDR_MYTYPE, RUNTIME_CLASS(CMyDoc), RUNTIME_CLASS(CMyMDIChildWnd), RUNTIME_CLASS(CMyView)); AddDocTemplate(pDocTemplate);... View object CMyMDIFrameWnd* pmymainframe = new CMyMDIFrameWnd; MDIChildWnd object Application object MDIFrameWnd object Document object CObject CCmdTarget CWinThread CView CMyView CFrameWnd CMDIFrameWnd CMDIChildWnd CMyMDIChildWnd CDocument CMyDoc CDocTemplate CWnd CWinApp CMyWinApp CMultiDocTemplate CMyMDIFrameWnd 5-1 MFC Application Framework MFC MFC 315

11 第㆔篇淺出 MFC 程式設計 MIS MIS Application Framework Application Framework MFC Serialize File/Open File/Save Document Serialization Serialize MFC Windows ) MDI OLE Application Framework Application Framework Framework Framework Application Framework 316

12 第 5 章總觀 Application Framework Application Framework 1985 Apple MacApp Application Framework The key ideas of a commercial application framework : a generic app on steroids that provides a large amount of general-purpose functionality within a well-planned, welltested, cohesive structure. MacApp Application Framework Application Framework

13 第㆔篇淺出 MFC 程式設計 Apple Application Framework an extended collection of classes that cooperate to support a complete application architecture or application model, providing more complete application development support than a simple set of class libraries. Ray Valdes Dr. Dobb's Journal "Sizing up Application Frameworks and Class Libraries" An application framework is an integrated object-oriented software system that offers all the application-level classes(documents, views, and commands)needed by a generic application. An application framework is meant to be used in its entirety, and fosters both design reuse and code reuse. An application framework embodies a particular philosophy for structuring an application, and in return for a large mass of prebuilt functionality, the programmer gives up control over many architectural-design decisions. Donald G. Firesmith "Frameworks : The Golden path of the object Nirvana" Application Framework What are frameworks?they are significant collections of collaborating classes that capture both the small-scale patterns and major mechanisms that, in turn, implement the common requirements and design in a specific application domain. 318

14 第 5 章總觀 Application Framework Bjarne Stroustrup C++ The C++ Programming Language Application Framework Libraries build out of the kinds of classes described above support design and re-use of code by supplying building blocks and ways of combining them; the application builder designs a framework into which these common building blocks are fitted. An alternative, and sometimes more ambitious, approach to the support of design and reuse is to provide code that establishes a common framework into which the application builder fits application-specific code as building blocks. Such an approach is often called an application framework. The classes establishing such a framework often have such fat interfaces that they are hardly types in the traditional sense. They approximate the ideal of being complete applications, except that they don't do anything. The specific actions are supplied by the application programmer. Kaare Christian 1994/02/08 PC Magazine "C++ Application Frameworks" post-and-beam post-and-beam DIY V Do It Yourself -- Application Framework Windows Application Framework Windows post-and-beam Windows C Windows 319

15 第㆔篇淺出 MFC 程式設計 C++ Application Framework Windows Application Framework message loops Windows Application Framework -- Windows C++ -- Windows API Application Framework Windows C++ Application Framework Windows Framework Application Framework OCX OLE UI Application Framework Framework Windows Framework Application Framework Visual Basic Application Framework Application Framework C++ Framework 320

16 第 5 章總觀 Application Framework Application Framework Application Framework PC Application Framework C++ PC PC Application Framework C++ UNIX PC C++ Smalltalk-80 Application Framework Application Framework Application Framework Class Library GUI toolkits robustness raw API GUI toolkits Class Library Application Framework MFC OWL Open Class Library PC Application Framework Application Framework 321

17 第㆔篇淺出 MFC 程式設計 Application Framework, Class Library, GUI toolkit Class Library GUI toolkit Application Framework Class Library Application Framework Class Library Class Library UI GUI toolkit Class Library UI GUI toolkit assembly GUI Windows GUI toolkit DOS Chatter Box DOS GUI Application Framework Windows API MFC APIs Application Framework Windows API MFC OWL Application Framework Application Framework Application Framework 322

18 第 5 章總觀 Application Framework Application Framework Application Framework Windows API Windows API ? ? ? Multimedia Ex ? Win32s Win API Jungle 323

19 第㆔篇淺出 MFC 程式設計 Microsoft Foundation Classes(MFC) PC C++ Application Frameworks Microsoft MFC Microsoft Foundation Classes Borland OWL Object WindowLibrary IBM VisualAge C++ Open Class Library C++ Watcom Symantec Metaware Integraded Development Environment IDE Application Framework MFC Delphi Pascal Application Framework Java Application Framework Delphi Visual Basic RAD Rapid Application Development PME Properties-Method-Event components properties events methods Borland 1997 C++ Builder PME Visual Component Library VCL C++ Builder RAD Windows SDK Software Development Kit Windows API Windows... API Application Programming Interface 324

20 第 5 章總觀 Application Framework Windows APIs APIs Windows MFC APIs 1989 Application Framework AFX C++ Windows AFX "X" "utilize the latest in object oriented technology to provide tools and libraries for developers writing the most advanced GUI applications on the market" Windows -- Windows -- "deliver the power of object-oriented solutions to programmers to enable them to build world-class Windows based applications in C++." Windows 3.0 C++ AFX MFC C++ C++ Windows MFC WinMain RegisterClass Window Procedure Windows Windows 325

21 第㆔篇淺出 MFC 程式設計 MFC AFX Windows Message Mapping Message routing C++ MFC MFC Application Framework MFC MFC 5-3 MFC... LRU MDI About menu toolbar MDI Help statusbar indicator pane 5-3 MFC 326

22 第 5 章總觀 Application Framework Visual C++ MFC 1992/04 C/C MFC ,000 C++ 60 Windows "thin and efficient C++ transformation of the Windows API" /07 Win32 SDK MFC 1.0 AFX Document/View UI AFX MFC UNIX XWindow OS/2 PM Mac System 7 Windows 16 Windows 3.x 32 Windows 95 Windows NT Visual C C/C MFC /03 Windows 3.x /08 Windows NT Visual C for Windows NT MFC 2.1 MFC ,000 C Visual C++ Wizards MFC /12 16 Visual C MFC 2.5 OLE2 ODBC 327

23 第㆔篇淺出 MFC 程式設計 1994/09 Visual C MFC Windows NT Windows 95 thread-safe UI Property Sheet miniframe MFC collections template-based Segmented Executable Linker Incremental Linker OBJ EXE, Win32 memory-mapped file, Windows NT Windows 95 editbuildrun-debug, Incremental Linker 1995/01 MAPI Messaging API WinSock MFC Windows 95 tree tooltip spin slider progress RTF edit 1995/07 MFC /09 32 MFC 4.0 DAO OCX containers Visual C template RTTI C++ IDE Class View Resource View File View Wizardbar ClassWizard Components Gallery AppWizard 1996 MFC 4.1 ISAPI Internet Server API CHttpServer CHttpFilter CHttpServerContext CHttpFilterContext CHtmlStream Web ISAPI Extension Wizard Visual C Game SDK Windows 95 Visual C

24 第 5 章總觀 Application Framework OLE OCXs OLE ActiveX Visual C VxD 1996 MFC 4.2 ActiveX Standard C++ Library Win32 Internet WinInet Internet binding data sources Visual C Wizard ActiveX Web GIF JPEG 1997 Visual C Visual C++ Visual Tools Visual Studio 97 Visual C++ Visual Basic Visual J++ Visual InterDev Visual FoxPro Visual Studio 97 MFC 4.21 ATL Active Template Library 2.1 ActiveX MFC Windows C++ MFC/C++ Application Framework MFC MFC MFC application framework MFC 329

25 第㆔篇淺出 MFC 程式設計 MFC General Purpose classes -... indows API classes - Windows API DC... pplication framework classes - Document/View level abstractions - operation system extensions - OLE ODBC DAO MAPI WinSock ISAPI General Purpose classes MFC Windows MFC Windows DOS CObject MFC CObject CObject RTTI Persistence Dynamic Creation Diagnostic DOS MFC CArchive CDumpContext CRuntimeClass collection classes collection Array 330

26 第 5 章總觀 Application Framework List Map List key String-to-String Map - Word-to-Ptr 16 Map Serialization S MFC collection classes CObject CObject CArray (template) CByteArray CDWordArray CObArray CPtrArray CStringArray CUIntArray CWordArray Arrays of of user types CList (template) CPtrList CObList CStringList Lists of of user types Typed Template Collections CTypedPtrArray CTypedPtrList CTypedPtrMap CMap (template) CMapWordToPtr CMapPtrToWord CMapPtrToPtr CMapWordToOb CMapStringToPtr CMapStringToOb CMapStringToString Maps of of user types CRect - Windows RECT Windows CRect MFC CSize - Windows SIZE CPoint - Windows POINT Windows 331

27 第㆔篇淺出 MFC 程式設計 CPoint MFC CTime - static GetCurrentTime + - += -+ CTimeSpan - CString - = += < > exception handling classes exception MFC Exception Handling MFC 11 CException CArchiveException CDaoException CDBException CFileException CMemoryException CNotSupportedException COleException COleDispatchException CResourceException CUserException 332

28 第 5 章總觀 Application Framework Windows API classes MFC Windows API CWinThread - MFC 3.0 MFC thread-safe SDK CWinApp - MFC CWinThread 32 Windows CWinApp m_szexename ProcessShellCommand CWnd - view C++ handle C++ C++ CWnd WM_ WM_COMMAND handle C++ CWnd m_hwnd handle CWnd CWnd handle HWND hwnd = pwnd->m_hwnd; CCmdTarget - CWnd WM_COMMAND GDI DC Menu 333

29 第㆔篇淺出 MFC 程式設計 Application framework classes Document/View MFC application framework Document/View Document/View/Frame Document Template CDocTemplate CSingleDocTemplate CMultiDocTemplate - Document Template Document View Frame CSingleDocTemplate CMultiDocTemplate MDI SDI MDI CSingleDocTemplate SDI CMultiDocTemplate MDI SDK MDI CMultiDocTemplate SDI CSingleDocTemplate CDocument - CDocument Serialize Scribble Step1 CView - OnDraw Scribble Step1 View High level abstractions UI CToolBar CStatusBar CDialogBar View ScrollView 334

30 第 5 章總觀 Application Framework CFormView CEditView CTreeView RTF CRichEditView Afx C++ SmallTalk Java MFC Afx Afx AfxWinInit WinMain MFC MFC GUI AfxWinInit - AFX MFC console Visual C++ Tear AfxBeginThread AfxEndThread AfxFormatString1 AfxFormatString2 AfxMessageBox AfxOutputDebugString AfxGetApp AfxGetMainWnd AfxGetInstance AfxRegisterClass 14 # # 756 printf printf Windows API MessageBox D # 924 application object CWinApp instance handle WNDCLASS MFC MFC macros CObject CRuntimeClass object services RTTI Serialization... CObject 335

31 第㆔篇淺出 MFC 程式設計 -- MFC RTTI Serialization "persistent" Dynamic object creation document view frame framework OLE OLE server OLE items OLE client MFC DECLARE_DYNAMIC IMPLEMENT_DYNAMIC DECLARE_DYNCREATE IMPLEMENT_DYNCREATE DECLARE_SERIAL IMPLEMENT_SERIAL DECLARE_OLECREATE OLE IMPLEMENT_OLECREATE OLE 336

32 第 5 章總觀 Application Framework MFC Message Mapping Command Routing MFC DECLARE_MESSAGE_MAP BEGIN_MESSAGE_MAP ON_COMMAND ON_CONTROL ON_MESSAGE??? ON_OLECMD ON_REGISTERED_MESSAGE ON_REGISTERED_THREAD_ MESSAGE ON_THREAD_MESSAGE ON_UPDATE_COMMAND_UI END_MESSAGE_MAP MFC Programming MFC MFC 337

33 第㆔篇淺出 MFC 程式設計 MFC data types MFC Win32 SDK Win32 SDK BOOL BSTR BYTE Boolean TRUE FALSE 32-bit 8-bit COLORREF 32-bit DWORD LONG LPARAM LPCSTR LPSTR LPCTSTR 32-bit 32-bit 32-bit callback 32-bit 32-bit 32-bit Unicode DBCS LPTSTR 32-bit Unicode DBCS LPVOID LPRESULT 32-bit 32-bit callback UINT Win16 16-bit Win32 32-bit WNDPROC WORD 32-bit 16-bit WPARAM callback Win16 16 bits Win32 32 bits 338

34 第 5 章總觀 Application Framework MFC POSITION collection MFC collection classes LPCRECT 32-bit RECT MFC C++ WINDEF.H (_MSC_VER >= 800) #define NULL 0 #define far // Win32 far near memory model #define near // flat model pascall #define pascal stdcall // stdcall #define cdecl _cdecl #define CDECL _cdecl #define CALLBACK stdcall // Windows programming #define WINAPI stdcall // PASCAL CALLBACK WINAPI #define WINAPIV cdecl // APIENTRY stdcall #define APIENTRY WINAPI // #define APIPRIVATE stdcall #define PASCAL stdcall #define FAR #define NEAR #define CONST far near const typedef unsigned long typedef int typedef unsigned char typedef unsigned short typedef float typedef FLOAT typedef BOOL near typedef BOOL far typedef BYTE near typedef BYTE far DWORD; BOOL; BYTE; WORD; FLOAT; *PFLOAT; *PBOOL; *LPBOOL; *PBYTE; *LPBYTE; 339

35 第㆔篇淺出 MFC 程式設計 typedef int near typedef int far typedef WORD near typedef WORD far typedef long far typedef DWORD near typedef DWORD far typedef void far typedef CONST void far typedef int typedef unsigned int typedef unsigned int *PINT; *LPINT; *PWORD; *LPWORD; *LPLONG; *PDWORD; *LPDWORD; *LPVOID; *LPCVOID; INT; UINT; *PUINT; /* Types use for passing & returning polymorphic values */ typedef UINT WPARAM; typedef LONG LPARAM; typedef LONG LRESULT; typedef DWORD typedef DWORD COLORREF; *LPCOLORREF; typedef struct tagrect LONG left; LONG top; LONG right; LONG bottom; RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT; typedef const RECT FAR* LPCRECT; typedef struct tagpoint LONG x; LONG y; POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT; typedef struct tagsize LONG cx; LONG cy; SIZE, *PSIZE, *LPSIZE; 340

36 第 5 章總觀 Application Framework 341

37 342 第㆔篇淺出 MFC 程式設計

38 第 6 章 MFC 程式的生死因果 MFC C/SDK Windows MFC Application Framework MFC MFC Windows WinMain RegisterClass CreateWindow Message Loop Window Procedure MFC MFC MFC Windows API Application Framework 343

39 第㆔篇淺出 MFC 程式設計 SDK/MFC WinMain Windows Procedure message handler ClassWizard click click click!!! Wizard VC/MFC Wizard raw Windows API << Windows Application >> various Windows APIs... Window Procedure GetMessage/DispatchMessage CreateWindow RegisterClass WinMain 344

40 第 6 章 MFC 程式的生死因果 MFC << MFC Application >> CObject MFC CCmdTarget CWinThread CWinApp CMyWinApp CWnd CView CMyView CFrameWnd CMyFrameWnd MFC CDocument CMyDoc Visual C++ << MFC Application >> Dynamic Creation, Serialization. Message Mapping, Message Routing. Windows APIs MFC Window Procedure GetMessage/DispatchMessage CWinApp::Run CreateWindow CWinApp::InitInstance MFC Visual C++ 345

41 第㆔篇淺出 MFC 程式設計 MFC MFC MFC 1.0 SDK API 2.0 Application Framework Document-View OLE DAO... Document-View C++/MFC AppWizard ClassWizard Wizards Wizards Wizards Document-View MFC SDK API RegisterClass CreateWindow GetMessage DispatchMessage MFC MFC MFC 4.2 "Hello MFC" MFC

42 第 6 章 MFC 程式的生死因果 CObject CObject CCmdTarget CCmdTarget CWinThread CWinThread CWnd CWnd CWinApp CWinApp CMyWinApp CMyWinApp CFrameWnd CMyFrameWnd CMyFrameWnd 6-1 MFC MFC SDK MFC VC LIBC.LIB C Runtime MSVCRT.LIB C Runtime MSVCRTD.LIB 'D' Debug Large/Medium/Small 32 #38 347

43 第㆔篇淺出 MFC 程式設計 DLL Import VC GDI32.LIB for GDI32.DLL( bytes in Win95) USER32.LIB for USER32.DLL(45568 bytes in Win95) KERNEL32.LIB for KERNEL32 DLL( bytes in Win95)... MFC AFX MFC application framework AppWizard MFC import MFC AFX ) VC MFC 4.2 MFC42.LIB MFC42.DLL( bytes) 的 import MFC42D.LIB MFC42D.DLL( bytes) 的 import MFCS42.LIB MFCS42D.LIB MFCN42D.LIB MFCD42D.LIB MFCO42D.LIB link.exe HELLO.MAK Visual C++ makefile makefile 348

44 第 6 章 MFC 程式的生死因果 SDK WINDOWS.H API WINDOWS.H CommDlg ToolHelp DDEML....H WINDOWS.H 5000.H WINDOWS.H "Master included file for Windows applications" MFC.H STDAFX.H - Precompiled header file MFC STDAFX.H Hello STDAFX.H AFXWIN.H AFXWIN.H - Windows MFC MFC AFX.H AFXVER_.H AFXV_W32.H WINDOWS.H AFXEXT.H - AFXDLGS.H - Common Dialog MFC COMMDLG.H AFXCMN.H - Windows 95 Common Control MFC AFXCOLL.H - Collections Classes AFXDLLX.H - MFC extension DLLs AFXRES.H - MFC RC MFC File Edit ID 349

45 第㆔篇淺出 MFC 程式設計 // File commands #define ID_FILE_NEW #define ID_FILE_OPEN #define ID_FILE_CLOSE #define ID_FILE_SAVE #define ID_FILE_SAVE_AS... // Edit commands #define ID_EDIT_COPY #define ID_EDIT_CUT... 0xE100 0xE101 0xE102 0xE103 0xE104 0xE122 0xE123 AppWizard Scribble step0 RC STRINGTABLE DISCARDABLE BEGIN ID_FILE_NEW "Create a new document" ID_FILE_OPEN "Open an existing document" ID_FILE_CLOSE "Close the active document" ID_FILE_SAVE "Save the active document" ID_FILE_SAVE_AS "Save the active document with a new name"... ID_EDIT_COPY "Copy the selection and puts it on the Clipboard" ID_EDIT_CUT "Cut the selection and puts it on the Clipboard"... END MFC \MSVC\MFC\INCLUDE Windows SDK WINDOWS.H COMMDLG.H TOOLHELP.H DDEML.H... Precompiled header 350

46 第 6 章 MFC 程式的生死因果 Precompiled Header Windows.H Precompiled header.h Borland C/C++ Microsoft Visual C MFC Document/View MFC Application Framework Hello "Hello, MFC" MFC MFC MFC CWinApp CFrameWnd Hello 6-2 MFC CWinApp::InitInstance Hello Hello 6-3 Hello MFC MFC MFC 6-3 Hello MFC Windows API MFC 351

47 第㆔篇淺出 MFC 程式設計 WinMain RegisterClass CreateWindow Message Loop GetMessage/DispatchMessage Window Procedure Hello HELLO.MAK - makefile RESOURCE.H - ID IDM_ABOUT JJHOUR.ICO - HELLO.RC - STDAFX.H - AFXWIN.H STDAFX.CPP - STDAFX.H Precompiled header HELLO.H - CMyWinApp CMyFrameWnd HELLO.CPP - CMyWinApp CMyFrameWnd.DEF WM_PAINT Hello MFC Application object CWinApp MainFrame object CFrameWnd Hello

48 第 6 章 MFC 程式的生死因果 STDAFX.H #include <afxwin.h> STDAFX.CPP #include <stdafx.h> HELLO.H CMyWinApp class declaration CMyFrameWnd class declaration RESOURCE.H #define IDM_xxx HELLO.CPP #include <stdafx.h> #include "resource.h" #include "hello.h" CMyWinApp theapp; CMyWinApp class definition CMyFrameWnd class definition HELLO.RC #include "resource.h" #include <afxres.h> Icon description Menu description Dialog Template Message Map 6-3 Hello.CPP HELLO.MAK DOS nmake hello.mak p.224 #0001 # filename : hello.mak #0002 # make file for hello.exe (MFC 4.0 Application) #0003 # usage : nmake hello.mak (Visual C++ 5.0) #0004 #0005 Hello.exe : StdAfx.obj Hello.obj Hello.res #0006 link.exe /nologo /subsystem:windows /incremental:no \ #0007 /machine:i386 /out:"hello.exe" \ #0008 Hello.obj StdAfx.obj Hello.res \ #0009 msvcrt.lib kernel32.lib user32.lib gdi32.lib mfc42.lib #0010 #0011 StdAfx.obj : StdAfx.cpp StdAfx.h #0012 cl.exe /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" \ #0013 /D "_AFXDLL" /D "_MBCS" /Fp"Hello.pch" /Yc"stdafx.h" \ #0014 /c StdAfx.cpp #0015 #0016 Hello.obj : Hello.cpp Hello.h StdAfx.h #0017 cl.exe /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" \ #0018 /D "_AFXDLL" /D "_MBCS" /Fp"Hello.pch" /Yu"stdafx.h" \ #0019 /c Hello.cpp #0020 #0021 Hello.res : Hello.rc Hello.ico jjhour.ico #0022 rc.exe /l 0x404 /Fo"Hello.res" /D "NDEBUG" /D "_AFXDLL" Hello.rc 353

49 第㆔篇淺出 MFC 程式設計 RESOURCE.H #0001 // resource.h #0002 #define IDM_ABOUT 100 HELLO.RC #0001 // hello.rc #0002 #include "resource.h" #0003 #include "afxres.h" #0004 #0005 JJHouRIcon ICON DISCARDABLE "JJHOUR.ICO" #0006 AFX_IDI_STD_FRAME ICON DISCARDABLE "JJHOUR.ICO" #0007 #0008 MainMenu MENU DISCARDABLE #0009 #0010 POPUP "&Help" #0011 #0012 MENUITEM "&About HelloMFC...", IDM_ABOUT #0013 #0014 #0015 #0016 AboutBox DIALOG DISCARDABLE 34, 22, 147, 55 #0017 STYLE DS_MODALFRAME WS_POPUP WS_CAPTION WS_SYSMENU #0018 CAPTION "About Hello" #0019 #0020 ICON "JJHouRIcon",IDC_STATIC,11,17,18,20 #0021 LTEXT "Hello MFC 4.0",IDC_STATIC,40,10,52,8 #0022 LTEXT "Copyright 1996 Top Studio",IDC_STATIC,40,25,100,8 #0023 LTEXT "J.J.Hou",IDC_STATIC,40,40,100,8 #0024 DEFPUSHBUTTON "OK",IDOK,105,7,32,14,WS_GROUP #0025 STDAFX.H #0001 // stdafx.h : include file for standard system include files, #0002 // or project specific include files that are used frequently, #0003 // but are changed infrequently #0004 #0005 #include <afxwin.h> // MFC core and standard components 354

50 第 6 章 MFC 程式的生死因果 STDAFX.CPP #0001 // stdafx.cpp : source file that includes just the standard includes #0002 // Hello.pch will be the pre-compiled header #0003 // stdafx.obj will contain the pre-compiled type information #0004 #0005 #include "stdafx.h" HELLO.H #0001 // #0002 // MFC 4.0 Hello Sample Program #0003 // Copyright (c) 1996 Top Studio * J.J.Hou #0004 // #0005 // #0006 // #0007 // #0008 // #0009 // : hello.h : : hello.mak Hello : CMyFrameWnd CMyWinApp #0010 // #0011 #0012 class CMyWinApp : public CWinApp #0013 #0014 public: #0015 BOOL InitInstance(); // #0016 ; #0017 #0018 // #0019 class CMyFrameWnd : public CFrameWnd #0020 #0021 public: #0022 CMyFrameWnd(); // constructor #0023 afx_msg void OnPaint(); // for WM_PAINT #0024 afx_msg void OnAbout(); // for WM_COMMAND (IDM_ABOUT) #0025 #0026 private: #0027 DECLARE_MESSAGE_MAP() // Declare Message Map #0028 static VOID CALLBACK LineDDACallback(int,int,LPARAM); #0029 // : callback "static" 'this' #0030 ; 355

51 第㆔篇淺出 MFC 程式設計 HELLO.CPP #0001 // #0002 // MFC 4.0 Hello sample program #0003 // Copyright (c) 1996 Top Studio * J.J.Hou #0004 // #0005 // #0006 // #0007 // #0008 // #0009 // #0010 // : hello.cpp : : hello.mak MFC Document/View WM_PAINT GDI LineDDA() "Hello, MFC" #0011 // #0012 #include "Stdafx.h" #0013 #include "Hello.h" #0014 #include "Resource.h" #0015 #0016 CMyWinApp theapp; // application object #0017 #0018 // #0019 // CMyWinApp's member #0020 // #0021 BOOL CMyWinApp::InitInstance() #0022 #0023 m_pmainwnd = new CMyFrameWnd(); #0024 m_pmainwnd->showwindow(m_ncmdshow); #0025 m_pmainwnd->updatewindow(); #0026 return TRUE; #0027 #0028 // #0029 // CMyFrameWnd's member #0030 // #0031 CMyFrameWnd::CMyFrameWnd() #0032 #0033 Create(NULL, "Hello MFC", WS_OVERLAPPEDWINDOW, rectdefault, #0034 NULL, "MainMenu"); // "MainMenu" #0035 #0036 // #0037 BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) #0038 ON_COMMAND(IDM_ABOUT, OnAbout) #0039 ON_WM_PAINT() #0040 END_MESSAGE_MAP() #0041 // #0042 void CMyFrameWnd::OnPaint() #0043 #0044 CPaintDC dc(this); 356

52 第 6 章 MFC 程式的生死因果 #0045 CRect rect; #0046 #0047 GetClientRect(rect); #0048 #0049 dc.settextalign(ta_bottom TA_CENTER); #0050 #0051 ::LineDDA(rect.right/2, 0, rect.right/2, rect.bottom/2, #0052 (LINEDDAPROC) LineDDACallback, (LPARAM) (LPVOID) &dc); #0053 #0054 // #0055 VOID CALLBACK CMyFrameWnd::LineDDACallback(int x, int y, LPARAM lpdc) #0056 #0057 static char sztext[] = "Hello, MFC"; #0058 #0059 ((CDC*)lpdc)->TextOut(x, y, sztext, sizeof(sztext)-1); #0060 for(int i=1; i<50000; i++); // #0061 #0062 // #0063 void CMyFrameWnd::OnAbout() #0064 #0065 CDialog about("aboutbox", this); // #0066 about.domodal(); #0067 "AboutBox" RC MFC CWinApp CFrameWnd MFC BOOL VOID MFC DECLARE_MESSAGE_MAP BEGIN_MESSAGE_END END_MESSAGE_MAP MFC C++ HELLO.H afx_msg #23 CALLBACK #28 WINDEF.H CALLBACK #define CALLBACK stdcall // AFXWIN.H afx_msg #define afx_msg // intentional placeholder // MFC causal relations C/SDK MFC 357

53 第㆔篇淺出 MFC 程式設計 MFC MFC Windows WinMain Hello theapp application object WinMain application object CWinApp CFrameWnd 6-2 MFC Hello Generic WinMain WndProc MFC WinMain CWinApp WndProc CFrameWnd CWinApp CFrameWnd Frame Window WinMain WndProc class CMyWinApp : public CWinApp... ; class CMyFrameWnd : public CFrameWnd... ; "My" 358

54 第 6 章 MFC 程式的生死因果 CWinApp- 取代 WinMain 的地位 CWinApp application CWinApp object SDK WinMain InitApplication InitInstance CWinApp AFXWIN.H class CWinApp : public CWinThread // Attributes // Startup args (do not change) HINSTANCE m_hinstance; HINSTANCE m_hprevinstance; LPTSTR m_lpcmdline; int m_ncmdshow; // Running args (can be changed in InitInstance) LPCTSTR m_pszappname; // human readable name LPCTSTR m_pszregistrykey; // used for registry entries public: // set in constructor to override default LPCTSTR m_pszexename; // executable name (no spaces) LPCTSTR m_pszhelpfilepath; // default based on module path LPCTSTR m_pszprofilename; // default based on app name public: // hooks for your initialization code virtual BOOL InitApplication(); // overrides for implementation virtual BOOL InitInstance(); virtual int ExitInstance(); virtual int Run(); virtual BOOL OnIdle(LONG lcount);... ; 359

55 第㆔篇淺出 MFC 程式設計 CWinApp WinMain SDK MFC WinMain SDK WinMain CWinApp virtual BOOL InitApplication(); virtual BOOL InitInstance(); virtual int Run(); WinMain CWinApp handle C++ MFC 2.5 m_pmainwnd MFC AFXWIN.H 2.5 class CWinApp : public CCmdTarget // Attributes // Startup args (do not change) HINSTANCE m_hinstance; HINSTANCE m_hprevinstance; LPSTR m_lpcmdline; int m_ncmdshow; // Running args (can be changed in InitInstance) CWnd* m_pmainwnd; // main window (optional) CWnd* m_pactivewnd; // active main window (may not be m_pmainwnd) const char* m_pszappname; // human readable name public: // set in constructor to override default const char* m_pszexename; // executable name (no spaces) const char* m_pszhelpfilepath; // default based on module path const char* m_pszprofilename; // default based on app name public: // hooks for your initialization code virtual BOOL InitApplication(); virtual BOOL InitInstance(); // running and idle processing virtual int Run(); virtual BOOL OnIdle(LONG lcount); 360

56 第 6 章 MFC 程式的生死因果 // exiting virtual int ExitInstance();... ; MFC m_pmainwnd 4.x CWinThread CWinApp MFC AFXWIN.H 4.x class CWinThread : public CCmdTarget // Attributes CWnd* m_pmainwnd; // main window (usually same AfxGetApp()->m_pMainWnd) CWnd* m_pactivewnd; // active main window (may not be m_pmainwnd) // only valid while running HANDLE m_hthread; // this thread's HANDLE DWORD m_nthreadid; // this thread's ID int GetThreadPriority(); BOOL SetThreadPriority(int npriority); // Operations DWORD SuspendThread(); DWORD ResumeThread(); // Overridables // thread initialization virtual BOOL InitInstance(); // running and idle processing virtual int Run(); virtual BOOL PreTranslateMessage(MSG* pmsg); virtual BOOL PumpMessage(); // low level message pump virtual BOOL OnIdle(LONG lcount); // return TRUE if more idle processing public: // valid after construction AFX_THREADPROC m_pfnthreadproc;... ; Win32 CWinThread SuspendThread ResumeThread 361

57 第㆔篇淺出 MFC 程式設計 CFrameWnd- 取代 WndProc 的地位 CFrameWnd SDK long FAR PASCAL WndProc(HWND hwnd, UNIT msg, WORD wparam, LONG lparam) switch(msg) case WM_COMMAND : switch(wparam) case IDM_ABOUT : OnAbout(hWnd, wparam, lparam); break; break; case WM_PAINT : OnPaint(hWnd, wparam, lparam); break; default : DefWindowProc(hWnd, msg, wparam, lparam); MFC Hello CMyFrameWnd class CMyFrameWnd : public CFrameWnd public: CMyFrameWnd(); afx_msg void OnPaint(); afx_msg void OnAbout(); DECLARE_MESSAGE_MAP() ; OnPaint OnAbout WM_PAINT WM _COMMAND IDM_ABOUT HELLO.CPP DECLARE MAP 362

58 第 6 章 MFC 程式的生死因果 MFC Message Map DECLARE_MESSAGE_MAP BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_WM_PAINT() ON_COMMAND(IDM_ABOUT, OnAbout) END_MESSAGE_MAP() 363

59 第㆔篇淺出 MFC 程式設計 引爆器 -Application object HELLO.H HELLO.CPP application object Hello MFC MFC HELLO.CPP 1 CMyWinApp theapp; // application object WINMAIN.CPP int int AFXAPI AFXAPI AfxWinMain AfxWinMain (...) (...) CWinApp* CWinApp* papp papp = AfxGetApp(); AfxGetApp(); AfxWinInit(...); BOOL CMyWinApp::InitInstance() m_pmainwnd = new CMyFrameWnd(); m_pmainwnd->showwindow(m_ncmdshow); m_pmainwnd->updatewindow(); return TRUE; papp->initapplication(); papp->initinstance(); nreturncode nreturncode = papp->run(); papp->run(); AfxWinTerm(); AfxWinTerm(); CMyFrameWnd::CMyFrameWnd() Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() theapp Hello application MFC object Hello CMyWinApp CWinApp APPCORE.CPP 364

60 第 6 章 MFC 程式的生死因果 CWinApp::CWinApp(LPCTSTR lpszappname) m_pszappname = lpszappname; // initialize CWinThread state AFX_MODULE_THREAD_STATE* pthreadstate = AfxGetModuleThreadState(); pthreadstate->m_pcurrentwinthread = this; m_hthread = ::GetCurrentThread(); m_nthreadid = ::GetCurrentThreadId(); // initialize CWinApp state AFX_MODULE_STATE* pmodulestate = AfxGetModuleState(); pmodulestate->m_pcurrentwinapp = this; // in non-running state until WinMain m_hinstance = NULL; m_pszhelpfilepath = NULL; m_pszprofilename = NULL; m_pszregistrykey = NULL; m_pszexename = NULL; m_lpcmdline = NULL; m_pcmdinfo = NULL;... CWinApp theapp theapp : 365

61 第㆔篇淺出 MFC 程式設計 1 HELLO.CPP CMyWinApp theapp; // application object WINMAIN.CPP int int AFXAPI AFXAPI AfxWinMain AfxWinMain (...) (...) CWinApp* CWinApp* papp papp = AfxGetApp(); AfxGetApp(); AfxWinInit(...); AfxWinInit(...); BOOL CMyWinApp::InitInstance() m_pmainwnd = new CMyFrameWnd(); m_pmainwnd->showwindow(m_ncmdshow); m_pmainwnd->updatewindow(); return TRUE; papp->initapplication(); papp->initapplication(); papp->initinstance(); nreturncode nreturncode = papp->run(); papp->run(); AfxWinTerm(); AfxWinTerm(); CMyFrameWnd::CMyFrameWnd() Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() theapp WinMain WinMain MFC 6-4 _twinmain -t Unicode // in APPMODUL.CPP extern "C" int WINAPI _twinmain(hinstance hinstance, HINSTANCE hprevinstance, LPTSTR lpcmdline, int ncmdshow) // call shared/exported WinMain return AfxWinMain(hInstance, hprevinstance, lpcmdline, ncmdshow); DLLMODUL.CPP DllMain DLL 366

62 第 6 章 MFC 程式的生死因果 // in WINMAIN.CPP #0001 ///////////////////////////////////////////////////////////////// #0002 // Standard WinMain implementation #0003 // Can be replaced as long as 'AfxWinInit' is called first #0004 #0005 int AFXAPI AfxWinMain (HINSTANCE hinstance, HINSTANCE hprevinstance, #0006 LPTSTR lpcmdline, int ncmdshow) #0007 #0008 ASSERT(hPrevInstance == NULL); #0009 #0010 int nreturncode = -1; #0011 CWinApp* papp = AfxGetApp(); #0012 #0013 // AFX internal initialization #0014 if (!AfxWinInit(hInstance, hprevinstance, lpcmdline, ncmdshow)) #0015 goto InitFailure; #0016 #0017 // App global initializations (rare) #0018 ASSERT_VALID(pApp); #0019 if (!papp->initapplication()) #0020 goto InitFailure; #0021 ASSERT_VALID(pApp); #0022 #0023 // Perform specific initializations #0024 if (!papp->initinstance()) #0025 #0026 if (papp->m_pmainwnd!= NULL) #0027 #0028 TRACE0("Warning: Destroying non-null m_pmainwnd\n"); #0029 papp->m_pmainwnd->destroywindow(); #0030 #0031 nreturncode = papp->exitinstance(); #0032 goto InitFailure; #0033 #0034 ASSERT_VALID(pApp); #0035 #0036 nreturncode = papp->run(); #0037 ASSERT_VALID(pApp); #0038 #0039 InitFailure: #0040 #0041 AfxWinTerm(); #0042 return nreturncode; # Windows MFC WINMAIN.CPP 367

63 第㆔篇淺出 MFC 程式設計 int AFXAPI AfxWinMain (HINSTANCE hinstance, HINSTANCE hprevinstance, LPTSTR lpcmdline, int ncmdshow) int nreturncode = -1; CWinApp* papp = AfxGetApp(); AfxWinInit(hInstance, hprevinstance, lpcmdline, ncmdshow); papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); return nreturncode; AfxGetApp AFXWIN1.INL _AFXWIN_INLINE CWinApp* AFXAPI AfxGetApp() return afxcurrentwinapp; afxcurrentwinapp AFXWIN.H #define afxcurrentwinapp AfxGetModuleState()->m_pCurrentWinApp CWinApp::CWinApp AfxGetApp CMyWinApp AfxWinMain CWinApp* papp = AfxGetApp(); papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); CMyWinApp::InitApplication(); CMyWinApp::InitInstance(); CMyWinApp::Run(); CWinApp::InitApplication(); // CMyWinApp InitApplication CMyWinApp::InitInstance(); // CMyWinApp InitInstance CWinApp::Run(); // CMyWinApp Run 368

64 第 6 章 MFC 程式的生死因果 SDK InitApplication InitInstance Run MFC MFC MFC application framework MFC MFC AfxWinMain 369

65 第㆔篇淺出 MFC 程式設計 AfxWinInit AFX HELLO.CPP 1 CMyWinApp theapp; // application object WINMAIN.CPP int AFXAPI AfxWinMain (...) CWinApp* papp = AfxGetApp(); 2 AfxWinInit(...); BOOL CMyWinApp::InitInstance() m_pmainwnd = new CMyFrameWnd(); m_pmainwnd->showwindow(m_ncmdshow); m_pmainwnd->updatewindow(); return TRUE; papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); CMyFrameWnd::CMyFrameWnd() Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() AfxWinInit CWinApp APPINIT.CPP BOOL AFXAPI AfxWinInit(HINSTANCE hinstance, HINSTANCE hprevinstance, LPTSTR lpcmdline, int ncmdshow) ASSERT(hPrevInstance == NULL); // set resource handles AFX_MODULE_STATE* pstate = AfxGetModuleState(); pstate->m_hcurrentinstancehandle = hinstance; pstate->m_hcurrentresourcehandle = hinstance; // fill in the initial state for the application CWinApp* papp = AfxGetApp(); if (papp!= NULL) // Windows specific initialization (not done if no CWinApp) 370

66 第 6 章 MFC 程式的生死因果 papp->m_hinstance = hinstance; papp->m_hprevinstance = hprevinstance; papp->m_lpcmdline = lpcmdline; papp->m_ncmdshow = ncmdshow; papp->setcurrenthandles(); // initialize thread specific data (for main thread) if (!afxcontextisdll) AfxInitThread(); return TRUE; AfxInitThread THRDCORE.CPP void AFXAPI AfxInitThread() if (!afxcontextisdll) // attempt to make the message queue bigger for (int cmsg = 96;!SetMessageQueue(cMsg) && (cmsg -= 8); ) ; // set message filter proc _AFX_THREAD_STATE* pthreadstate = AfxGetThreadState(); ASSERT(pThreadState->m_hHookOldMsgFilter == NULL); pthreadstate->m_hhookoldmsgfilter = ::SetWindowsHookEx(WH_MSGFILTER, _AfxMsgFilterHook, NULL, ::GetCurrentThreadId()); // intialize CTL3D for this thread _AFX_CTL3D_STATE* pctl3dstate = _afxctl3dstate; if (pctl3dstate->m_pfnautosubclass!= NULL) (*pctl3dstate->m_pfnautosubclass)(afxgetinstancehandle()); // allocate thread local _AFX_CTL3D_THREAD just for automatic termination _AFX_CTL3D_THREAD* ptemp = _afxctl3dthread; Visual C++ WinMain AfxWinInit MFC AfxWinInit 371

67 第㆔篇淺出 MFC 程式設計 CWinApp::InitApplication 1 HELLO.CPP CMyWinApp theapp; // application object WINMAIN.CPP int AFXAPI AfxWinMain (...) CWinApp* papp = AfxGetApp(); 2 AfxWinInit(...); BOOL CMyWinApp::InitInstance() m_pmainwnd = new CMyFrameWnd(); m_pmainwnd->showwindow(m_ncmdshow); m_pmainwnd->updatewindow(); return TRUE; 3 papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); CMyFrameWnd::CMyFrameWnd() Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() AfxWinInit papp->initapplication papp CMyWinApp theapp papp->initapplication(); CMyWinApp::InitApplication(); CMyWinApp CWinApp InitApplication CWinApp CWinApp::InitApplication(); APPCORE.CPP 372

68 第 6 章 MFC 程式的生死因果 BOOL CWinApp::InitApplication() if (CDocManager::pStaticDocManager!= NULL) if (m_pdocmanager == NULL) m_pdocmanager = CDocManager::pStaticDocManager; CDocManager::pStaticDocManager = NULL; if (m_pdocmanager!= NULL) m_pdocmanager->adddoctemplate(null); else CDocManager::bStaticInit = FALSE; return TRUE; MFC Document Template CDocManager 373

69 第㆔篇淺出 MFC 程式設計 CMyWinApp::InitInstance 1 HELLO.CPP CMyWinApp theapp; // application object WINMAIN.CPP int AFXAPI AfxWinMain (...) CWinApp* papp = AfxGetApp(); 2 AfxWinInit(...); BOOL CMyWinApp::InitInstance() m_pmainwnd = new CMyFrameWnd(); m_pmainwnd->showwindow(m_ncmdshow); m_pmainwnd->updatewindow(); return TRUE; 3 4 papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); CMyFrameWnd::CMyFrameWnd() Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() InitApplication AfxWinMain papp->initinstance CMyWinApp theapp papp->initinstance(); CMyWinApp::InitInstance(); CMyWinApp CWinApp InitInstance CWinApp CMyWinApp InitInstance 374

70 第 6 章 MFC 程式的生死因果 APPCORE.CPP base class CWinApp virtual BOOL InitApplication(); virtual BOOL InitInstance(); virtual int Run(); virtual int ExitInstance(); HELLO.CPP overridden virtual BOOL InitInstance(); CMyWinApp derived class ㆒般而言,CMyWinApp 只改寫 CWinApp 的 InitInstance, 通常它不改寫 InitApplication 和 Run InitInstance CWinApp 375

71 第㆔篇淺出 MFC 程式設計 CFrameWnd::Create HELLO.CPP 1 CMyWinApp theapp; // application object WINMAIN.CPP int AFXAPI AfxWinMain (...) CWinApp* papp = AfxGetApp(); 2 AfxWinInit(...); BOOL CMyWinApp::InitInstance() 5 m_pmainwnd = new CMyFrameWnd(); m_pmainwnd->showwindow(m_ncmdshow); m_pmainwnd->updatewindow(); return TRUE; 3 4 papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); CMyFrameWnd::CMyFrameWnd() 6 Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() CMyWinApp::InitInstance new CMyFrameWnd C++ new CMyFrameWnd::CMyFrameWnd Create(NULL, "Hello MFC", WS_OVERLAPPEDWINDOW, rectdefault, NULL, "MainMenu"); Create CFrameWnd RegisterClass C++ CFrameWnd::Create 376

72 第 6 章 MFC 程式的生死因果 BOOL Create( LPCTSTR lpszclassname, LPCTSTR lpszwindowname, DWORD dwstyle = WS_OVERLAPPEDWINDOW, const RECT& rect = rectdefault, CWnd* pparentwnd = NULL, LPCTSTR lpszmenuname = NULL, DWORD dwexstyle = 0, CCreateContext* pcontext = NULL ); lpszclassname WNDCLASS NULL MFC Create lpszwindowname "Hello MFC" dwstyle WS_OVERLAPPEDWINDOW WINDOWS.H #define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED WS_CAPTION WS_SYSMENU WS_THICKFRAME WS_MINIMIZEBOX WS_MAXIMIZEBOX) Create(NULL, "Hello MFC", WS_OVERLAPPED WS_CAPTION WS_SYSMENU WS_THICKFRAME rectdefault, NULL, "MainMenu"); dwexstyle ::CreateWindowEx ::CreateWindow CFrameWnd ::Create ::CreateWindowEx Windows

73 第㆔篇淺出 MFC 程式設計 WS_EX_DLGMODALFRAME WS_EX_NOPARENTNOTIFY WS_EX_TOPMOST WS_EX_ACCEPTFILES WS_EX_TRANSPARENT Windows 95 WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE 3D Framework Create rect rectdefault static Windows SDK CW_USEDEFAULT CreateWindow Create(NULL, "Hello MFC", WS_OVERLAPPEDWINDOW, CRect(40, 60, 240, 460), // 起始位置 (40,60), 寬 200, 高 400) NULL, "MainMenu"); pparentwnd top-level NULL desktop lpszmenuname RC MainMenu pcontext CCreateContext framework Document/View CDocTemplate CDocument / CView / CFrameWnd Document/View pcontext NULL CFrameWnd::Create MFC MFC 378

74 第 6 章 MFC 程式的生死因果 WINFRM.CPP BOOL CFrameWnd::Create(LPCTSTR lpszclassname, LPCTSTR lpszwindowname, DWORD dwstyle, const RECT& rect, CWnd* pparentwnd, LPCTSTR lpszmenuname, DWORD dwexstyle, CCreateContext* pcontext) HMENU hmenu = NULL; if (lpszmenuname!= NULL) // load in a menu that will get destroyed when window gets destroyed HINSTANCE hinst = AfxFindResourceHandle(lpszMenuName, RT_MENU); hmenu = ::LoadMenu(hInst, lpszmenuname); m_strtitle = lpszwindowname; // save title for later CreateEx(dwExStyle, lpszclassname, lpszwindowname, dwstyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, pparentwnd->getsafehwnd(), hmenu, (LPVOID)pContext); return TRUE; CreateEx CWnd CreateEx CFrameWnd CFrameWnd::CreateEx CWnd CreateEx :: WINCORE.CPP BOOL CWnd::CreateEx(DWORD dwexstyle, LPCTSTR lpszclassname, LPCTSTR lpszwindowname, DWORD dwstyle, int x, int y, int nwidth, int nheight, HWND hwndparent, HMENU nidorhmenu, LPVOID lpparam) // allow modification of several common create parameters CREATESTRUCT cs; cs.dwexstyle = dwexstyle; cs.lpszclass = lpszclassname; 379

75 第㆔篇淺出 MFC 程式設計 cs.lpszname = lpszwindowname; cs.style = dwstyle; cs.x = x; cs.y = y; cs.cx = nwidth; cs.cy = nheight; cs.hwndparent = hwndparent; cs.hmenu = nidorhmenu; cs.hinstance = AfxGetInstanceHandle(); cs.lpcreateparams = lpparam; PreCreateWindow(cs); AfxHookWindowCreate(this); // HWND hwnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszclass, cs.lpszname, cs.style, cs.x, cs.y, cs.cx, cs.cy, cs.hwndparent, cs.hmenu, cs.hinstance, cs.lpcreateparams);... PreCreateWindow CWnd CFrameWnd this CFrameWnd::PreCreateWindow WINFRM.CPP // CFrameWnd second phase creation BOOL CFrameWnd::PreCreateWindow(CREATESTRUCT& cs) if (cs.lpszclass == NULL) AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG); cs.lpszclass = _afxwndframeorview; // COLOR_WINDOW background... AfxDeferRegisterClass AFXIMPL.H 380

76 第 6 章 MFC 程式的生死因果 AFXIMPL.H #define AfxDeferRegisterClass(fClass) \ ((afxregisteredclasses & fclass)? TRUE : AfxEndDeferRegisterClass(fClass)) afxregisteredclasses fclass MFC AfxEndDeferRegisterClass(fClass) afxregisteredclasses AFXWIN.H // in AFXWIN.H #define afxregisteredclasses AfxGetModuleState()->m_fRegisteredClasses WINCORE.CPP : #0001 BOOL AFXAPI AfxEndDeferRegisterClass(short fclass) #0002 #0003 BOOL bresult = FALSE; #0004 #0005 // common initialization #0006 WNDCLASS wndcls; #0007 memset(&wndcls, 0, sizeof(wndclass)); // start with NULL defaults #0008 wndcls.lpfnwndproc = DefWindowProc; #0009 wndcls.hinstance = AfxGetInstanceHandle(); #0010 wndcls.hcursor = afxdata.hcurarrow; #0011 #0012 AFX_MODULE_STATE* pmodulestate = AfxGetModuleState(); #0013 if (fclass & AFX_WND_REG) #0014 #0015 // Child windows - no brush, no icon, safest default class styles #0016 wndcls.style = CS_DBLCLKS CS_HREDRAW CS_VREDRAW; #0017 wndcls.lpszclassname = _afxwnd; #0018 bresult = AfxRegisterClass(&wndcls); #0019 if (bresult) #0020 pmodulestate->m_fregisteredclasses = AFX_WND_REG; #0021 #0022 else if (fclass & AFX_WNDOLECONTROL_REG) #0023 #0024 // OLE Control windows - use parent DC for speed #0025 wndcls.style = CS_PARENTDC CS_DBLCLKS CS_HREDRAW CS_VREDRAW; #0026 wndcls.lpszclassname = _afxwndolecontrol; #0027 bresult = AfxRegisterClass(&wndcls); #0028 if (bresult) 381

77 第㆔篇淺出 MFC 程式設計 #0029 pmodulestate->m_fregisteredclasses = AFX_WNDOLECONTROL_REG; #0030 #0031 else if (fclass & AFX_WNDCONTROLBAR_REG) #0032 #0033 // Control bar windows #0034 wndcls.style = 0; // control bars don't handle double click #0035 wndcls.lpszclassname = _afxwndcontrolbar; #0036 wndcls.hbrbackground = (HBRUSH)(COLOR_BTNFACE + 1); #0037 bresult = AfxRegisterClass(&wndcls); #0038 if (bresult) #0039 pmodulestate->m_fregisteredclasses = AFX_WNDCONTROLBAR_REG; #0040 #0041 else if (fclass & AFX_WNDMDIFRAME_REG) #0042 #0043 // MDI Frame window (also used for splitter window) #0044 wndcls.style = CS_DBLCLKS; #0045 wndcls.hbrbackground = NULL; #0046 bresult = RegisterWithIcon(&wndcls, _afxwndmdiframe, AFX_IDI_STD_MDIFRAME); #0047 if (bresult) #0048 pmodulestate->m_fregisteredclasses = AFX_WNDMDIFRAME_REG; #0049 #0050 else if (fclass & AFX_WNDFRAMEORVIEW_REG) #0051 #0052 // SDI Frame or MDI Child windows or views - normal colors #0053 wndcls.style = CS_DBLCLKS CS_HREDRAW CS_VREDRAW; #0054 wndcls.hbrbackground = (HBRUSH) (COLOR_WINDOW + 1); #0055 bresult = RegisterWithIcon(&wndcls, _afxwndframeorview, AFX_IDI_STD_FRAME); #0056 if (bresult) #0057 pmodulestate->m_fregisteredclasses = AFX_WNDFRAMEORVIEW_REG; #0058 #0059 else if (fclass & AFX_WNDCOMMCTLS_REG) #0060 #0061 InitCommonControls(); #0062 bresult = TRUE; #0063 pmodulestate->m_fregisteredclasses = AFX_WNDCOMMCTLS_REG; #0064 #0065 #0066 return bresult; #

78 第 6 章 MFC 程式的生死因果 #define AFX_WND_REG (0x0001) #define AFX_WNDCONTROLBAR_REG (0x0002) #define AFX_WNDMDIFRAME_REG (0x0004) #define AFX_WNDFRAMEORVIEW_REG (0x0008) #define AFX_WNDCOMMCTLS_REG (0x0010) #define AFX_WNDOLECONTROL_REG (0x0020) WINC const TCHAR _afxwnd[] = AFX_WND; const TCHAR _afxwndcontrolbar[] = AFX_WNDCONTROLBAR; const TCHAR _afxwndmdiframe[] = AFX_WNDMDIFRAME; const TCHAR _afxwndframeorview[] = AFX_WNDFRAMEORVIEW; const TCHAR _afxwndolecontrol[] = AFX_WNDOLECONTROL; AFX_ AFXIMPL.H #ifndef _UNICODE #define _UNICODE_SUFFIX #else #define _UNICODE_SUFFIX _T("u") #endif #ifndef _DEBUG #define _DEBUG_SUFFIX #else #define _DEBUG_SUFFIX _T("d") #endif #ifdef _AFXDLL #define _STATIC_SUFFIX #else #define _STATIC_SUFFIX _T("s") #endif #define AFX_WNDCLASS(s) \ _T("Afx") _T(s) _T("42") _STATIC_SUFFIX _UNICODE_SUFFIX _DEBUG_SUFFIX #define AFX_WND #define AFX_WNDCONTROLBAR #define AFX_WNDMDIFRAME #define AFX_WNDFRAMEORVIEW #define AFX_WNDOLECONTROL AFX_WNDCLASS("Wnd") AFX_WNDCLASS("ControlBar") AFX_WNDCLASS("MDIFrame") AFX_WNDCLASS("FrameOrView") AFX_WNDCLASS("OleControl") 383

79 第㆔篇淺出 MFC 程式設計 Windows 95 non-unicode MFC "AfxWnd42d" "AfxControlBar42d" "AfxMDIFrame42d" "AfxFrameOrView42d" "AfxOleControl42d" Windows NT Unicode MFC "AfxWnd42sud" "AfxControlBar42sud" "AfxMDIFrame42sud" "AfxFrameOrView42sud" "AfxOleControl42sud" AfxEndDeferRegisterClass RegisterWithIcon AfxRegisterClass static BOOL AFXAPI RegisterWithIcon(WNDCLASS* pwndcls, LPCTSTR lpszclassname, UINT nidicon) pwndcls->lpszclassname = lpszclassname; HINSTANCE hinst = AfxFindResourceHandle( MAKEINTRESOURCE(nIDIcon), RT_GROUP_ICON); if ((pwndcls->hicon = ::LoadIcon(hInst, MAKEINTRESOURCE(nIDIcon))) == NULL) // use default icon pwndcls->hicon = ::LoadIcon(NULL, IDI_APPLICATION); return AfxRegisterClass(pWndCls); BOOL AFXAPI AfxRegisterClass(WNDCLASS* lpwndclass) WNDCLASS wndcls; 384

80 第 6 章 MFC 程式的生死因果 if (GetClassInfo(lpWndClass->hInstance, lpwndclass->lpszclassname, &wndcls)) // class already registered return TRUE; ::RegisterClass(lpWndClass);... return TRUE; PreCreateWindow NULL PreCreateWindow Framework // in WINCORE.CPP BOOL CWnd::PreCreateWindow(CREATESTRUCT& cs) AfxDeferRegisterClass(AFX_WND_REG);... cs.lpszclass = _afxwnd; CWnd _afxwnd return TRUE; // in WINFRM.CPP BOOL CFrameWnd::PreCreateWindow(CREATESTRUCT& cs) if (cs.lpszclass == NULL) AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG);... cs.lpszclass = _afxwndframeorview; CFrameWnd _afxwndframeorview... // in WINMDI.CPP BOOL CMDIFrameWnd::PreCreateWindow(CREATESTRUCT& cs) 385

81 第㆔篇淺出 MFC 程式設計 if (cs.lpszclass == NULL) AfxDeferRegisterClass(AFX_WNDMDIFRAME_REG);... cs.lpszclass = _afxwndmdiframe; return TRUE; CMDIFrameWnd _afxwndmdiframe // in WINMDI.CPP BOOL CMDIChildWnd::PreCreateWindow(CREATESTRUCT& cs)... return CFrameWnd::PreCreateWindow(cs); CMDIChildWnd _afxwndframeorview // in VIEWCORE.CPP BOOL CView::PreCreateWindow(CREATESTRUCT & cs) if (cs.lpszclass == NULL) AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG);... cs.lpszclass = _afxwndframeorview; CView _afxwndframeorview... Create icon Create Create SDK RegisterClass CreateWindow MFC RegisterClass MFC HELLO.RC AFX_IDI_STD_FRAME ICON DISCARDABLE "HELLO.ICO" AfxEndDeferRegisterClass 55 RegisterWithIcon icon AFX_IDI_STD_FRAME 386

82 第 6 章 MFC 程式的生死因果 AfxRegisterWndClass Cursor Create Afx:b:14ae:6:3e8f CFrameWnd::Create CMDIFrameWnd::LoadFrame MFC Create LoadFrame PreCreateWindow Win95 MFC 4.2 "AfxWnd42d" "AfxControlBar42d" "AfxMDIFrame42d" "AfxFrameOrView42d" "AfxOleControl42d" Spy++ VC++ Afx:b:14ae:6:3e8f Application Framework Afx:x:y:z:w 387

83 第㆔篇淺出 MFC 程式設計 x: window hex style y: hex z: hex w: icon hex MFC PreCreateWindow Create LoadFrame API GetClassInfo lpszclassname hicon AfxRegisterClass #0000 #define MY_CLASSNAME "MyClassName" #0001 #0002 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) #0003 #0004 static LPCSTR classname = NULL; #0005 #0006 if (!CFrameWnd::PreCreateWindow(cs)) #0007 return FALSE; #0008 #0009 if (classname==null) #0010 // One-time class registration #0011 // The only purpose is to make the class name something #0012 // meaningful instead of "Afx:0x4d:27:32:hup1hup:hike!" #0013 // #0014 WNDCLASS wndcls; #0015 ::GetClassInfo(AfxGetInstanceHandle(), cs.lpszclass, &wndcls); #0016 wndcls.lpszclassname = MY_CLASSNAME; #0017 wndcls.hicon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); #0018 VERIFY(AfxRegisterClass(&wndcls)); #0019 classname=tracewnd_classname; #0020 #0021 cs.lpszclass = classname; #0022 #0023 return TRUE; #0024 MFC Debug Window DBWIN 388

84 第 6 章 MFC 程式的生死因果 1 HELLO.CPP CMyWinApp theapp; // application object WINMAIN.CPP int AFXAPI AfxWinMain (...) CWinApp* papp = AfxGetApp(); 2 AfxWinInit(...); BOOL CMyWinApp::InitInstance() 5 m_pmainwnd = new CMyFrameWnd(); 7 m_pmainwnd->showwindow(m_ncmdshow); 8 m_pmainwnd->updatewindow(); return TRUE; 3 4 papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); CMyFrameWnd::CMyFrameWnd() 6 Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() CMyFrameWnd::CMyFrameWnd CMyWinApp::InitInstance ShowWindow UpdateWindow Hello WM _PAINT WM _PAINT MFC SDK GetMessage /DispatchMesage 389

85 第㆔篇淺出 MFC 程式設計 HELLO.CPP WINMAIN.CPP int AFXAPI AfxWinMain (...) CWinApp* papp = AfxGetApp(); AfxWinInit(...); papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); CWinApp::Run CWinThread::Run do do ::GetMessage(&msg,...); ::GetMessage(&msg,...); PreTranslateMessage&msg); PreTranslateMessage&msg); ::TranslateMessage(&msg); ::TranslateMessage(&msg); ::DispatchMessage(&msg); ::DispatchMessage(&msg); while while (::PeekMessage(...)); (::PeekMessage(...)); 1 CMyWinApp theapp; // application object BOOL CMyWinApp::InitInstance() 5 m_pmainwnd = new CMyFrameWnd(); 7 m_pmainwnd->showwindow(m_ncmdshow); 8 m_pmainwnd->updatewindow(); return TRUE; CMyFrameWnd::CMyFrameWnd() 6 Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint()... void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP() DefWindowProc DefWindowProc hooking and subclassing (please see chap9, p.560, Minotauros and Theseus ) AfxWndProc AfxWndProc Hello WM_PAINT papp->run papp CMyWinApp theapp papp->run(); CMyWinApp::Run(); 390

86 第 6 章 MFC 程式的生死因果 CMyWinApp CWinApp Run CWinApp CWinApp::Run(); APPCORE.CPP int CWinApp::Run() if (m_pmainwnd == NULL && AfxOleGetUserCtrl()) // Not launched /Embedding or /Automation, but has no main window! TRACE0("Warning: m_pmainwnd is NULL in CWinApp::Run - quitting application.\n"); AfxPostQuitMessage(0); return CWinThread::Run(); 32 MFC 16 MFC CWinApp CCmdTarget CWinThread THRDCORE.CPP int CWinThread::Run() // for tracking the idle time state BOOL bidle = TRUE; LONG lidlecount = 0; // acquire and dispatch messages until a WM_QUIT message is received. for (;;) // phase1: check to see if we can do idle work while (bidle &&!::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE)) // call OnIdle while in bidle state if (!OnIdle(lIdleCount++)) bidle = FALSE; // assume "no idle" state // phase2: pump messages while available do // pump message, but quit on WM_QUIT 391

87 第㆔篇淺出 MFC 程式設計 if (!PumpMessage()) return ExitInstance(); // reset "no idle" state after pumping "normal" message if (IsIdleMessage(&m_msgCur)) bidle = TRUE; lidlecount = 0; while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE)); ASSERT(FALSE); // not reachable BOOL CWinThread::PumpMessage() if (!::GetMessage(&m_msgCur, NULL, NULL, NULL)) return FALSE; // process this message if (m_msgcur.message!= WM_KICKIDLE &&!PreTranslateMessage(&m_msgCur)) ::TranslateMessage(&m_msgCur); ::DispatchMessage(&m_msgCur); return TRUE; SDK DispatchMessage MFC Hello MFC AfxEndDeferRegisterClass wndcls.lpfnwndproc = DefWindowProc; 392

88 第 6 章 MFC 程式的生死因果 DefWindowProc AfxWndProc MFC hook subclassing WinMain MFC MFC MFC MFC Message Map 393

89 第㆔篇淺出 MFC 程式設計 HELLO.CPP 1 CMyWinApp theapp; // application object WINMAIN.CPP int AFXAPI AfxWinMain (...) CWinApp* papp = AfxGetApp(); 2 AfxWinInit(...); BOOL CMyWinApp::InitInstance() 5 m_pmainwnd = new CMyFrameWnd(); 7 m_pmainwnd->showwindow(m_ncmdshow); 8 m_pmainwnd->updatewindow(); return TRUE; papp->initapplication(); papp->initinstance(); nreturncode = papp->run(); AfxWinTerm(); AfxWndProc WM_PAINT 10 message routing WM_PAINT message map CMyFrameWnd::CMyFrameWnd() 6 Create(NULL, "Hello MFC",..., "MainMenu"); void CMyFrameWnd::OnPaint() void CMyFrameWnd::OnAbout()... BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_COMMAND(IDM_ABOUT, OnAbout) ON_WM_PAINT() END_MESSAGE_MAP()... Message Map SDK MFC HELLO.H CMyFrameWnd DECLARE_MESSAGE _MAP 394

90 第 6 章 MFC 程式的生死因果 class CMyFrameWnd : public CFrameWnd public: CMyFrameWnd(); afx_msg void OnPaint(); afx_msg void OnAbout(); DECLARE_MESSAGE_MAP() ; HELLO.CPP BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd) ON_WM_PAINT() ON_COMMAND(IDM_ABOUT, OnAbout) END_MESSAGE_MAP() WM_PAINT OnPaint WM_COMMAND IDM_ABOUT OnAbout ON_WM_PAINT WM_PAINT OnPaint MFC Message Map : Windows WM_xxx ON_WM_CHAR WM_CHAR OnChar ON_WM_CLOSE WM_CLOSE OnClose ON_WM_CREATE WM_CREATE OnCreate ON_WM_DESTROY WM_DESTROY OnDestroy ON_WM_LBUTTONDOWN WM_LBUTTONDOWN OnLButtonDown ON_WM_LBUTTONUP WM_LBUTTONUP OnLButtonUp ON_WM_MOUSEMOVE WM_MOUSEMOVE OnMouseMove ON_WM_PAINT WM_PAINT OnPaint

91 第㆔篇淺出 MFC 程式設計 WM_COMMAND ON_COMMAND(<id>,<memberFxn>) ON_COMMAND(IDM_ABOUT, OnAbout) ON_COMMAND(IDM_FILENEW, OnFileNew) ON_COMMAND(IDM_FILEOPEN, OnFileOpen) ON_COMMAND(IDM_FILESAVE, OnFileSave) Notification BN_xxx Button ON_BN_CLICKED(<id>,<memberFxn>) memberfxn ComboBox ON_CBN_DBLCLK(<id>,<memberFxn>) memberfxn Edit ON_EN_SETFOCUS(<id>,<memberFxn>) memberfxn ListBox ON_LBN_DBLCLK(<id>,<memberFxn>) memberfxn afx_msg void Message Map Message Map MFC Message Map Message Map Message Routing SDK DefWindowProc MFC CCmdTarget Message Map 396

92 第 6 章 MFC 程式的生死因果 Document/View Dynamic Creation Serialization MFC SDK MFC MFC Application object Afx WinMain AfxWinInit AfxInitThread Afx WinMain InitApplication CWinApp AfxWinMain InitInstance CWinApp CMyWinApp ::InitInstance 'new' CMyFrameWnd CMyFrameWnd Create NULL MFC "AfxFrameOrView42d" InitInstance ShowWindow UpdateWindow WM_PAINT AfxWinMain Run WM_PAINT CWinApp::Run ::GetMessage WM_PAINT ::DispatchMessage CWnd::DefWindowProc 397

93 第㆔篇淺出 MFC 程式設計 CWnd::DefWindowProc Message Map BEGIN_MESSAGE_MAP END_MESSAGE_MAP WM_PAINT OnPaint File/Close WM_CLOSE CMyFrameWnd WM_CLOSE WM_CLOSE ::DestroyWindow WM_DESTROY WM_DESTROY ::PostQuitMessage WM_QUIT CWinApp::Run WM_QUIT ExitInstance CWinApp CMyWinApp ExitInstance CWinApp::Run CMyWinApp::ExitInstance CWinApp::ExitInstance AfxWinMain AfxWinTerm Hello OnPaint WM_PAINT "Hello, MFC" LineDDA API MFC Windows API LineDDA 398

94 第 6 章 MFC 程式的生死因果 LineDDA void WINAPI LineDDA(int, int, int, int, LINEDDAPROC, LPARAM); Bresenham ) LineDDA callback typedef void (CALLBACK* LINEDDAPROC)(int, int, LPARAM); callback Windows LineDDA LineDDA 32 Hello Device Context Bresenham (x1, y1) (x2, y2) LineDDACallback(int, int, PLARAM) LineDDA Bresenham 6-6 LineDDA 399

95 第㆔篇淺出 MFC 程式設計 LineDDA MFC C++ "scope operator" :: void CMyFrameWnd::OnPaint() CPaintDC dc(this); CRect rect; GetClientRect(rect); dc.settextalign(ta_bottom TA_CENTER); ::LineDDA(rect.right/2, 0, rect.right/2, rect.bottom/2, (LINEDDAPROC) LineDDACallback, (LPARAM) (LPVOID) &dc); LineDDACallback callback class CMyFrameWnd : public CFrameWnd... private: static VOID CALLBACK LineDDACallback(int,int,LPARAM); ; callback "static" C++ this ) Windows callback --- callback C++ callback Windows callback Windows Windows API callback API 400

96 第 6 章 MFC 程式的生死因果 SetTimer LineDDA EnumObjects API callback 6-6 LineDDA callback EnumObjects Device Context GDI object callback C++ callback C++ callback C++ Windows callback CMyclass class CMyclass private : int ncount; int CALLBACK _export public : EnumObjectsProc(LPSTR lplogobject, LPSTR lpdata); void enumit(cdc& dc); void CMyclass::enumIt(CDC& dc) // callback dc.enumobjects(obj_brush, EnumObjectsProc, NULL); C++ CMyclass::enumIt void CMyclass::enumIt(CDC& dc) // callback CDC::EnumObjects(OBJ_BRUSH, EnumObjectsProc, NULL, (CDC *)&dc); (CDC *)&dc this this 401

97 第㆔篇淺出 MFC 程式設計 --- C++ this ncount = 0; this->ncount = 0; EnumObjectsProc C++ callback Windows Windows this callback this callback C++ this 1. callback 2. static static C callback OO C++ static static ) static static static 402

98 第 6 章 MFC 程式的生死因果 Hello MFC idle time Win32 PeekMessage Microsoft CWinApp CWinThread CWinApp::Run - int CWinThread::Run()... for (;;) while (bidle &&!::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE)) // call OnIdle while in bidle state if (!OnIdle(lIdleCount++)) bidle = FALSE; // assume "no idle" state... // msg loop CThread::OnIdle CWinApp OnIdle CWinApp::OnIdle THRDCORE.CPP APPCORE.CPP O MFC MFC idle time CWinApp OnIdle virtual BOOL OnIdle(LONG lcount); 403

99 第㆔篇淺出 MFC 程式設計 lcount Hello lcount CWinThread::Run 0 Jeff Prosise Programming Windows 95 with OnIdle MFC lcount 0 WM _SYSTIMER WM_PAINT lcount 0 Hello 1. CMyWinApp OnIdle class CMyWinApp : public CWinApp public: virtual BOOL InitInstance(); // virtual BOOL OnIdle(LONG lcount); // OnIdle idle time ; 2. CMyFrameWnd IdleTimeHandler lcount OnIdle CMyFrameWnd DC class CMyFrameWnd : public CFrameWnd public: CMyFrameWnd(); // constructor afx_msg void OnPaint(); // for WM_PAINT afx_msg void OnAbout(); // for WM_COMMAND (IDM_ABOUT) void IdleTimeHandler(LONG lcount); // we want it call by CMyWinApp::OnIdle... ; 3. HELLO.CPP CMyWinApp ::OnIdle 404

100 第 6 章 MFC 程式的生死因果 BOOL CMyWinApp::OnIdle(LONG lcount) CMyFrameWnd* pwnd = (CMyFrameWnd*)m_pMainWnd; pwnd->idletimehandler(lcount); return TRUE; 4. HELLO.CPP CMyFrameWnd::IdleTimeHandler void CMyFrameWnd::IdleTimeHandler(LONG lcount) CString str; CRect rect(10,10,200,30); CDC* pdc = new CClientDC(this); str.format("%010d", lcount); pdc->drawtext(str, &rect, DT_LEFT DT_TOP); lcount MFC CString CRect CDC C++ Windows DC Device Context Hello lcount lcount 0 405

101 第㆔篇淺出 MFC 程式設計 SDK RC Template C MFC CDialog MFC HELLO.CPP WM_COMMAND (IDM_ABOUT) void CMyFrameWnd::OnAbout() CDialog about("aboutbox", this); about.domodal(); HELLO.RC AboutBox DIALOG DISCARDABLE 34, 22, 147, 55 STYLE DS_MODALFRAME WS_POPUP WS_CAPTION WS_SYSMENU CAPTION "About Hello" ICON "JJHouRIcon",IDC_STATIC,11,17,18,20 LTEXT "Hello MFC 4.0",IDC_STATIC,40,10,52,8 LTEXT "Copyright 1996 Top Studio",IDC_STATIC,40,25,100,8 LTEXT "J.J.Hou",IDC_STATIC,40,40,100,8 DEFPUSHBUTTON "OK",IDOK,105,7,32,14,WS_GROUP File/About Message Map WM _COMMAND IDM_ABOUT OnAbout OnAbout CDialog about CDialog about "About" CDialog CDialog::DoModal 406

102 第 6 章 MFC 程式的生死因果 File Open Save As Windows 3.1 Windows API Common Dialogs API COMMDLG.DLL 32 COMDLG32.DLL MFC CCommonDialog CFileDialog CPrintDialog CFindReplaceDialog CColorDialog CFontDialog CPageSetupDialog COleDialog File Open Save As Print Find and Replace Color Font Page Setup MFC 4.0 Ole CObject CObject CCmdTarget CCmdTarget CWnd CWnd CDialog CDialog CCommonDialog CColorDialog CColorDialog CFileDialog CFindReplaceDialog CFontDialog CFontDialog COleDialog COleDialog CPageSetupDialog CPageSetupDialog CPrintDialog CPrintDialog 407

103 第㆔篇淺出 MFC 程式設計 C/SDK OPENFILENAME API GetOpenFileName MFC Windows API Open char szfileters[] = "Text fiels (*.txt) *.txt All files (*.*) *.* " CFileDialog opendlg (TRUE, "txt", "*.txt", OFN_FILEMUSTEXIST OFN_HIDEREADONLY, szfilters, this); if (opendlg.domodal() == IDOK) filename = opendlg.getpathname(); opendlg TRUE Open Save As "txt" "*.txt" file name OFN_ szfilters DoModal CFileDialog GetPathName GetFileName GetFileTitle MFC 408

104 第 6 章 MFC 程式的生死因果 MFC CWinApp application object WinMain application object InitInstance CFrameWnd CFrameWnd::Create MFC WinMain Run WM_COMMAND IDM_ABOUT WM_PAINT OnAbout OnPaint MFC SDK MFC raw Windows API MFC MFC MFC MFC MFC OLE MFC Hello Windows MDI Document/View UI

105 410 第㆔篇淺出 MFC 程式設計

106 第 7 章簡單而完整 :MFC 骨幹程式 Hello MFC MFC MFC CWinApp CFrameWnd CDialog MFC UI Document/View MFC AppWizard MFC Scribble step0 MFC MFC ODBC OLE

107 第㆔篇淺出 MFC 程式設計 CObject CObject CCmdTarget CCmdTarget CWinThread CWinThread CWnd CWnd CWinApp CWinApp CView CView CMyWinApp CMyWinApp CMyView CFrameWnd CFrameWnd CDocument CDocument CMDIFrameWnd CMDIFrameWnd CMyDoc CMyDoc CDocTemplate CDocTemplate CMDIChildWnd CMDIChildWnd CMultiDocTemplate CMultiDocTemplate CMyMDIFrameWnd CMyMDIChildWnd CMyMDIChildWnd CControlBar CControlBar CStatusBar CStatusBar CToolBar CToolBar CDialog CDialog CMyDialog CMyDialog 7-1 MFC Windows MDI MFC UI MFC 412

108 第 7 章簡單而完整 :MFC 骨幹程式 7-2a Microsoft Word for Windows document document Word 413

109 第㆔篇淺出 MFC 程式設計 7-2b Microsoft Excel document 414

110 第 7 章簡單而完整 :MFC 骨幹程式 7-2c Microsoft PowerPoint document MFC Visual C++ AppWizard MFC 415

111 第㆔篇淺出 MFC 程式設計 File Edit View CEditView 416

112 第 7 章簡單而完整 :MFC 骨幹程式 MDI Window Help About dockable 417

113 第㆔篇淺出 MFC 程式設計 File Print... Preview Document View AppWizard View CEditView

114 第 7 章簡單而完整 :MFC 骨幹程式 Document/View MFC Application Framework Document/View OLE Document MDI Document MFC Document "Document" "Object" OLE PaintBrush bitmap SoundRecorder Wave Excel Word OLE OLE object item MFC Document CDocument?! char name[20]; char address[30]; int age; bool sex; struct dbllistnode struct dbllistnode *next, *prev; struct info_t int left; int top; 419

115 第㆔篇淺出 MFC 程式設計 ; int width; int height; void (*cursor)(); *item; CDocument Document CDocument CView 7-3a... CView CMyDoc::Serialize(...) CMyView::OnDraw(...) // // Document // Document // GDI // The C++ compiler gen ings, all of which a are caused by the ol... Hello, I am J.J.Hou, a goodman.... The difference, omit lpcmdline parameter a Document View 420

116 第 7 章簡單而完整 :MFC 骨幹程式 View View Document ( 7-3b) CMyDoc::Serialize(...) CMyView::OnLButtonDown(...) // Document // DWORD // DWORD Document FF FF F 6B LButtonDown CMyView::OnLButtonDown C C b View Document Document/View MFC CDocument Serialize CView OnDraw OnPaint CMyDoc CMyView CMyDoc::Serialize CMyView::OnDraw 421

117 第㆔篇淺出 MFC 程式設計 File/Open Application Framework CMyDoc::Serialize Application Framework CMyView::OnDraw WM_PAINT Framework CMyView::OnDraw Display DC File/Print... Framework CMyView::OnDraw Printer DC MFC MFC Framework GUI MFC Document/View GUI Document/View Application Framework Visual C++ IC MFC MFC MFC AppWizard Scribble Step0 422

118 第 7 章簡單而完整 :MFC 骨幹程式 AppWizard Scribble Step0 #if...#endif // //.H.CPP.CPP.H 7-4 Scribble step0 CScribbleApp CWinApp Scribble.h Scribble.cpp CMainFrame CMDIFrameWnd Mainfrm.h Mainfrm.cpp CChildFrame CMDIChildWnd Childfrm.h Childfrm.cpp CScribbleDoc CDocument ScribbleDoc.h ScribbleDoc.cpp CScribbleView CView ScribbleView.h ScribbleView.cpp CAboutDlg CDialog Scribble.cpp Scribble.cpp 7-4 Scribble Scribble step0 MFC Document/View MFC MDI 423

119 第㆔篇淺出 MFC 程式設計 MFC CWinApp CScribbleApp application object CMDIFrameWnd CMainFrame MDI CMultiDocTemplate Document/View CDocument CScribbleDoc Document CView CScribbleView View CMDIChildWnd CChildFrame MDI CToolBar CStatusBar CDialog CAboutDlg About MFC 7-1 Document/View MDI SDI AppWizard Options 4-2b SDI MDI MFC 7-4 Scribble step

120 第 7 章簡單而完整 :MFC 骨幹程式 Application CWinApp Document Template CMultiDocTemplate Document CDocument CToolBar MDI Frame CMDIFrameWnd CStatusBar MDI Child CDialog View Document Frame CView CMDIChildWnd 7-5 Scribble step0 MFC MDI 7-6 Scribble step0 #0001 class CScribbleApp : public CWinApp #0002 #0003 virtual BOOL InitInstance(); // HelloMFC #0004 afx_msg void OnAppAbout(); // "About" #0005 DECLARE_MESSAGE_MAP() // CWinApp #0006 ; // #0007 // #0008 class CMainFrame : public CMDIFrameWnd #0009 #0010 DECLARE_DYNAMIC(CMainFrame) #0011 CStatusBar m_wndstatusbar; #0012 CToolBar m_wndtoolbar; #0013 afx_msg int OnCreate(LPCREATESTRUCT lpcreatestruct); #0014 DECLARE_MESSAGE_MAP() #0015 ; #0016 #0017 class CChildFrame : public CMDIChildWnd #

121 第㆔篇淺出 MFC 程式設計 #0019 DECLARE_DYNCREATE(CChildFrame) #0020 DECLARE_MESSAGE_MAP() #0021 ; #0022 #0023 class CScribbleDoc : public CDocument #0024 #0025 DECLARE_DYNCREATE(CScribbleDoc) #0026 virtual void Serialize(CArchive& ar); #0027 DECLARE_MESSAGE_MAP() #0028 ; #0029 #0030 class CScribbleView : public CView #0031 #0032 DECLARE_DYNCREATE(CScribbleView) #0033 CScribbleDoc* GetDocument(); #0034 #0035 virtual void OnDraw(CDC* pdc); #0036 DECLARE_MESSAGE_MAP() // MFC 內部 #0037 ; Int AfxAPI AfxWinMain( K) #0038 #0039 class CAboutDlg : public CDialog CWinApp* papp = AfxGetApp(); #0040 AfxWinInit( K); ➁ #0041 DECLARE_MESSAGE_MAP() #0042 ; papp->initapplication(); ➂ #0043 papp->initinstance(); ➃ #0044 // nreturncode = papp->run(); ➊ #0045 #0046 CScribbleApp theapp; ➀ #0047 #0048 BEGIN_MESSAGE_MAP(CScribbleApp, CWinApp) #0049 ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ➍ #0050 ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) #0051 ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) ➋ #0052 ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) #0053 END_MESSAGE_MAP() #0054 #0055 BOOL CScribbleApp::InitInstance() ➄ #0056 # #0058 CMultiDocTemplate* pdoctemplate; #0059 pdoctemplate = new CMultiDocTemplate( ➅ #0060 IDR_SCRIBTYPE, #0061 RUNTIME_CLASS(CScribbleDoc), #0062 RUNTIME_CLASS(CChildFrame), #0063 RUNTIME_CLASS(CScribbleView)); #0064 AddDocTemplate(pDocTemplate); 426

122 第 7 章簡單而完整 :MFC 骨幹程式 #0065 #0066 CMainFrame* pmainframe = new CMainFrame; ➆ #0067 pmainframe->loadframe(idr_mainframe); ➇ #0068 m_pmainwnd = pmainframe; #0069 K #0070 pmainframe->showwindow(m_ncmdshow); ➉ #0071 pmainframe->updatewindow(); #0072 return TRUE; #0073 #0074 #0075 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) #0076 END_MESSAGE_MAP() #0077 #0078 void CScribbleApp::OnAppAbout() ➎ #0079 #0080 CAboutDlg aboutdlg; #0081 aboutdlg.domodal(); #0082 #0083 #0084 IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) #0085 #0086 BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) #0087 ON_WM_CREATE() #0088 END_MESSAGE_MAP() #0089 #0090 static UINT indicators[] = #0091 #0092 ID_SEPARATOR, #0093 ID_INDICATOR_CAPS, #0094 ID_INDICATOR_NUM, #0095 ID_INDICATOR_SCRL, #0096 ; #0097 #0098 int CMainFrame::OnCreate(LPCREATESTRUCT lpcreatestruct) ➈ #0099 #0100 m_wndtoolbar.create(this); #0101 m_wndtoolbar.loadtoolbar(idr_mainframe); #0102 m_wndstatusbar.create(this); // MFC 內部 CFrameWnd::Create CWnd::CreateEx ::CreateWindowEx WM_CREATE wmˍcre #0103 m_wndstatusbar.setindicators(indicators, #0104 sizeof(indicators)/sizeof(uint)); #0105 #0106 m_wndtoolbar.setbarstyle(m_wndtoolbar.getbarstyle() #0107 CBRS_TOOLTIPS CBRS_FLYBY CBRS_SIZE_DYNAMIC); #0108 #0109 m_wndtoolbar.enabledocking(cbrs_align_any); 427

123 第㆔篇淺出 MFC 程式設計 #0110 EnableDocking(CBRS_ALIGN_ANY); #0111 DockControlBar(&m_wndToolBar); #0112 return 0; #0113 #0114 #0115 IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) #0116 #0117 BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) #0118 END_MESSAGE_MAP() #0119 #0120 IMPLEMENT_DYNCREATE(CScribbleDoc, CDocument) #0121 #0122 BEGIN_MESSAGE_MAP(CScribbleDoc, CDocument) #0123 END_MESSAGE_MAP() #0124 #0125 void CScribbleDoc::Serialize(CArchive& ar) ➌ #0126 #0127 if (ar.isstoring()) #0128 #0129 // TODO: add storing code here #0130 #0131 else #0132 #0133 // TODO: add loading code here #0134 #0135 #0136 #0137 IMPLEMENT_DYNCREATE(CScribbleView, CView) #0138 #0139 BEGIN_MESSAGE_MAP(CScribbleView, CView) #0140 ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) #0141 ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) #0142 ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) #0143 END_MESSAGE_MAP() #0144 #0145 void CScribbleView::OnDraw(CDC* pdc) #0146 #0147 CScribbleDoc* pdoc = GetDocument(); #0148 // TODO: add draw code for native data here # Scribble step0 428

124 第 7 章簡單而完整 :MFC 骨幹程式 7-6 ➀~➃ Hello ➄ InitInstance ➅ new CMultiDocTemplate Document View Document Frame ➆ new CMyMDIFrameWnd ➇ LoadFrame IDR_MAINFRAME LoadFrame Create CreateWindowEx WM _CREATE ➈ CMainFrame WM _CREATE ON_WM_CREATE WM _CREATE Framework OnCreate ➉ InitInstance ShowWindow ➊ InitInstance AfxWinMain Run Hello ➋ Message Message Routing Map WM_COMMAND/ID_FILE_OPEN CWinApp::OnFileOpen MFC File Serialize Open ➌ Serialize ➍ WM_COMMAND/ID_APP_ABOUT OnAppAbout ➎ OnAppAbout CDialog 429

125 第㆔篇淺出 MFC 程式設計 Document Template Document/View View MDI Document SDI Frame Document OLE Frame Document Frame Document View Frame 1. Document 2. View 3. CMDIChildWnd Document Template CMultiDocTemplate BOOL CScribbleApp::InitInstance()... CMultiDocTemplate* pdoctemplate; pdoctemplate = new CMultiDocTemplate( IDR_SCRIBTYPE, RUNTIME_CLASS(CScribbleDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CScribbleView)); AddDocTemplate(pDocTemplate);... TEXT BITMAP Document Template: 430

126 第 7 章簡單而完整 :MFC 骨幹程式 BOOL CMyWinApp::InitInstance()... CMultiDocTemplate* pdoctemplate; pdoctemplate = new CMultiDocTemplate( IDR_TEXTTYPE, RUNTIME_CLASS(CTextDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CTextView)); AddDocTemplate(pDocTemplate); pdoctemplate = new CMultiDocTemplate( IDR_BMPTYPE, RUNTIME_CLASS(CBmpDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CBmpView)); AddDocTemplate(pDocTemplate);... CMultiDocTemplate CMultiDocTemplate::CMultiDocTemplate(UINT nidresource, CRuntimeClass* pdocclass, CRuntimeClass* pframeclass, CRuntimeClass* pviewclass); 1. nidresource ID IDR_SCRIBTYPE RC ID IDR_SCRIBTYPE ICON DISCARDABLE "res\\scribbledoc.ico" IDR_SCRIBTYPE MENU PRELOAD DISCARDABLE... STRINGTABLE PRELOAD DISCARDABLE BEGIN IDR_MAINFRAME "Scribble Step0" IDR_SCRIBTYPE "\nscrib\nscrib\nscribble Files (*.scb)\n.scb\n Scribble.Document\nScrib Document" END '\n' MDI 431

127 第㆔篇淺出 MFC 程式設計 ICON MENU STRINGTABLE 2. pdocclass Document CDocument CRuntimeClass 3. pframeclass Child CMDIChildWnd CRuntimeClass 4. pviewclass CView CRuntimeClass CRuntimeClass RTTI CRuntimeClass DECLARE_DYNAMIC DECLARE_DYNCREATE DECLARE_SERIAL static CRuntimeClass Document Template CRuntimeClass Document Template document view document frame window MFC Document Template CMultiDocTemplate IDR_SCRIBTYPE RC MENU ICON STRING '\n' AppWizard Advanced Options 432

128 第 7 章簡單而完整 :MFC 骨幹程式 RC IDR_MAINFRAME: "Scribble Step0" IDR_SCRIBTYPE( ): \n Scrib\n Scrib\n Scribble Files (*.scb)\n.scb\n Scribble.Document\n Scrib Document CDocTemplate::GetDocString 1~7 CDocTemplate CDocTemplate // in AFXWIN.H class CDocTemplate : public CCmdTarget... enum DocStringIndex windowtitle, // default window title docname, // user visible name for default document filenewname, // user visible name for FileNew // for file based documents: filtername, // user visible name for FileOpen filterext, // user visible extension for FileOpen // for file based documents with Shell open support: regfiletypeid, // REGEDIT visible registered file type identifier regfiletypename // Shell visible registered file type name ;... ; 433

129 第㆔篇淺出 MFC 程式設計 CString strdefext, strdocname; pdoctemplate->getdocstring(strdefext, CDocTemplate::filterExt); pdoctemplate->getdocstring(strdocname, CDocTemplate::docName); index 1. CDocTemplate::windowTitle SDI MDI IDR_MAINFRAME 2. CDocTemplate::docName "Scrib" "Scrib1" "Untitled" 3. CDocTemplate::fileNewName File/New File/New File/New 13 # CDocTemplate::filterName (wildcard filter string) "Scribble(*.scb)" File Open List Files Of Type 5. CDocTemplate::filterExt "scb" File Open 6. CDocTemplate::regFileTypeId ::RegisterShellFileTypes Registry HKEY_CLASSES_ROOT subkey Windows 7. (drag and drop) CDocTemplate::regFileTypeName Registry 434

130 第 7 章簡單而完整 :MFC 骨幹程式 Scribble 1 CDocTemplate::windowTitle 3 p.743 New 2 CDocTemplate::docName 4 CDocTemplate::filterName 5 CDocTemplate::filterExt 7 6 CDocTemplate::regFileTypeName CDocTemplate::regFileTypeId AppWizard AppW 435

131 第㆔篇淺出 MFC 程式設計 Document View CDocument Collections Classes MFC CView CDC CGdiObject MFC Document/View 7-3 View View Document View Document View Document Document Frame Document Views Views Document View CScrollView -- Serialization Serialize CMyDoc Serialize Scribble step1 step0 CScribbleDoc Serialize 436

132 第 7 章簡單而完整 :MFC 骨幹程式 void CScribbleDoc::Serialize(CArchive& ar) if (ar.isstoring()) // TODO: add storing code here else // TODO: add loading code here View Document Document Frame CView View 1. Document Frame WM _PAINT View OnPaint OnPaint OnDraw OnDraw OnPaint View View afx_msg void OnLButtonDown(UINT nflags, CPoint point); afx_msg void OnLButtonUp(UINT nflags, CPoint point); afx_msg void OnMouseMove(UINT nflags, CPoint point); Scribble step0 void CScribbleView::OnDraw(CDC* pdc) CScribbleDoc* pdoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here 437

133 第㆔篇淺出 MFC 程式設計 Hello CFrameWnd MDI CMDIFrameWnd MDI new CMDIFrameWnd LoadFrame // in WNDFRM.CPP BOOL CFrameWnd::LoadFrame(UINT nidresource, DWORD dwdefaultstyle, CWnd* pparentwnd, CCreateContext* pcontext) CString strfullstring; if (strfullstring.loadstring(nidresource)) AfxExtractSubString(m_strTitle, strfullstring, 0); // first sub-string if (!AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG)) return FALSE; // attempt to create the window LPCTSTR lpszclass = GetIconWndClass(dwDefaultStyle, nidresource); LPCTSTR lpsztitle = m_strtitle; if (!Create(lpszClass, lpsztitle, dwdefaultstyle, rectdefault, pparentwnd, MAKEINTRESOURCE(nIDResource), 0L, pcontext)) return FALSE; // will self destruct on failure normally // save the default menu handle m_hmenudefault = ::GetMenu(m_hWnd); // load accelerator resource LoadAccelTable(MAKEINTRESOURCE(nIDResource)); if (pcontext == NULL) // send initial update SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE); return TRUE; 438

134 第 7 章簡單而完整 :MFC 骨幹程式 BOOL CScribbleApp::InitInstance()... CMainFrame* pmainframe = new CMainFrame; if (!pmainframe->loadframe(idr_mainframe)) return FALSE; m_pmainwnd = pmainframe;... CFrameWnd::LoadFrame CFrameWnd::LoadFrame CFrameWnd::Create CFrameWnd::Create CWnd::CreateEx ::CreateWindowEx ::CreateWindowEx WM_CREATE BEGIN_MESSAGE_MAP(CMainFrame, BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) CMDIFrameWnd) ON_WM_CREATE() ON_WM_CREATE() END_MESSAGE_MAP() END_MESSAGE_MAP() CMainFrame::OnCreate CMainFrame::OnCreate WM _CREATE CMainFrame ::OnCreate Lo IDR_MAINFRAME CFrameWnd::LoadFrame // defined in SCRIBBLE.RC IDR_MAINFRAME ICON DISCARDABLE "res\\scribble.ico" IDR_MAINFRAME MENU PRELOAD DISCARDABLE... IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE... STRINGTABLE PRELOAD DISCARDABLE BEGIN IDR_MAINFRAME "Scribble Step0".. END LoadFrame Create 439

135 第㆔篇淺出 MFC 程式設計 CToolBar CStatusBar CMainFrame class CMainFrame : public CMDIFrameWnd protected: // control bar embedded members CStatusBar m_wndstatusbar; CToolBar m_wndtoolbar;... ; WM _CREATE WM _CREATE Message Map BEGIN_MESSAGE_MAP(CMyMDIFrameWnd, CMDIFrameWnd) ON_WM_CREATE() END_MESSAGE_MAP() ON_WM_CREATE WM _CREATE OnCreate AppWizard OnCreate int CMainFrame::OnCreate(LPCREATESTRUCT lpcreatestruct) if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndtoolbar.create(this)!m_wndtoolbar.loadtoolbar(idr_mainframe)) TRACE0("Failed to create toolbar\n"); return -1; // fail to create if (!m_wndstatusbar.create(this)!m_wndstatusbar.setindicators(indicators, sizeof(indicators)/sizeof(uint))) TRACE0("Failed to create status bar\n"); return -1; // fail to create 440

136 第 7 章簡單而完整 :MFC 骨幹程式 // TODO: Remove this if you don't want tool tips or a resizeable toolbar m_wndtoolbar.setbarstyle(m_wndtoolbar.getbarstyle() CBRS_TOOLTIPS CBRS_FLYBY CBRS_SIZE_DYNAMIC); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndtoolbar.enabledocking(cbrs_align_any); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; m_wndtoolbar.create(this) this m_wndtoolbar.loadtoolbar(idr_mainframe) RC IDR _MAINFRAME RC IDR_MAINFRAME BITMAP MOVEABLE PURE "RES\\TOOLBAR.BMP" IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 BEGIN BUTTON ID_FILE_NEW BUTTON ID_FILE_OPEN BUTTON ID_FILE_SAVE SEPARATOR BUTTON ID_EDIT_CUT BUTTON ID_EDIT_COPY BUTTON ID_EDIT_PASTE SEPARATOR BUTTON ID_FILE_PRINT BUTTON ID_APP_ABOUT END LoadToolBar LoadBitmap + SetButtons LoadToolBar BITMAP TOOLBAR VC++ BITMAP TOOLBAR TOOLBAR ID 441

137 第㆔篇淺出 MFC 程式設計 m_wndstatusbar.create(this) this m_wndstatusbar.setindicators(,...) Indicator On/Off AFXRES.H indicators #define ID_INDICATOR_EXT #define ID_INDICATOR_CAPS #define ID_INDICATOR_NUM #define ID_INDICATOR_SCRL #define ID_INDICATOR_OVR #define ID_INDICATOR_REC #define ID_INDICATOR_KANA 0xE700 // extended selection indicator 0xE701 // cap lock indicator 0xE702 // num lock indicator 0xE703 // scroll lock indicator 0xE704 // overtype mode indicator 0xE705 // record mode indicator 0xE706 // kana lock indicator static static UINT UINT indicators[] indicators[] = = ID_SEPARATOR, ID_SEPARATOR, // // status status line line indicator indicator ID_INDICATOR_CAPS, ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, ID_INDICATOR_SCRL, ; ; MFC Drag and Drop Shell Windows 95 Document Frame Shell 442

138 第 7 章簡單而完整 :MFC 骨幹程式 SDK Drag and Drop Shell Shell WM _DROPFILES WM _DROPFILES WS_EX _ACCEPTFILES CreateWindow WS_EX _ACCEPTFILES WM_DROPFILES wparam DragQueryFile DragQueryPoint API SDK MFC BOOL CScribbleApp::InitInstance()... // Enable drag/drop open m_pmainwnd->dragacceptfiles(); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE);... CWnd::DragAcceptFile(BOOL baccept=true); TRUE Shell CFrameWnd OnDropFiles WM _DROPFIELS application OnOpenDocument 443

139 第㆔篇淺出 MFC 程式設計 CWinApp::EnableShellOpen(); Shell Framework DDE Dynamic Data Exchange DDE CDocManager DDE RegisterShellFileTypes CWinApp::RegisterShellFileTypes(); Shell Shell Document Template registry Windows Registry.reg Windows regedit.exe.reg Registry ::RegCreateKey ::RegSetValue Win32 Registry MFC CWinApp::RegisterShellFileTypes.txt Notepad.bmp PBrush.ppt PowerPoint.xls Excel Scribble.txt Shell Notepad Scribble.bmp Shell Scribble Scribble 444

140 第 7 章簡單而完整 :MFC 骨幹程式 CCmdTarget Message Map DECLARE_MESSAGE_MAP.CPP BEGIN_MESSAGE_MAP END_MESSAGE_MAP 7-6 Scribble Message Map CScribbleApp WM_COMMAND BEGIN_MESSAGE_MAP(CScribbleApp, CWinApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) END_MESSAGE_MAP() ID_APP_ABOUT OnAppAbout CWinApp 445

141 第㆔篇淺出 MFC 程式設計 MDI IDR_MAINFRAME IDR_SCRIBTYPE 446

142 第 7 章簡單而完整 :MFC 骨幹程式 File View Help IDR _MAINFRAME IDR _SCRIBTYPE RC MFC Framework Framework Open Save Print As Print Setup Find Replace Edit CEditView File LRU Appwizard View Window Cascade Tile Yes Message No Map ID File New ID_FILE_NEW CWinApp::OnFileNew No Open ID_FILE_OPEN CWinApp::OnFileOpen No Close ID_FILE_CLOSE CDocument::OnFileClose Yes Save ID_FILE_SAVE CDocument::OnFileSave Yes Save As ID_FILE_SAVEAS CDocument::OnFileSaveAs Yes Print ID_FILE_PRINT CView::OnFilePrint No Print Pre&view ID_FILE_PRINT_PREVIEW CView::OnFilePrintPreview No Print Setup ID_FILE_PRINT_SETUP CWinApp::OnFilePrintSetup No "Recent File Name" ID_FILE_MRU_FILE1~4 CWinApp::OnOpenRecentFile Yes 447

143 第㆔篇淺出 MFC 程式設計 ID Exit ID_APP_EXIT CWinApp::OnFileExit Yes Edit Undo ID_EDIT_UNDO None Cut ID_EDIT_CUT None Copy ID_EDIT_COPY None Paste ID_EDIT_PASTE None View Toolbar ID_VIEW_TOOLBAR FrameWnd::OnBarCheck Yes Status Bar ID_VIEW_STATUS_BAR FrameWnd::OnBarCheck Yes Window(MDI only) New Window ID_WINDOW_NEW MDIFrameWnd::OnWindowNew Yes Cascade ID_WINDOW_CASCADE MDIFrameWnd::OnWindowCmd Yes Tile ID_WINDOW_TILE_HORZ MDIFrameWnd::OnWindowCmd Yes Arrange Icons ID_WINDOW_ARRANGE MDIFrameWnd::OnWindowCmd Yes Help About AppName ID_APP_ABOUT None No Message AppWizar Map BEGIN_MESSAGE_MAP(CScribbleApp, CWinApp)... ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) END_MESSAGE_MAP() BEGIN_MESSAGE_MAP(CScribbleView, CView)... ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() 448

144 第 7 章簡單而完整 :MFC 骨幹程式 Scribble About WM _COMMAND ID_APP_ABOUT Message Map: BEGIN_MESSAGE_MAP(CScribbleApp, CWinApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) END_MESSAGE_MAP() OnAppAbout void CScribbleApp::OnAppAbout() CAboutDlg aboutdlg; aboutdlg.domodal(); CAboutDlg CDialog class CAboutDlg : public CDialog enum IDD = IDD_ABOUTBOX ; // IDD_ABOUTBOX RC... DECLARE_MESSAGE_MAP() ; SDK SDK dialog C template CDialog DoModal 10 DDX 449

145 第㆔篇淺出 MFC 程式設計 Scribble step0 AppWizard CScribbleView CView CEditView CEditView Edit SerializeRaw Edit raw text AppWizard CView CEditView void CScribbleDoc::Serialize(CArchive& ar) // CEditView contains an edit control which handles all serialization ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar); void CScribbleView::OnDraw(CDC* pdc) 450

146 第 7 章簡單而完整 :MFC 骨幹程式 CScribbleDoc* pdoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here 451

epub83-1

epub83-1 C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

bingdian001.com

bingdian001.com 1. DLL(Dynamic Linkable Library) DLL ± lib EXE DLL DLL EXE EXE ± EXE DLL 1 DLL DLL DLL Windows DLL Windows API Visual Basic Visual C++ Delphi 2 Windows system32 kernel32.dll user32.dll gdi32.dll windows

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

ebook50-15

ebook50-15 15 82 C / C + + Developer Studio M F C C C + + 83 C / C + + M F C D L L D L L 84 M F C MFC DLL M F C 85 MFC DLL 15.1 82 C/C++ C C + + D L L M F C M F C 84 Developer Studio S t u d i o 292 C _ c p l u s

More information

ebook50-14

ebook50-14 14 M F C 74 75 76 77 M F C 78 M F C 79 M F C 80 D e l e t e Delete ( ) 81 M F C 14.1 74 14-1 Cut Paste C E d i t 14-1 1. C l a s s Wi z a r d C E d i t C l a s s Wi z a r d W M _ R B U T TO N D O W N 2.

More information

INTRODUCTION TO COM.DOC

INTRODUCTION TO COM.DOC 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

More information

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2 PowerBuilder 9 PowerBuilder Native Interface(PBNI) PowerBuilder 9 PowerBuilder C++ Java PowerBuilder 9 PBNI PowerBuilder Java C++ PowerBuilder NVO / PowerBuilder C/C++ PowerBuilder 9.0 PowerBuilder Native

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

The Analysis Of Basic MFC Program Running Principle

The Analysis Of Basic MFC Program Running Principle 浅析 MFC 程序基本运行机制 或许我不该写这篇文章 ; 或许你会不屑的看了看标题, 然后华丽的 WS 之 ; 又或许你会在看完之后, 在 这篇文章的末尾的写上 打倒 KC, 打倒 MFC, 打倒 M$, 然后签上自己伟大的名字 但是这都丝毫不会影响包括我在内的所有想了解 MFC 的 Coder 对于 MFC 研究 或许, 有好几个问题曾连续地在你的脑海里浮现 : MFC 很容易学么? 是的, 很容易

More information

(procedure-oriented)?? 2

(procedure-oriented)?? 2 1 (procedure-oriented)?? 2 (Objected-Oriented) (class)? (method)? 3 : ( 4 ???? 5 OO 1966 Kisten Nygaard Ole-Johan Dahl Simula Simula 爲 6 Smalltalk Alan Kay 1972 PARC Smalltalk Smalltalk 爲 Smalltalk 爲 Smalltalk

More information

概述

概述 OPC Version 1.8 build 0925 KOCRDK Knight OPC Client Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOC_Init...5 2.2.2 KOC_Uninit...5 2.3...5

More information

CHAPTER 1

CHAPTER 1 CHAPTER 1 1-1 System Development Life Cycle; SDLC SDLC Waterfall Model Shelly 1995 1. Preliminary Investigation 2. System Analysis 3. System Design 4. System Development 5. System Implementation and Evaluation

More information

Learning Java

Learning Java Java Introduction to Java Programming (Third Edition) Prentice-Hall,Inc. Y.Daniel Liang 2001 Java 2002.2 Java2 2001.10 Java2 Philip Heller & Simon Roberts 1999.4 Java2 2001.3 Java2 21 2002.4 Java UML 2002.10

More information

2/80 2

2/80 2 2/80 2 3/80 3 DSP2400 is a high performance Digital Signal Processor (DSP) designed and developed by author s laboratory. It is designed for multimedia and wireless application. To develop application

More information

ebook51-14

ebook51-14 14 Wi n d o w s M F C 53 54 55 56 ( ) ( Wo r k e r T h r e a d ) 57 ( ) ( U s e r Interface Thread) 58 59 14.1 53 1. 2. C l a s s Wi z a r d O n I d l e () 3. Class Wi z a r d O n I d l e () O n I d l

More information

國家圖書館典藏電子全文

國家圖書館典藏電子全文 EAI EAI Middleware EAI 3.1 EAI EAI Client/Server Internet,www,Jav a 3.1 EAI Message Brokers -Data Transformation Business Rule XML XML 37 3.1 XML XML XML EAI XML 1. XML XML Java Script VB Script Active

More information

ebook140-8

ebook140-8 8 Microsoft VPN Windows NT 4 V P N Windows 98 Client 7 Vintage Air V P N 7 Wi n d o w s NT V P N 7 VPN ( ) 7 Novell NetWare VPN 8.1 PPTP NT4 VPN Q 154091 M i c r o s o f t Windows NT RAS [ ] Windows NT4

More information

Microsoft Word - 11.doc

Microsoft Word - 11.doc 除 錯 技 巧 您 將 於 本 章 學 到 以 下 各 項 : 如 何 在 Visual C++ 2010 的 除 錯 工 具 控 制 下 執 行 程 式? 如 何 逐 步 地 執 行 程 式 的 敘 述? 如 何 監 看 或 改 變 程 式 中 的 變 數 值? 如 何 監 看 程 式 中 計 算 式 的 值? 何 謂 Call Stack? 何 謂 診 斷 器 (assertion)? 如 何

More information

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

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 Windows RTEMS 1 Danilliu MMI TCP/IP 80486 QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos ecos Email www.rtems.com RTEMS ecos RTEMS RTEMS Windows

More information

Microsoft Word - 物件導向編程精要.doc

Microsoft Word - 物件導向編程精要.doc Essential Object-Oriented Programming Josh Ko 2007.03.11 object-oriented programming C++ Java OO class object OOP Ruby duck typing complexity abstraction paradigm objects objects model object-oriented

More information

EJB-Programming-3.PDF

EJB-Programming-3.PDF :, JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Value Object Design Pattern J2EE Design Patterns Value Object Value Object Factory J2EE EJB Test Client

More information

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

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 References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

02

02 Thinking in C++: Volume One: Introduction to Standard C++, Second Edition & Volume Two: Practical Programming C++ C C++ C++ 3 3 C C class C++ C++ C++ C++ string vector 2.1 interpreter compiler 2.1.1 BASIC

More information

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

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO Car DVD New GUI IR Flow User Manual V0.1 Jan 25, 2008 19, Innovation First Road Science Park Hsin-Chu Taiwan 300 R.O.C. Tel: 886-3-578-6005 Fax: 886-3-578-4418 Web: www.sunplus.com Important Notice SUNPLUS

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

RUN_PC連載_12_.doc

RUN_PC連載_12_.doc PowerBuilder 8 (12) PowerBuilder 8.0 PowerBuilder PowerBuilder 8 PowerBuilder 8 / IDE PowerBuilder PowerBuilder 8.0 PowerBuilder PowerBuilder PowerBuilder PowerBuilder 8.0 PowerBuilder 6 PowerBuilder 7

More information

VB程序设计教程

VB程序设计教程 高 等 学 校 教 材 Visual Basic 程 序 设 计 教 程 魏 东 平 郑 立 垠 梁 玉 环 石 油 大 学 出 版 社 内 容 提 要 本 书 是 按 高 等 学 校 计 算 机 程 序 设 计 课 程 教 学 大 纲 编 写 的 大 学 教 材, 主 要 包 括 VB 基 础 知 识 常 用 程 序 结 构 和 算 法 Windows 用 户 界 面 设 计 基 础 文 件 处

More information

Microsoft PowerPoint - ch6 [相容模式]

Microsoft PowerPoint - ch6 [相容模式] UiBinder wzyang@asia.edu.tw UiBinder Java GWT UiBinder XML UI i18n (widget) 1 2 UiBinder HelloWidget.ui.xml: UI HelloWidgetBinder HelloWidget.java XML UI Owner class ( Composite ) UI XML UiBinder: Owner

More information

<4D6963726F736F667420506F776572506F696E74202D20C8EDBCFEBCDCB9B9CAA6D1D0D0DEBDB2D7F92E707074>

<4D6963726F736F667420506F776572506F696E74202D20C8EDBCFEBCDCB9B9CAA6D1D0D0DEBDB2D7F92E707074> 软 件 架 构 师 研 修 讲 座 胡 协 刚 软 件 架 构 师 UML/RUP 专 家 szjinco@public.szptt.net.cn 中 国 软 件 架 构 师 网 东 软 培 训 中 心 小 故 事 : 七 人 分 粥 当 前 软 件 团 队 的 开 发 现 状 和 面 临 的 问 题 软 件 项 目 的 特 点 解 决 之 道 : 从 瀑 布 模 型 到 迭 代 模 型 解 决 项

More information

提问袁小兵:

提问袁小兵: C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.

More information

Value Chain ~ (E-Business RD / Pre-Sales / Consultant) APS, Advanc

Value Chain ~ (E-Business RD / Pre-Sales / Consultant) APS, Advanc Key @ Value Chain fanchihmin@yahoo.com.tw 1 Key@ValueChain 1994.6 1996.6 2000.6 2000.10 ~ 2004.10 (E- RD / Pre-Sales / Consultant) APS, Advanced Planning & Scheduling CDP, Collaborative Demand Planning

More information

ebook140-9

ebook140-9 9 VPN VPN Novell BorderManager Windows NT PPTP V P N L A V P N V N P I n t e r n e t V P N 9.1 V P N Windows 98 Windows PPTP VPN Novell BorderManager T M I P s e c Wi n d o w s I n t e r n e t I S P I

More information

Windows XP

Windows XP Windows XP What is Windows XP Windows is an Operating System An Operating System is the program that controls the hardware of your computer, and gives you an interface that allows you and other programs

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

2/e 1998/04 MFC 1/e Windows MFC MFC 2/e 1998/ UNALIS 3/e 2/e 2/e 3/e 3/e MFC 2/e MFC 3/e MFC MFC 2/e VC5+MFC42 VC6+MFC421 MFC 2/e 1

2/e 1998/04 MFC 1/e Windows MFC MFC 2/e 1998/ UNALIS 3/e 2/e 2/e 3/e 3/e MFC 2/e MFC 3/e MFC MFC 2/e VC5+MFC42 VC6+MFC421 MFC 2/e 1 2/e 1998/04 MFC 1/e Windows MFC MFC 2/e 1998/05 1998 UNALIS 3/e 2/e 2/e 3/e 3/e MFC 2/e MFC 3/e MFC MFC 2/e VC5+MFC42 VC6+MFC421 MFC 2/e 1 MFC 2/e PDF http://www.jjhou.com http://expert.csdn.net/jjhou

More information

Java 1 Java String Date

Java 1 Java String Date JAVA SCJP Java 1 Java String Date 1Java 01 Java Java 1995 Java Java 21 Java Java 5 1-1 Java Java 1990 12 Patrick Naughton C++ C (Application Programming Interface API Library) Patrick Naughton NeXT Stealth

More information

슬라이드 1

슬라이드 1 2018-2019 年度第二学期 00106501 计算机图形学 童伟华管理科研楼 1205 室 E-mail: tongwh@ustc.edu.cn 中国科学技术大学数学科学学院 http://math.ustc.edu.cn/ 附讲五 Windows 编程 (API) 2 Windows 操作系统简史 1981 年,Chase Bishop 提出 Interface Manager 模型 1985

More information

1 目 錄 1. 簡 介... 2 2. 一 般 甄 試 程 序... 2 3. 第 一 階 段 的 準 備... 5 4. 第 二 階 段 的 準 備... 9 5. 每 間 學 校 的 面 試 方 式... 11 6. 各 程 序 我 的 做 法 心 得 及 筆 記... 13 7. 結 論..

1 目 錄 1. 簡 介... 2 2. 一 般 甄 試 程 序... 2 3. 第 一 階 段 的 準 備... 5 4. 第 二 階 段 的 準 備... 9 5. 每 間 學 校 的 面 試 方 式... 11 6. 各 程 序 我 的 做 法 心 得 及 筆 記... 13 7. 結 論.. 如 何 準 備 研 究 所 甄 試 劉 富 翃 1 目 錄 1. 簡 介... 2 2. 一 般 甄 試 程 序... 2 3. 第 一 階 段 的 準 備... 5 4. 第 二 階 段 的 準 備... 9 5. 每 間 學 校 的 面 試 方 式... 11 6. 各 程 序 我 的 做 法 心 得 及 筆 記... 13 7. 結 論... 20 8. 附 錄 8.1 推 甄 書 面 資 料...

More information

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

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

目次 

目次  軟 體 工 程 期 末 報 告 網 路 麻 將 91703014 資 科 三 黃 偉 嘉 91703024 資 科 三 丘 祐 瑋 91703030 資 科 三 江 致 廣 1 目 次 壹 前 言 (Preface) P.4 貳 計 畫 簡 述 及 預 期 效 益 (Project Description and Expected Results) P.4 參 系 統 開 發 需 求 (System

More information

Eclipse C C++, or

Eclipse C C++,  or Eclipse C C++, Emailctchen@pl.csie.ntut.edu.tw or s1669021@ntut.edu.tw, s2598003@ntut.edu.tw http://pl.csie.ntut.edu.tw/~ctchen, http://www.ntut.edu.tw/~s2598003/ 2004/9/10 (0.02 ) Eclipse http://www.eclipse.org

More information

第 15 章 程 式 編 写 語 言 15.1 程 式 編 写 語 言 的 角 色 程 式 編 寫 語 言 是 程 式 編 寫 員 與 電 腦 溝 通 的 界 面 語 法 是 一 組 規 則 讓 程 式 編 寫 員 將 字 詞 集 合 起 來 電 腦 是 處 理 位 元 和 字 節 的 機 器, 與

第 15 章 程 式 編 写 語 言 15.1 程 式 編 写 語 言 的 角 色 程 式 編 寫 語 言 是 程 式 編 寫 員 與 電 腦 溝 通 的 界 面 語 法 是 一 組 規 則 讓 程 式 編 寫 員 將 字 詞 集 合 起 來 電 腦 是 處 理 位 元 和 字 節 的 機 器, 與 程 式 編 写 語 言 在 完 成 這 章 後, 你 將 能 夠 了 解 程 式 編 写 語 言 的 功 能 了 解 高 階 語 言 和 低 階 語 言 之 間 的 分 別 知 道 翻 譯 程 式 的 意 義 和 能 夠 把 翻 譯 程 式 分 類 為 : 匯 編 程 式 編 譯 程 式 和 解 譯 程 式 認 識 不 同 翻 譯 程 式 的 優 點 和 缺 點 程 式 是 指 揮 電 腦 的 指

More information

EJB-Programming-4-cn.doc

EJB-Programming-4-cn.doc EJB (4) : (Entity Bean Value Object ) JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Session Bean J2EE Session Façade Design Pattern Session Bean Session

More information

ebook50-11

ebook50-11 11 Wi n d o w s C A D 53 M F C 54 55 56 57 58 M F C 11.1 53 11-1 11-1 MFC M F C C D C Wi n d o w s Wi n d o w s 4 11 199 1. 1) W M _ PA I N T p W n d C W n d C D C * p D C = p W n d GetDC( ); 2) p W n

More information

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

基于UML建模的管理管理信息系统项目案例导航——VB篇 PowerBuilder 8.0 PowerBuilder 8.0 12 PowerBuilder 8.0 PowerScript PowerBuilder CIP PowerBuilder 8.0 /. 2004 21 ISBN 7-03-014600-X.P.. -,PowerBuilder 8.0 - -.TP311.56 CIP 2004 117494 / / 16 100717 http://www.sciencep.com

More information

序 软 件 工 程 思 想 林 锐 序 软 件 工 程 思 想 讲 述 软 件 开 发 和 做 程 序 员 的 道 理, 视 野 独 特, 构 思 新 颖, 内 容 风 趣, 不 落 窠 臼, 令 人 耳 目 一 新 堪 称 难 得, 以 至 回 味 无 穷 作 者 从 事 了 八 年 的 软 件 开 发 工 作, 在 他 的 博 士 学 位 论 文 完 成 之 际 写 下 了 这 本 心 之 所 感

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii 前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii C# 7 More Effective C# C# C# C# C# C# Common Language Runtime CLR just-in-time

More information

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南 Symantec Sygate Enterprise Protection 防 护 代 理 安 装 使 用 指 南 5.1 版 版 权 信 息 Copyright 2005 Symantec Corporation. 2005 年 Symantec Corporation 版 权 所 有 All rights reserved. 保 留 所 有 权 利 Symantec Symantec 徽 标 Sygate

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM CHAPTER 6 SQL SQL SQL 6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM 3. 1986 10 ANSI SQL ANSI X3. 135-1986

More information

Microsoft Word - CIN-DLL.doc

Microsoft Word - CIN-DLL.doc 6.3. 调 用 动 态 链 接 库 (DLL) 相 对 于 CIN 来 讲,NI 更 推 荐 用 户 使 用 DLL 来 共 享 基 于 文 本 编 程 语 言 开 发 的 代 码 除 了 共 享 或 重 复 利 用 代 码, 开 发 人 员 还 能 利 用 DLL 封 装 软 件 的 功 能 模 块, 以 便 这 些 模 块 能 被 不 同 开 发 工 具 利 用 在 LabVIEW 中 使 用

More information

WinMDI 28

WinMDI 28 WinMDI WinMDI 2 Region Gate Marker Quadrant Excel FACScan IBM-PC MO WinMDI WinMDI IBM-PC Dr. Joseph Trotter the Scripps Research Institute WinMDI HP PC WinMDI WinMDI PC MS WORD, PowerPoint, Excel, LOTUS

More information

RunPC2_.doc

RunPC2_.doc PowerBuilder 8 (5) PowerBuilder Client/Server Jaguar Server Jaguar Server Connection Cache Thin Client Internet Connection Pooling EAServer Connection Cache Connection Cache Connection Cache Connection

More information

EK-STM32F

EK-STM32F STMEVKIT-STM32F10xx8 软 件 开 发 入 门 指 南 目 录 1 EWARM 安 装... 1 1.1 第 一 步 : 在 线 注 册... 1 1.2 第 二 步 : 下 载 软 件... 2 1.3 第 三 步 : 安 装 EWARM... 3 2 基 于 STMEVKIT-STM32F10xx8 的 示 例 代 码 运 行... 6 2.1 GPIO Demo... 6 2.2

More information

epub 61-2

epub 61-2 2 Web Dreamweaver UltraDev Dreamweaver 3 We b We b We Dreamweaver UltraDev We b Dreamweaver UltraDev We b We b 2.1 Web We b We b D r e a m w e a v e r J a v a S c r i p t We b We b 2.1.1 Web We b C C +

More information

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f 27 1 Vol.27 No.1 CEMENTED CARBIDE 2010 2 Feb.2010!"!!!!"!!!!"!" doi:10.3969/j.issn.1003-7292.2010.01.011 OPC 1 1 2 1 (1., 412008; 2., 518052), OPC, WinCC VB,,, OPC ; ;VB ;WinCC Application of OPC Technology

More information

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

IBM Rational ClearQuest Client for Eclipse   1/ IBM Rational ClearQuest Client for Ecl 1/39 Balaji Krish,, IBM Nam LeIBM 2005 4 15 IBM Rational ClearQuest ClearQuest Eclipse Rational ClearQuest / Eclipse Clien Rational ClearQuest Rational ClearQuest Windows Web Rational ClearQuest Client

More information

2/14 Buffer I12, /* x=2, buffer = I 1 2 */ Buffer I243, /* x=34, buffer = I 2 43 */ x=56, buffer = I243 Buffer I243I265 code_int(int x, char *buffer)

2/14 Buffer I12, /* x=2, buffer = I 1 2 */ Buffer I243, /* x=34, buffer = I 2 43 */ x=56, buffer = I243 Buffer I243I265 code_int(int x, char *buffer) 1/14 IBM Rational Test RealTime IBM, 2004 7 01 50% IBM Rational Test RealTime IBM Rational Test RealTime 1. 50% IBM Rational Test RealTime IBM Rational Test RealTime 2. IBM Rational Test RealTime Test

More information

untitled

untitled 21 Visual FoxPro Visual FoxPro 6.0 11 Visual FoxPro Visual FoxPro CIP Visual FoxPro 2004 21 ISBN 7-03-014834-7 V Visual FoxPro TP311.138 CIP 2004 143035 16 100717 http://www.sciencep.com * 2004 12 7871092

More information

AL-M200 Series

AL-M200 Series NPD4754-00 TC ( ) Windows 7 1. [Start ( )] [Control Panel ()] [Network and Internet ( )] 2. [Network and Sharing Center ( )] 3. [Change adapter settings ( )] 4. 3 Windows XP 1. [Start ( )] [Control Panel

More information

D C 93 2

D C 93 2 D9223468 3C 93 2 Java Java -- Java UML Java API UML MVC Eclipse API JavadocUML Omendo PSPPersonal Software Programming [6] 56 8 2587 56% Java 1 epaper(2005 ) Java C C (function) C (reusability) eat(chess1,

More information

Microsoft PowerPoint - Aqua-Sim.pptx

Microsoft PowerPoint - Aqua-Sim.pptx Peng Xie, Zhong Zhou, Zheng Peng, Hai Yan, Tiansi Hu, Jun-Hong Cui, Zhijie Shi, Yunsi Fei, Shengli Zhou Underwater Sensor Network Lab 1 Outline Motivations System Overview Aqua-Sim Components Experimental

More information

IP505SM_manual_cn.doc

IP505SM_manual_cn.doc IP505SM 1 Introduction 1...4...4...4...5 LAN...5...5...6...6...7 LED...7...7 2...9...9...9 3...11...11...12...12...12...14...18 LAN...19 DHCP...20...21 4 PC...22...22 Windows...22 TCP/IP -...22 TCP/IP

More information

2 SGML, XML Document Traditional WYSIWYG Document Content Presentation Content Presentation Structure Structure? XML/SGML 3 2 SGML SGML Standard Gener

2 SGML, XML Document Traditional WYSIWYG Document Content Presentation Content Presentation Structure Structure? XML/SGML 3 2 SGML SGML Standard Gener SGML HTML XML 1 SGML XML Extensible Markup Language XML SGML Standard Generalized Markup Language, ISO 8879, SGML HTML ( Hypertext Markup Language HTML) (Markup Language) (Tag) < > Markup (ISO) 1986 SGML

More information

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

高尔夫赌博现金棋牌,能赚现金的棋牌游戏 街机赌博游戏 真钱的棋牌游戏,30 高 尔 夫 赌 博 现 金 棋 牌, 能 赚 现 金 的 棋 牌 游 戏 街 机 赌 博 游 戏 真 钱 的 棋 牌 游 戏,30 108 http://www.3-pointdriving.com 高 尔 夫 赌 博 现 金 棋 牌, 能 赚 现 金 的 棋 牌 游 戏 街 机 赌 博 游 戏 真 钱 的 棋 牌 游 戏,30 可 以 参 加 这 斗 地 主 和 麻 将 中 的 免 费 赢 奖 品

More information

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F 1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET 2.0 2.0.NET Framework.NET Framework 2.0 ( 3).NET Framework 2.0.NET Framework ( System ) o o o o o o Boxing UnBoxing() o

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

untitled

untitled COM ActiveX Control 年 ACTIVEX CONTROLS 念... 3 ACTIVEX... 3 MFC ACTIVEX CONTROLWIZARD... 3 MFC ACTIVEX CONTROLS WIZARD... 4 MFC... 4... 4 ACTIVEX... 4 ONDRAW 行... 4 ONDRAW() 數... 5 ACTIVEX... 5 (STOCK PROPERTIES)...

More information

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

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

untitled

untitled Work Managers 什 Work Managers? WebLogic Server 9.x 行 (thread) 理 thread pool 數量 立 execute queues 來 量 理 thread count, thread priority 參數 理 thread pool 數量? WebLogic Server 9.x 理 行 (thread) (self-tuning) 句

More information

AL-MX200 Series

AL-MX200 Series PostScript Level3 Compatible NPD4760-00 TC Seiko Epson Corporation Seiko Epson Corporation ( ) Seiko Epson Corporation Seiko Epson Corporation Epson Seiko Epson Corporation Apple Bonjour ColorSync Macintosh

More information

软件测试(TA07)第一学期考试

软件测试(TA07)第一学期考试 一 判 断 题 ( 每 题 1 分, 正 确 的, 错 误 的,20 道 ) 1. 软 件 测 试 按 照 测 试 过 程 分 类 为 黑 盒 白 盒 测 试 ( ) 2. 在 设 计 测 试 用 例 时, 应 包 括 合 理 的 输 入 条 件 和 不 合 理 的 输 入 条 件 ( ) 3. 集 成 测 试 计 划 在 需 求 分 析 阶 段 末 提 交 ( ) 4. 单 元 测 试 属 于 动

More information

CH01.indd

CH01.indd 3D ios Android Windows 10 App Apple icloud Google Wi-Fi 4G 1 ( 3D ) 2 3 4 5 CPU / / 2 6 App UNIX OS X Windows Linux (ios Android Windows 8/8.1/10 BlackBerry OS) 7 ( ZigBee UWB) (IEEE 802.11/a/b/g/n/ad/ac

More information

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

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE Project Properties IDE makefile 1. Oracle Solaris Studio 12.2 IDE 2010 9 2 8 9 10 11 13 20 26 28 30 32 33 Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1. "File" > "New

More information

OOAD PowerDesigner OOAD Applying PowerDesigner CASE Tool in OOAD PowerDesigner CASE Tool PowerDesigner PowerDesigner CASE To

OOAD PowerDesigner OOAD Applying PowerDesigner CASE Tool in OOAD PowerDesigner CASE Tool PowerDesigner PowerDesigner CASE To PowerDesigner Applying PowerDesigner CASE Tool in OOAD albertchung@mpinfo.com.tw PowerDesigner CASE Tool PowerDesigner PowerDesigner CASE Tool PowerDesigner CASE Tool CASE Tool PowerDesignerUnified ProcessUMLing

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

(Pattern Recognition) 1 1. CCD

(Pattern Recognition) 1 1. CCD ********************************* ********************************* (Pattern Recognition) 1 1. CCD 2. 3. 4. 1 ABSTRACT KeywordsMachine Vision, Real Time Inspection, Image Processing The purpose of this

More information

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月 高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月 电 子 教 案 P1 2 978-7-111-27081-2 计 算 机 应 用 基 础 ( 第 2

More information

穨control.PDF

穨control.PDF TCP congestion control yhmiu Outline Congestion control algorithms Purpose of RFC2581 Purpose of RFC2582 TCP SS-DR 1998 TCP Extensions RFC1072 1988 SACK RFC2018 1996 FACK 1996 Rate-Halving 1997 OldTahoe

More information

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile.. WebSphere Studio Application Developer IBM Portal Toolkit... 1/21 WebSphere Studio Application Developer IBM Portal Toolkit Portlet Doug Phillips (dougep@us.ibm.com),, IBM Developer Technical Support Center

More information

Microsoft PowerPoint ARIS_Platform_en.ppt

Microsoft PowerPoint ARIS_Platform_en.ppt ARIS Platform www.ixon.com.tw ARIS ARIS Architecture of Integrated Information System Prof. Dr. Dr. h.c. mult. August-Wilhelm Scheer ARIS () 2 IDS Scheer AG International Presence >> Partners and subsidiaries

More information

提纲 1 2 OS Examples for 3

提纲 1 2 OS Examples for 3 第 4 章 Threads2( 线程 2) 中国科学技术大学计算机学院 October 28, 2009 提纲 1 2 OS Examples for 3 Outline 1 2 OS Examples for 3 Windows XP Threads I An Windows XP application runs as a seperate process, and each process may

More information

untitled

untitled Ogre Rendering System http://antsam.blogone.net AntsamCGD@hotmail.com geometry systemmaterial systemshader systemrendering system API API DirectX OpenGL API Pipeline Abstraction API Pipeline Pipeline configurationpipeline

More information

第12讲 Windows API

第12讲 Windows API UNIT 13 MFC E-MAIL nadinetan@163.com MFC 2 MFC 3 MFC 4 5 6 7 1 MFC 1.1 MFC MFC Microsoft Foundation Class Windows mfc*.dll Windows MFC C++ 8 1.1 MFC MFC Microsoft Foundation Class MFC Windows Windows MFC

More information

PTS7_Manual.PDF

PTS7_Manual.PDF User Manual Soliton Technologies CO., LTD www.soliton.com.tw - PCI V2.2. - PCI 32-bit / 33MHz * 2 - Zero Skew CLK Signal Generator. - (each Slot). -. - PCI. - Hot-Swap - DOS, Windows 98/2000/XP, Linux

More information

豐佳燕.PDF

豐佳燕.PDF Application of Information Literacy to chiayen@estmtc.tp.edu.tw information literacy Theme-oriented teaching. Abstract Based on the definition of Information Literacy and Six core concepts of the problem

More information

Android Robert C.C. Huang Oscar F.Y. Liu Peter C.L. Hsieh 2011/03/21

Android Robert C.C. Huang Oscar F.Y. Liu Peter C.L. Hsieh 2011/03/21 Android Robert C.C. Huang Oscar F.Y. Liu Peter C.L. Hsieh 2011/03/21 Outlines for Today Future Planning Review System Architecture Dev. Tools & Making the First App Project Structure & File Details Application

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

藍牙網路在資訊家電的應用

藍牙網路在資訊家電的應用 崑 山 科 技 大 學 資 訊 工 程 系 專 題 製 作 報 告 ANDROID 3D 推 箱 子 遊 戲 ANDROID 3D - BOXGAME 學 生 : 黃 咸 嘉 陳 政 男 郭 撫 龍 指 導 老 師 : 李 宗 儒 中 華 民 國 一 百 一 年 五 月 i ANDROID 3D 推 箱 子 遊 戲 ANDROID 3D - BOXGAME 學 生 : 黃 咸 嘉 Student:

More information

Bus Hound 5

Bus Hound 5 Bus Hound 5.0 ( 1.0) 21IC 2007 7 BusHound perisoft PC hound Bus Hound 6.0 5.0 5.0 Bus Hound, IDE SCSI USB 1394 DVD Windows9X,WindowsMe,NT4.0,2000,2003,XP XP IRP Html ZIP SCSI sense USB Bus Hound 1 Bus

More information

9, : Java 19., [4 ]. 3 Apla2Java Apla PAR,Apla2Java Apla Java.,Apla,,, 1. 1 Apla Apla A[J ] Get elem (set A) A J A B Intersection(set A,set B) A B A B

9, : Java 19., [4 ]. 3 Apla2Java Apla PAR,Apla2Java Apla Java.,Apla,,, 1. 1 Apla Apla A[J ] Get elem (set A) A J A B Intersection(set A,set B) A B A B 25 9 2008 9 M ICROEL ECTRON ICS & COMPU TER Vol. 25 No. 9 September 2008 J ava 1,2, 1,2, 1,2 (1, 330022 ; 2, 330022) :,. Apla - Java,,.. : PAR ;Apla - Java ; ;CMP ; : TP311 : A : 1000-7180 (2008) 09-0018

More information

13 A DSS B DSS C DSS D DSS A. B. C. CPU D. 15 A B Cache C Cache D L0 L1 L2 Cache 16 SMP A B. C D 17 A B. C D A B - C - D

13 A DSS B DSS C DSS D DSS A. B. C. CPU D. 15 A B Cache C Cache D L0 L1 L2 Cache 16 SMP A B. C D 17 A B. C D A B - C - D 2008 1 1 A. B. C. D. UML 2 3 2 A. B. C. D. 3 A. B. C. D. UML 4 5 4 A. B. C. D. 5 A. B. C. D. 6 6 A. DES B. RC-5 C. IDEA D. RSA 7 7 A. B. C. D. TCP/IP SSL(Security Socket Layer) 8 8 A. B. C. D. 9 9 A. SET

More information

Microsoft Word - ch04三校.doc

Microsoft Word - ch04三校.doc 4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear

More information

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

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 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

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

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 Oracle Solaris Studio 12.2 DLight 2010 9 2 2 3 DLight 3 3 6 13 CPU 16 18 21 I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AMP Apache MySQL

More information

基于ECO的UML模型驱动的数据库应用开发1.doc

基于ECO的UML模型驱动的数据库应用开发1.doc ECO UML () Object RDBMS Mapping.Net Framework Java C# RAD DataSetOleDbConnection DataGrod RAD Client/Server RAD RAD DataReader["Spell"].ToString() AObj.XXX bug sql UML OR Mapping RAD Lazy load round trip

More information