|
|
|
|
WindowGet Rid of ‘Untitled’ in the Window CaptionWhen a document has no current name, it is the default behavior of an application is to indicate that to the user by appending ‘Untitled’ to the caption bar. When a lack of a document name is the normal case for an application then the ‘Untitled’ nomenclature is inappropriate. Fortunately, there is a way to tell Windows to not do this. Before the main window is created, the application is given a chance to change the style settings that will be used with the window. One of those style bits is associated with appending the document name to the caption. If that particular style bit is removed then the document name won’t be appended to the application caption. BOOL
CMainFrame::PreCreateWindow(CREATESTRUCT& cs) Save and restoreOne really nice thing a user likes to see is for an application to start up in the same location it last ran in. This can be accomplished by reading the application’s positional data on shut down and saving that data. The next time the application starts up, it checks to see if it has any position data saved in the registry. If so, the previous position is reasserted and the application picks up where it last left off. In the app's Hextern bool g_bSizeAsserted; In the app's cppbool g_bSizeAsserted = false; In MainFrm.cppIn the OnCreate()
// Move the window to its last known size. In the OnClose()
void CMainFrame::OnClose() In the form view:
void CMyView::OnInitialUpdate() Setting min/max sizeSometimes, it makes sense to allow the user to change the application’s window size but to limit that size to some minimal and maximum size. Lets take the example of a CFormView application where we want to limit the smallest size that the window can be. There’s a windows message that is issued before a size or movement message. Intercept this message by letting the class wizard insert a handler in the main window for a WM_GETMINMAXINFO message. Let the minimal size be determined by the smallest size that we want to let our dialog template based form view to display as. During the time that the view is initializing, get the size of the appliction’s window and use that width and height as the minimal size value. We have to do the entire application size, not just the client area. { Windows will call into the application to get its min and max allowable sizes before any movement message is processed. However, we only want to handle these when we’ve established a valid minimal size so we have to add a conditional to detect when the minimal size value is valid. void
CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI) |
|
|