Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Basic Windows

Jim Fawcett
21 May 2003
Classic Windows Processing
user events
via
keyboard or mouse

win32 API calls

windows

implements process
WinMain
message queue windows
messages and messages
implements
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?

 Lecture1/BasicWindows/MinWin
 Lecture1/BasicWindows/MFCWin
 Lecture1/Dialog
 Lecture1/MFCFrameWindow
 Lecture1/DataViz
 Lecture1/WinForms

Basic Windows 4
Windows Processing Using MFC

windows

messages

messages
Microsoft Foundation Classes

messages
(MFC)
CFrameWnd

CStatic

messages
CWinApp
CEdit

CButton

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
CObject
Windows Programming

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?

 Lecture1/BasicWindows/MinWin
 Lecture1/BasicWindows/MFCWin
 Lecture1/Dialog
 Lecture1/MFCFrameWindow
 Lecture1/DataViz
 Lecture1/WinForms

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?

 Lecture1/BasicWindows/MinWin
 Lecture1/BasicWindows/MFCWin
 Lecture1/Dialog
 Lecture1/MFCFrameWindow
 Lecture1/DataViz
 Lecture1/WinForms

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?

 Lecture1/BasicWindows/MinWin
 Lecture1/BasicWindows/MFCWin
 Lecture1/Dialog
 Lecture1/MFCFrameWindow
 Lecture1/DataViz
 Lecture1/WinForms

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 appw izard
Basic Windows 16
Basic Windows 17
Where is Example Code?

 Lecture1/BasicWindows/MinWin
 Lecture1/BasicWindows/MFCWin
 Lecture1/Dialog
 Lecture1/MFCFrameWindow
 Lecture1/DataViz
 Lecture1/WinForms

Basic Windows 18
WinForm-Based Application

ContainerControl

Form

myForm

Basic Windows 19
WinForm-Based Application

Basic Windows 20
Where is Example Code?

 Lecture1/BasicWindows/MinWin
 Lecture1/BasicWindows/MFCWin
 Lecture1/Dialog
 Lecture1/MFCFrameWindow
 Lecture1/DataViz
 Lecture1/WinForms

Basic Windows 21
End of Presentation

You might also like