WTL architecture (4)

zhaozj2021-02-16  45

WTL architecture

The dialog ATL's dialog supports the universal dialog, which has added a universal dialog package. Even joining the input verification and callback functions for the dialog. For example, you want to change the Year Open dialog in the user. There is actions when the folder is, then you should inherit a class from cfiledialogimpl <> to implement onfolderchange ():

class CMyFileDialog: public CFileDialogImpl {public: CMyFileDialog (BOOL b): CFileDialogImpl (b) {} void OnFolderChange (LPOFNOTIFY lpon) {char strFolder [MAX_PATH]; if (GetFolderPath (strFolder, sizeof (strFolder)) > 0) {MessageBox (Strfolder);}}};

When the path of the folder changes, CFiledialogIMPL <> calls onfolderchange (). This function uses the base class getFolderPath () to get a new path. Control WTL provides package classes for all Win32 and General Controls, including Windows 2000 new join Although only simple packaging, they make these controls easier access. For example, can you remember to read the message of the current selected item from the list view and the parameters that need to pass? (In fact, you need to send two messages, one is the index of the selected item, the other is to read its text.) The author of the WTL has completed these annoying work for you, providing a simple package function for You use it. There are two ways to use these controls. If you have a control in your dialog, you can attach the HWnd of the control to a package object, access the control using the package class. This method simplifies you read Write the control data and handle the code for the Notification message. Additional usage is to add these classes to your view class in the inheritance hierarchy: Class CMYVIEW: PUBLIC CWINDOWIMPL This means that CWindowImpl "is from CListBox inheritance Therefore, the created window will be a list box (because the name of the window class is obtained by calling clistbox :: getWndclassName (). In addition, the ATL window mechanism will type this window, will send it to the message route Your message map. It retains the old window function, so that the message you have not processed will be processed by the old window function. When your view class is inherited from the control class, WTL will use this technology. NOTIFICATION message and subclass of this topic, one thing is worth pointing, that is, when the event occurs, most of the window controls send the Notification message to their parent windows. Let you have a window to handle these Notification messages Category An existing control window (or subcatencies an existing class, then establish an instance), so that the message is much better before the control. For example, you want to handle the Click event you need to do. Just Handle BN_Clicked Notification. It will send you a window class by the button. Another way is to process Click messages from the CContainedWindow <> subclass button. I said this is because a well-known ATL advocacy gives me one This is done in the code. His code acquired a simple button Click event is 3 to 4 times that of others, because he is a button control, rather than a simple handling BN_Clicked Notification.WTL is also available. Some new controls, there is no peer in Win32. You have seen a - Command Bar, in fact, there are other very useful classes:

Class Description CBitmapButton This is a button with bitmap replacement title. You can provide an Image List, which contains the button in normal, invalid, push and mouse falling on the button on the button. ChyperLink lets you build a Static control, it On behalf of a HyperLink, the default web browser opens this link when the user clicks on it. Cwaitcursor is just in its constructor to change the mouse icon into a wait state, and restore in the destructor .cchecklistViewCtrl at each There is a check box.cmultipaneStatusBarctrl (unreasonable continuation) on the edge of the List Box.cmultipaneStatusBarctrl (unreasonable)

转载请注明原文地址:https://www.9cbs.com/read-27301.html

New Post(0)