Example of CHTDlgBase dialog box used by HTControl control class in VC++

  • 2020-04-02 02:33:00
  • OfStack

This paper describes an MFC example of VC++ interface programming, based on the HTControl control control class of CHTDlgBase dialog box main file code. The program can complete the dynamic creation of frame form, form appearance (client and non-client area), adjust the form size, invalid child window control and other functions.

The specific implementation code is as follows:



#if !defined(__CHTDlgBase1_H__)
#define __CHTDlgBase1_H__
class AFX_CLASS_EXPORT CHTDlgBase1 : public CDialog
{
 DECLARE_DYNAMIC(CHTDlgBase1)
public:

INT_PTR CreateModalDlg(char* szName, DWORD dwStyle, DWORD dwExStyle = NULL, CWnd** pMainWnd = NULL);

INT_PTR CreateModallessDlg(char* szName, DWORD dwStyle, DWORD dwExStyle = NULL, CWnd** pMainWnd = NULL);

void InvalidateRect(LPCRECT lpRect, BOOL bInvalidateChildren = FALSE);
public:
 //The form is wide and the value is updated when the form size is changed
 int m_iWindowWidth;
 //The form is tall. The value is updated after the form's size is changed
 int m_iWindowHeight;
 //The client area of the form is wide and the value is updated when the form size is changed
 int m_iClientWidth;
 //The client area of the form is high. The value is updated after the form size is changed
 int m_iClientHeight;
 int m_iMinWindowWidth;
 int m_iMinWindowHeight;
 //The maximum width of the form, 0 by default, indicates that it is spread across the screen
 int m_iMaxWindowWidth;
 //The maximum height of the form, 0 by default, indicates that it is spread all over the screen
 int m_iMaxWindowHeight;
 //A modal dialog box that cannot be assigned to directly
 BOOL m_bModal;
 //FALSE: the form does not follow the movement of the form, can be directly assigned in the derived class
 BOOL m_bLBtnMoveWindow;
 //It cannot be assigned directly
 BOOL m_bShowWindowFlag111;
public:
 CHTDlgBase1();
 virtual ~CHTDlgBase1();
 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
 afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
 afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
 afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
 afx_msg LRESULT OnNcHitTest(CPoint point);
 afx_msg void OnClose();
 afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
 afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
 afx_msg void OnDestroy();
 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
 afx_msg void OnNcPaint();
 afx_msg BOOL OnNcActivate(BOOL bActive);
 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
 afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
 afx_msg void OnNcDestroy();
 afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
 afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
 afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
 afx_msg void OnSize(UINT nType, int cx, int cy);
 DECLARE_MESSAGE_MAP()
protected:
 virtual void OnOK();
 virtual void OnCancel();
 HICON m_hIcon;
private:
 CWnd** m_ppMainWnd;
};
#endif //!__CHTDlgBase1_H__

The example code in VC++ project development has a certain reference value, I hope to give you a certain help in the project development.


Related articles: