200 likes | 322 Views
Chapter 7. The Modeless Dialog and Windows Common Dialogs. Modeless Dialogs.
E N D
Chapter 7 The Modeless Dialog and Windows Common Dialogs
Modeless Dialogs • In the Microsoft Foundation Class (MFC) Library version 6.0, modal and modeless dialogs share the same base class, CDialog, and they both use a dialog resource that you can build with the dialog editor. If you're using a modeless dialog with a view, you'll need to know some specialized programming techniques.
Creating Modeless Dialogs • For Modal Dialogs • Use CDialog Constructor • Call DoModal Auto Destroy on Return • For Modeless Dialogs • Use CDialog Constructor • Call CDialog::Create Function • You Must track the ID, Messages etc. • You must provide for the Destructor call
User-Defined Messages • The Dialog must send the message to the application • Two Options • CWnd::SendMessage • Immediate call to Message Handler • PostMessage • Delayed call to Message Handler it uses the Windows Message Queue
Dialog Ownership • Being a Pop-Up style window, Windows thinks the MainFrame is the owner • You must provide pointer to provide the message path back to the view class
Example 7c • A simple Dialog with one edit control and, OK and Cancel buttons
Windows Common Dialogs • CColorDialog • CFileDialog • CFindReplaceDialog • CPageSetupDialog • CFontDialog • CPrintDialog • CPrintDialog
CFileDialog Example • Using CFileDialog Directly CFileDialog dlg(TRUE, "bmp", "*.bmp"); if (dlg.DoModal() == IDOK) { CFile file; VERIFY(file.Open(dlg.GetPathName(), CFile::modeRead)); }
CFileDialog • Nested Dialogs • Yes you can Nest the Dialogs • Create a dialog with a hole in it. • Example 7b File Delete
Chapter 8 Common Controls • Other controls included in a DLL named COMCTL32.DLL • Example 8a
Common Controls • Example 8b
Quick look at 9 and 10 • Active X • Small controls • Child windows • IE 4 Common Controls • IP Address • Extended Combo Box • May need to include COMCTL32.DLL to dist. Your apps
Memory Managment Chapter 10
Processes • 4 Gig Memory Space • Top 1/2 is shared in win 95 • Bottom 1/2 stacks, heaps global var, exe, and DLL
Virtual Memory • 4K units (page) • Code or data • Swapped if not used • CR3 Register used to switch processes using Dir Page
Functions for memory • VirtualAlloc • Dynamic memory usage • May not be used by most Apps • Most use the C Run Time or Windows Heap • Reserved • Committed
Memory Functions cont. • GlobalAlloc win16 • Fixed • Moveable • C++ new delete • Supplied by CRT • Reserved in 4M Regions • Committed in 64K Blocks (16 pages)
More • Memory Mapped Files (DIB) • _heapmin used if program runs and runs and runs • Use of const • Var Data • Const Data • Program space (like ROM)