Basic Windows
Total Page:16
File Type:pdf, Size:1020Kb
Basic Windows Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2004 Classic Windows Processing user events via keyboard or mouse win32 API calls windows process WinMain implements message queue windows messages and implements messages message message loop routing provides win32 API application messages functionality register windows WinProc "class" implements create window message application function calls show window handling update window for get message application dispatch message windows messages controls Basic Windows 2 Basic Windows 3 Where is Example Code? CoreTechnologies/WindowsProgramming/code/BasicWindows/MinWin CoreTechnologies/WindowsProgramming/code/BasicWindows/MFCWin CSE778/Lecture1/MFCDialog CSE778/Lecture1/MFCFrameWindow CSE778/Lecture1/DataViz CSE681/code/WinFormDemo Basic Windows 4 Windows Processing Using MFC windows Microsoft Foundation Classes (MFC) messages CFrameWnd messages messages CStatic CWinApp CEdit CButton messages CApp application single global CWindow function calls functionality instance starts processing user event process via windows keyboard or mouse messages Basic Windows 5 Partial MFC Hierarchy Providing Support for Windows Programming CObject database support CDC CMenu CGdiObject CCmdTarget CFile utility classes classes CWinThread CWnd CDocument CDocItem CDocTemplate COle classes CWndApp CSingleDocTemplate CMultiDocTemplate CFrameWnd CDialog CControlBar CView CButton CComboBox CEdit other control CProperty Page CStatic CScrollBar CListBox classes Basic Windows 6 Basic Windows 7 Where is Example Code? CSE681/code/MinWin CSE778/Lecture1/BasicWindows/MFCWin CSE778/Lecture1/MFCDialog CSE778/Lecture1/MFCFrameWindow CSE778/Lecture1/DataViz CSE681/code/WinFormDemo Basic Windows 8 MFC-Based Dialog Application CWinThread CWnd Object stored locally CWinApp CDialog in CDemoApp::InitInstance() CDemoApp CDemoDlg Basic Windows 9 Basic Windows 10 Where is Example Code? CSE681/code/MinWin CSE778/Lecture1/BasicWindows/MFCWin CSE778/Lecture1/MFCDialog CSE778/Lecture1/MFCFrameWindow CSE778/Lecture1/DataViz CSE681/code/WinFormDemo Basic Windows 11 MFC-Based Frame Window Frame Window Developed with Class Wizard Does not use Document / View Architecture CWnd CFrameWnd CWinApp CChildView CMainFrame public: ... m_pMainWnd public: ... protected: void OnPaint(); BOOL GetToggle(); void OnMouseMove(UINT nFlags, CPoint point); CWizFrameWinApp void OnLButtonDow n(UINT nFlags, CPoint point); protected: public: void OnToggle(); // menu handler int OnCreate(LPCREATESTRUCT lpCreateStruct); ... int OnCreate(LPCREATESTRUCT lpCreateStruct); virtual BOOL InitInstance(); ... private: void OnAppAbout(); CChildView m_w ndView ; CStatic *m_pCStatic; CStatusBar m_w ndStatusBar; int m_TriangleX; int m_TriangleY; int m_DisplayX; private: int m_DisplayY; BOOL m_Toggle; int m_MouseX; int m_MouseY; Basic Windows 12 MFC-Based Frame Window Basic Windows 13 Where is Example Code? CSE681/code/MinWin CSE778/Lecture1/BasicWindows/MFCWin CSE778/Lecture1/MFCDialog CSE778/Lecture1/MFCFrameWindow CSE778/Lecture1/DataViz CSE681/code/WinFormDemo Basic Windows 14 MFC-BASED SDI Application CWinApp CView Dev eloper adds message map entries to associate ev ents like Dev eloper adds f unctionality to button clicks with ev ent handler OnDraw( ) and adds ev ent f unctions handlers like OnLButtonDown( ) CGdiDemoView CDialog CGdiDemoApp Attribute: CPoint pentagon[5] CPoint CPoint center local object f loat angle def ined in OnAboutDlg( ) Operation: OnDraw( ) local object OnLButtonDown(...) in InitInstance( ) CAboutDlg CFrameWnd CSingleDocTemplate CDocument Dev eloper can add menus to this object, connected through Dev eloper can add code to ev ent map and handlers to document class to manage application code in Doc or View window's data, i.e., read and CMainFrame classes write to f ile. GdiDemoDoc GdiDemo Logical Structure Basic Windows generated by appwizard, modified by developer 15 MFC-Based SDI Application resource.h GdiDemo.h af xres.rc GdiDemo.rc GdiDemo.cpp GdiDemoDoc.h GdiDemoDoc.cpp GdiDemo.rc2 af xres.h MainFrm.h stdaf x.h stdaf x.cpp MainFrm.cpp GdiDemoView.h GdiDemoView.cpp GdiDemo Physical Structure generated by appwizard Basic Windows 16 Basic Windows 17 Where is Example Code? CSE681/code/MinWin CSE778/Lecture1/BasicWindows/MFCWin CSE778/Lecture1/MFCDialog CSE778/Lecture1/MFCFrameWindow CSE778/Lecture1/DataViz CSE681/code/WinFormDemo Basic Windows 18 WinForm-Based Application ContainerControl Form myForm Basic Windows 19 WinForm-Based Application Basic Windows 20 Where is Example Code? CSE681/code/MinWin CSE778/Lecture1/BasicWindows/MFCWin CSE778/Lecture1/MFCDialog CSE778/Lecture1/MFCFrameWindow CSE778/Lecture1/DataViz CSE681/code/WinFormDemo Basic Windows 21 End of Presentation.