Window class definition

Source: Internet
Author: User

Next, the last frame will certainly have questions about how the two window classes came from.

G_pMainWnd = new CUMFCMainWindow (_ T ("UMFCMainWindow "));
G_pLoginWnd = new CUMFCLoginWindow (_ T ("UMFCLoginWindow "));

 

Today, I will explain the history of the window class.

# Pragma once
# Include "EasyUI. h"
# Include "EasyDialog. h"
# Include "EasyEventDelgate. h"
# Include "EasyList. h"
# Include "EasyStatic. h"
# Include "EasyProgress. h"
# Include "EasyTrayIcon. h"
# Include "EasyRadioButton. h"
# Include "EasyMenu. h"
Using namespace easyui;

Class CUMFCMainWindow
: Public CEasyDialogWinWnd // windows window base class
{
Public:
CUMFCMainWindow (LPCTSTR pszWndName); // constructor. You need to input the window name, which is the window name configured in xml and the value of the name attribute.
LPCTSTR GetWindowClassName () const; // specify a name for the window class
UINT GetClassStyle () const; // window style. null can be returned directly without any need.
// The preceding three methods must be implemented by the window class.

Bool OnCreate ();
Void OnDestory ();
// Message Processing Function
LRESULT OnWndMsg (UINT uMsg, WPARAM wParam, LPARAM lParam );

// Event processing functions (details will be given below)
DECLARE_EVENT_FUN (OnMenuOpen );
DECLARE_EVENT_FUN (OnMenuQuit );
... // Several event handler Functions
DECLARE_EASY_EVENT (CUMFCMainWindow); // This is required and is used to bind the event processing function. The parameter is the window class name.
DECLARE_EASY_CONTROL_BIND (); // This is also required to bind controls to member variables for easy access
// Note: For Event Control binding, this article will explain in detail later.

Public: // control variable
CEasyStatic * m_pStcUsrname;
CEasyList * m_pListRun;
... // Several controls
}

 

The general header file is like this. (The complete version is not provided here. If you need an example project of the complete version, you can contact me to send it via QQ or leave a mailbox)

The CPP file also has some necessary work:

BEGIN_ULTRANT_EVENT_MAP (CUMFCMainWindow) // macro starting from event binding
// Event binding. The first parameter is the window class name, the second is the control name, and the third is the macro of the event type.
/*
Supported event types
// Control event
Enum EVENT_ID
{
EVENT_SKIN_BEFORE,
EVENT_SKIN_AFTER,
EVENT_TIMER,
EVENT_BTN_LCLICK,
EVENT_BTN_RCLICK,
EVENT_BTN_LDBCLICK,
EVENT_BTN_RDBCLICK,
EVENT_CHK_SELECT,
EVENT_RADIO_SELECT,
EVENT_SLIDER_SCROLL,
EVENT_LSTBOX_SELCHANGE,
EVENT_LSTBOX_DBLCLICK,
EVENT_LST_ROW_SELCHANGE,
EVENT_LST_ITEM_SELCHANGE,
EVENT_LST_DBLCLICK,
EVENT_TREE_SEL_CHANGE,
EVENT_TREE_DBCLICK,
EVENT_MENU_SELECT,
EVENT_COMBOX_SELCHANGE,
EVENT_EDIT_TEXT_INPUT,
EVENT_EDIT_TEXT_CHANGE,
EVENT_STEP_NUM_CHANGE,
EVENT_END, // The extended event needs to start from here
};
*/
ON_ULTRANT_EVENT (_ T ("UMFCMainWindow"), _ T ("btnaddtask"), EVENT_BTN_LCLICK, & CUMFCMainWindow: OnAddTask );
ON_ULTRANT_EVENT (_ T ("UMFCMainWindow"), _ T ("btndeltask"), EVENT_BTN_LCLICK, & CUMFCMainWindow: OnDelTask );
... // Bind different events
ON_ULTRANT_EVENT (_ T ("menutray"), _ T ("start"), EVENT_MENU_SELECT, & CUMFCMainWindow: OnMenuStart );
ON_ULTRANT_EVENT (_ T ("menutray"), _ T ("stop"), EVENT_MENU_SELECT, & CUMFCMainWindow: OnMenuStop );
END_ULTRANT_EVENT_MAP () // end macro

// The control is bound to the CUMFCMainWindow class name, _ T ("UMFCMainWindow") window name
BEGIN_ULTRANT_CONTROL_BIND (CUMFCMainWindow, _ T ("UMFCMainWindow "))
// CUltrantList * pointer type member variable, m_pListRun member variable, _ T ("listrun") Control name
BIND_CONTROL (CUltrantList *, m_pListRun, _ T ("listrun "));
BIND_CONTROL (CUltrantList *, m_pListDel, _ T ("listdel "));
......
BIND_CONTROL (CUltrantStatic *, m_pStcUsrname, _ T ("stcaccount "));
BIND_CONTROL (CUltrantRadioButton *, m_pBtnListDel, _ T ("radiodel "));
END_ULTRANT_CONTROL_BIND ()

CUMFCMainWindow: CUMFCMainWindow (LPCTSTR pszWndName)
: CUltrantDialogWinWnd (pszWndName) // The Window name required for base class initialization
{
}

LPCTSTR CUMFCMainWindow: GetWindowClassName () const
{
Return _ T ("UMFCMainWindow"); // register a window class name
}

UINT CUMFCMainWindow: GetClassStyle () const
{
Return CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
}

// The CUMFCMainWindow class of the event processing function, OnSelectRunLst function name
IMP_EVENT_FUN (CUMFCMainWindow, OnSelectRunLst)
{
// Data is a parameter provided by the processing function. Different event types give different data.
_ OnSwitchLst (EM_BTN_STATUS_TWO = data-> lParam );
}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.