COP4226, Topics for the Final Exam

Here are topics from the first half that will be needed for the test

  • Windows Messages
  • OnDraw
  • Message mapping
  • Mapping Modes
  • GDI classes
  • Selecting a GDI object into the device context
  • GetTextMetrics
    • tmExternalLeading, tmHeight, tmInternalLeading
  • Device Context member functions
  • Dialogs: modal vs modeless
  • Control classes in dialogs
  • Create a class for a dialog
    • Create member variables for each control
    • Create message maps for buttons
  • Connecting the view and the dialog
    • UpdateData(TRUE) to get dat from controls to the class
    • UpdateData(FALSE) to get the data from the class to the controls
  • Identifying controls
    • GetDlgItem(IDC_DATA)
    • pWnd->GetDlgCtrlID()
  • User defined messages
    • PostMessage - on queue
    • SendMessage - immediate
    • Add message mapping
      • Begin(.cpp): ON_MESSAGE(WM_GOODBYE, OnGoodbye)
      • Declare (.h): afx_msg LRESULT OnGoodbye(WPARAM wParam, LPARAM lParam)
  • Modeless Dialog
    • Overload constructor with pointer to view, so dialog knows which view gets the message
    • Overload the Create function. Call the base class Create with the IDD of the Dialog
    • DestroyWindow to kill the dialog
    • Override the OnOK and OnCancel handlers to post the message to the view
    • Create dialog in constructor, delete it in the destructor

