MFC pointed foot (2)

zhaozj2021-02-16  57

class CDialog: public CWnd {DECLARE_DYNAMIC (CDialog) // Modeless constructpublic: CDialog (); BOOL Create (LPCTSTR lpszTemplateName, CWnd * pParentWnd = NULL); BOOL Create (UINT nIDTemplate, CWnd * pParentWnd = NULL); BOOL CreateIndirect (LPCDLGTEMPLATE lpDialogTemplate , CWnd * pParentWnd = NULL, void * lpDialogInit = NULL); BOOL CreateIndirect (HGLOBAL hDialogTemplate, CWnd * pParentWnd = NULL); // Modal constructpublic: CDialog (LPCTSTR lpszTemplateName, CWnd * pParentWnd = NULL); CDialog (UINT nIDTemplate, CWnd * pParentWnd = NULL); BOOL InitModalIndirect (LPCDLGTEMPLATE lpDialogTemplate, CWnd * pParentWnd = NULL, void * lpDialogInit = NULL); BOOL InitModalIndirect (HGLOBAL hDialogTemplate, CWnd * pParentWnd = NULL); // Attributespublic: void MapDialogRect (LPRECT lpRect) const; void SetHelpID (UINT nIDR); // Operationspublic: // modal processingvirtual int DoModal (); // support for passing on tab control - use 'PostMessage' if neededvoid NextDlgCtrl () const; void PrevDlgCtrl () const; void GotoDlgCtrl (CWnd * pwndctrl); // DEF ault button accessvoid SetDefID (UINT nID); DWORD GetDefID () const; // terminationvoid EndDialog (int nResult); // Overridables (special message map entries) virtual BOOL OnInitDialog (); virtual void OnSetFont (CFont * pFont); protected: virtual void OnOK (); virtual void OnCancel (); // Implementationpublic: virtual ~ CDialog (); # ifdef _DEBUGvirtual void AssertValid () const; virtual void Dump (CDumpContext & dc) const; #endifvirtual BOOL PreTranslateMessage (MSG * pMsg); virtual BOOL OnCmdMsg (UINT nID, int nCode, void * pExtra, AFX_CMDHANDLERINFO * pHandlerInfo); virtual BOOL CheckAutoCenter (); protected: UINT m_nIDHelp; // Help ID (0 for none, see HID_BASE_RESOURCE) // parameters for 'DoModal'

LPCTSTR m_lpszTemplateName; // name or MAKEINTRESOURCEHGLOBAL m_hDialogTemplate; // indirect (m_lpDialogTemplate == NULL) LPCDLGTEMPLATE m_lpDialogTemplate; // indirect if (m_lpszTemplateName == NULL) void * m_lpDialogInit; // DLGINIT resource dataCWnd * m_pParentWnd; // parent / owner windowHWND m_hWndTop; // top level parent window (may be disabled) #ifndef _AFX_NO_OCC_SUPPORT_AFX_OCC_DIALOG_INFO * m_pOccDialogInfo; virtual BOOL SetOccDialogInfo (_AFX_OCC_DIALOG_INFO * pOccDialogInfo); # endifvirtual void PreInitDialog (); // implementation helpersHWND PreModal (); void PostModal (); BOOL CreateIndirect (LPCDLGTEMPLATE lpDialogTemplate, CWnd * pParentWnd, void * lpDialogInit, HINSTANCE hInst); BOOL CreateIndirect (HGLOBAL hDialogTemplate, CWnd * pParentWnd, HINSTANCE hInst); protected: // {{aFX_MSG (CDialog) afx_msg LRESULT OnCommandHelp (WPARAM wParam, LPARAM lParam) AFX_MSG LRESULT OnHELPHITTEST (WPARAM WPARAM, LPARAM LPARAM); AFX_MSG LRESULT HANDLINITDIALOG (WPARAM, LRESULT HANDLESETFONT (WPARAM, LPA RAM); //}} AFX_MSG # ifndef _AFX_NO_GRAYDLG_SUPPORTafx_msg HBRUSH OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor); # endifDECLARE_MESSAGE_MAP ()}; 1: // Modeless constructpublic: CDialog ();

Oh, huh, it's seen from this cdialog is a ready class, very good, I like,

2:

Bool create (LPCTSTR LPSZTEMPLATENAME, CWND * PPARENTWND = NULL); BOOL CREATE (UINT NidTemplate, CWND * PParentWnd = Null);

2 constructor, is a resource label, a resource pointer. It belongs to the overload function, in addition, the default parameters are used. C language list.

Bool CreateIndirect (LPCDLGTEMPLATE LPDIALOGTEMPLATE, CWND * PPARENTWND = NULL, VOID * LPDIALOGINIT = NULL); BOOL CREATEINDIRECT (HGLobal HDialogTemplate, CWnd * PparentWnd = Null);

Indirect creation. Use the parameters such as global handle, is this member function a "factory method"? ? // Modal constructpublic: CDialog (LPCTSTR lpszTemplateName, CWnd * pParentWnd = NULL); CDialog (UINT nIDTemplate, CWnd * pParentWnd = NULL); BOOL InitModalIndirect (LPCDLGTEMPLATE lpDialogTemplate, CWnd * pParentWnd = NULL, void * lpDialogInit = NULL); BOOL InitModalIndirect (Hglobal HDialogTemplate, CWND * PParentWnd = NULL);

The Modal dialog box is created with a different constructor with a different constructor. The CDIALOG class is a class that is directly dealing with the user, once again exposes the implementation details of CDIALOG. The user has to deal with such details. Hey, MFC is ...., if it is my own MFC program, it must be packaged again for CDIALOG classes.

3: void nextdlgctrl () const; void prevdlgctrl () const; void gotodlgctrl (cwnd * pwndctrl); // default button accessvoid setdefic (uint nid); dword getDefid () const;

From these functions, CDIALOG is used as a container of sub-controls, which is bound to form a tight coupling relationship with subcreens. How to relieve their tight coupling if I have a re-encapsulated MFC?

4: I don't want to see this code, I really don't have anything to stir up,: (, just for Win API simple packaging, simple!, Also make people pay attention to unnecessary realistic details!

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

New Post(0)