|
|
|
|
The CFormView is a real work horse of a class. It does a great job of giving you the best aspects of the SDI document view architecture with the ease of control layouts that the dialog class has spoiled us with. Cut, Copy, Paste and Undo in a CFormView - One of the things that a CDialog derived class supplies but CFormView doesn't is cut, copy past and undo in the form's edit controls. Here's how to put that functionality back in. Precluding Resize - The default styles given to a CFormView class include a resizable window. This is not the most appropriate behavior for most applications. Here's how to fix the problem. Cut, Copy, Paste and Undo in a CFormViewWhen a CEdit is in a CFormView, you lose some of the dialog box behavior that we’ve come to know and love. Cut, Copy, Paste and Undo have to be supported directly in code. This is accomplished easily enough if not entirely in a self evident manner. First, the code has to detect that an edit event has happened. You do this through a parent of the control. Secondly, you have to handle the enable of the edit event command handler and, again, this occurs in a parent’s code. By ‘parent’, I mean either the CFormView that contains the control(s) or further up the food chain in the CMainFrame. void CXcopyDirView::OnEditCopy() One other little thing to take into account – what if the cut, copy, paste, undo is supposed to apply to a control other than a CEdit? In that case, you will have to check for the supported control type and handle in a manner appropriate to the control. Precluding ResizeOne problem that you get in CFormView that is not normally an issue with dialogs is that the wizard defaults to wrapping a frame around the dialog template that resizes. There are two places where this resize can be removed. The first place is during application creation time. Go into the Advanced section and uncheck ‘Thick Frame’. This will remove the WS_THICKFRAME style from the main window. If you’ve failed to uncheck this attribute during project creation, you can still implement after the fact by changing the window style of the mainframe before the main window is created. This is accomplished in the CMainFrame’s PreCreateWindow method. BOOL
CMainFrame::PreCreateWindow(CREATESTRUCT& cs) |
|
|