These are the topics from the second half

  • Chapter 11: Bitmaps - Ex11a
    • Bitmaps are like other GDI objects
    • Display surface is bitmap associated with device context
    • Must copy other bitmaps into the display bitmap
      Create bitmap: CBitmap bitmap;
      Create dc: CDC dcMemory;
      Load bitmap: bitmap.LoadBitmap(IDB_REDBLOCKS);
      Select bitmap: dcMemory.SelectObject(&bitmap);
      Copy bitmap: pDC->BitBlt(100, 100, 54, 96, &dcMemory, 0, 0, SRCCOPY);
    • To map pixels exaclty, use StretchBlt
      CSize(54, 96);
      pDC->DPtoLP(&size);
      pDC->StretchBlt(100, 100, size.cx, -size.cy, &dcMemory, 0, 0, 54, 96, SRCCOPY);
    • Improving Display for Animation: Ex11b
      • Constructor: new CDC, new CBitmap
      • Destructor:   delete m_pBitmap, delete m_pdcMemory
      • OnInitialUpdate: Create DC, Create rectangle for entire page (use sizeTotal), Change to DP, Set size of bitmap to entire page, Set Mapping Mode for m_pdcMemory
      • OnPaint: Get clip box for dc, Select bitmap into memory, save old one to restore it, Set update region for memory, Get background brush, Select brush into memory, save old one, Fill memory with syscolo
      • OnDraw(memory):
      • Transfer bitmap to dc
      • Select old brush and bitmap
      • Use InvalidateRect FALSE
    • Bitmaps for Push Buttons - Ex11d
      • Add three buttons: Check Owner Draw
      • import three bitmaps, give IDs that are strings
        • COPYU : up, corresponds to the text on the button
        • COPYD : down
      • Dialog header: Add CBitmapButton m_editCopy
      • OnInitDialog: VERIFY(m_editCopy.AutoLoad(IDC_BUTTON1, this));
      • Focus: F, Disabled: X
  • Chapter 12: Threads
    • Ex12a:
      • Disable start button: GetDlgItem(IDC_START)->EnableWindow(FALSE)
      • Busy loop: Use PeekMessage instead of GetMessage in "if"
      • Timer function: calculate pos as percent
      • OnCancel: test count
      • Call Dialog
      • include header in view
    • Ex12b: Multithreaded Programming
      • Starting a thread: AfxBeginThread(proc, parm, prior)
      • global count, make it volatile
      • global UINT ComputeThreadProc(LPVOID pParam)
      • InterlockedIncrement
      • ::PostMessage and return 0
      • Book error: OnTimer must use global
      • User message: in dialog
        • #define message
        • DECLARE: afx_msg LRESULT proc(wparam, lparam)
        • BEGIN: ON_MESSAGE(message, proc)
    • Ex12c: Events
      • #include <afxmt.h>
      • CEvent g_eventStart;
      • CEvent g_eventKill;
      • ::WaitForSingleObject
        • INFINITE
        • 0: WAIT_OBJECT_0
      • OnInitDlg: start thread
      • OnStart: signal start
      • OnCancel: signal kill
  • Chapter 13: Menus
    • Main Frame: title bar, menu bar, client area
    • Client Area: toolbar, status bar, view window
    • Menus
    • keyboard accelerators
    • command processing
      • when menu is clicked
      • BEGIN_MESSAGE_MAP: OnCommand(IDM_ZOOM, OnZoom)
      • DECLARE_MESSAGE_MAP: afx_msg OnZoom()
    • update command
      • pointer to menu item
      • before window is displayed
        • pCmdUI->SetCheck(t or f)
        • pCmdUI->Enable(t or f)
    • Command message order: View, Doc, SDI, App
    • Ex13a
      • Create menu
      • Doc gets edit message
      • View gets transfer message
      • Doc has m_strText
      • View gets doc to access text
      • RichEditCtrl: GetModify, SetModify
      • CRichEditCtrl: mixed format, large quantity
      • WM_CREATE and WM_SIZE to resize the control
      • CREATE: view doesn't exist yet: rect is 0
      • ONSIZE: set window to client rect
      • OnNewDocument
      • pDoc->m_strText: access document
  • Chapter 13: Property Sheets
    • layer several dialogs
    • create dialogs in resource editor
    • create classes in Class Wizard
    • change files to property.h, .cpp
    • define user message to notify view for Apply
    • global pointer to view for Apply
    • OnCommand
    • OnApply
    • member var for each page
    • Page4: OnInitDialog to initialize spin
    • CFontSheet: AddPage(&m_page1);
    • Ex13b: View class
      • CFontSheet m_sh; BOOL m_bDefault
      • Format(CHARFORMAT &cf): think of LOGFONT
      • User Message
      • OnCreate
        • CHARFORMAT cf;
        • Format(cf);
        • m_rich.SetDefaultFormat(cf);
      • Constructor
        • initialize page member data
      • OnFormatDefault, OnFormatSelection
        • set title
        • set default
        • do modal
      • OnUpdateSelection
        • long nStart, nEnd;
        • m_rich.GetSel(nStart, nEnd);
        • pCmdUI->Enable(nStart != nEnd);
      • OnUserApply
        • m_rich.SetSelectionCharFormat(cf);
        • m_rich.SetDefaultCharFormat(cf);
      • Format: set mask, set values
  • Chapter 13: CRichEditCtrl
    • use CHARFORMAT to control
    • m_rich.SetSelectionCharFormat(cf);
    • m_rich.SetDefaultFormat(cf);
    • m_rich.GetSel(nStart, nEnd);
  • Chapter 13: CMenu - create a context menu
    • GetMenu
    • LoadMenu
    • Popup menu
      • create in resource
      • Load
      • GetSubMenu(0)->TrackPopupMenu(flags, x, y, this)
  • Chapter 13: Extended commands handler
    • ON_COMMAND_EX: return TRUE or FALSE
  • Chapter 14: Toolbars - Ex14a
    • Update Command UI
    • ToolTips \n
    • Ex14a
  • Chapter 14: Status Bar
    • ID_SEPARATOR
    • String Table for indicators
    • Create new or use default
      • AFX_IDW_STATUS_BAR gets the menu info messages
      • Change View menu if use own
      • CBRS_BOTTOM
    • Ex14b
      • OnUpdate
        • ::GetKeyState
      • OnViewStatusBar
        • ShowWindow, GetStyle
      • OnMouseMove
        • write to panes
        • SetPaneText(0, str);
        • SetPaneInfo(0, 0, 0, 50);
        • SetPaneInfo(1, 0, SBPS_STRETCH, 50);
          • SBPS_NORMAL, POPOUT, STRETCH, NOBORDERS, DISABLE
  • Chapter 16: Separating the Document from the View
    • Doc::UpdateAllViews
    • View::OnUpdate
    • View::OnInitialUpdate
      • start, new, open
      • base: calls OnUpdate
      • override: call base OnInitialUpdate, or class OnUpdate
    • Doc::OnNewDocument
      • document first created or File New
      • call base class in override
      • initialize data members
    • One View Application
      • doc members public (or make view a friend)
      • view OnInitialUpdate - update view to reflect data
      • OnDraw accesses doc directly, as well as commands
    • CFormView
      • scroll view window is dialog
      • No OnInitDlg, OnOK, OnCancel
      • Member functions do not call UpdateData, you must
    • Diagnostic Dumping
      • DECLARE_DYNAMIC, IMPLEMENT_DYNAMIC give class name
    • Ex16a
      • UpdateData updates controls in view
      • View Constructor: set init value
      • View OnInitialUpdate: send to controls
      • Add student to view.h
      • Dump on destruction
    • CObject
      • AddHead, AddTail: position of new element
      • RemoveTail, RemoveHead: object*
      • GetTail, GetHead: object*
      • GetNext, GetPrev: iterator, object*
      • trick to keep position at current
      • GetAt: position, return object*
      • SetAt: position, object*
    • CTypedPtrList template
      • template <CObList, CAction>
    • Dump
      • SetDepth(1) to expand next level of pointers
    • Ex16b
      • DeleteContents: new, open
      • Accessor function for list
      • afxDump.SetDepth(1) in Doc constructor
      • Dump list in Dump
      • Since it is a list of pointers, then must remove  each pointer and delete it.
      • View
        • ClearEntry, InsertEntry, GetEntry
        • menu handlers
  • Chapter 17: Serialization
    • Serializing is like Dump
    • DECLARE_SERIAL, IMPLEMENT_SERIAL (also does dynamic)
    • CArchive
      • IsStoring: ar << nInt
      • Call serialize for embedded objects
      • pointers can be inserted directly
    • CSingleDocTemplate
      • RUNTIME_CLASS to create dynamically
      • Resource string for file extension
    • OnFileNew
      • OnNewDocument
      • DeleteContents
      • OnInitialUpdate
    • OnFileOpen
      • OnOpenDocument
      • DeleteContents
    • Dirty Flag
      • SetModifiedFlag
      • IsModified
    • Ex17a
      • Edit the IDR_MAINFRAME string, change to hw2
      • Add serialize to CStudentDoc
      • DeleteContents
    • Double-click (modify InitInstance)
      • EnableShellOpen();
      • RegisterShellFileTypes(TRUE);
    • Drag and drop
      • m_pMainWind->DragAcceptFiles();
      • after processing command line
      • Look in registry: if already a file association, then it is ignored
  • Chapter 19: Print and Print Preview
    • Wizard
      • Adds Print and Print Preview to File menu
      • Maps File Print and Print Preview to base class
      • virtual functions: OnPreparePrinting, OnBeginPrinting, OnEndPrinting
    • Printer device context
    • CView::OnPrint - add headers and footers
    • CView::OnPrepareDC - mapping mode
      • CPrintInfo - only if printing
        • m_bContinuePrinting
      • CDC::IsPrinting
    • OnPreparePrinting
      • Set page numbers
        • CPrintInfo::SetMinPage
        • CPrintInfo::SetMaxPage
      • Before print dialog
    • OnBeingPrinting
      • After print dialog
      • Create GDI objects
    • OnEndPrinting - delete GDI objects
    • OnPrepareDC - called for each page
    • OnPrint - called for each page
    • Use pInfo to get the printable rectangle
    • CArray class - can use []
      • SerializeElements to serialize entire list
    • Ex19b
      • bubbles and text
  • Chapter 20: Multiple Views
    • Splitter Windows
      • Dynamic - one view: Ex20a
      • Static - multiple views, static placement: Ex20b
    • Ex20c - switching views without splitters
      • Add two options to the View menu
      • CMainFrame
        • ennum for views
        • SwitchToView(enum)
      • Get old view
      • Get new view
        • if no dialog item, then construct view
        • dialog item is set after switch
      • Context
        • Connects document to view
        • Set to current document
      • Create new view, using context
      • OnInitialUpdate for new view
      • SetActiveView(pNewActiveView)
      • Show and Hide  new and old
      • Set DlgCtrlID for new and old
      • RecalcLayout
    • Runtime class
      • Can test the type of window that a pointer points to
      • pView->GetRuntimeClass() == RUNTIME_CLASS(CStringView)
      • GetActiveView()->IsKindOf(RUNTIME_CLASS(CStringView): if yes, then can cast general pointer to specific pointer
  • Chapter 18: Reading and Writing MDI
    • MultiDocTemplate
    • CMDIMainFrame
      • Create mainframe
      • Two menus
    • CMDIChildFrame: CChildFrame
    • Creating an empty document - OnFileNew
      • Construct document object
      • Construct Child Frame window, replace menus
      • Construct view object and view window
      • Connect view, doc, mainframe
      • OnNewDocument
      • OnInitialUpdate
      • ActivateView
    • Document is destroyed when done - no DeleteContents
    • Multiple Doc Templates
      • template list box
      • OpenNewDocument
    • Explorer Launch and Drag and Drop
    • Ex18a
      • No empty document on start
  • Chapter 20: Multiple View MDI Application
    • Ex20d - multiple view class
      • create pointers to each doc template
      • add both view classes to App
      • select from menu
      • use duplicated menu for each template or create new
      • ExitInstance: Do not need to delete templates
      • NewHex
      • Get active child & document
      • Get pointer to new template
      • InitialUpdateFrame
  • Chapter 23: Programs without document or view classes
    • Dialog based
      • Calculator
      • InitInstance - return FALSE
    • SDI
      • Uncheck Doc/View
      • Edit OnPaint
      • Menu, Icon, Close Window, Toolbar and Status Bar
    • MDI