http://blog.csdn.net/zengraoli/article/details/9993153
2013-08-16 00:08 3289 People read Comments (2) favorite reports
Directory (?) [+]
1, first look at the Crichlistwnd here
is no longer inherited from Cwindowwnd.
Classcrichlistwnd:publicwindowimplbase
From Windowimplbase, you can see that there are three abstract functions:
Virtualcduistringgetskinfolder () = 0;
Virtualcduistringgetskinfile () = 0;
Virtuallpctstrgetwindowclassname (void) const=0;
These are simple, just return a fixed string
2, see Windowimplbase[CPP]View Plaincopyprint?
- Class Uilib_api Windowimplbase
- : Public Cwindowwnd
- , Public Cnotifypump
- , Public Inotifyui
- , Public Imessagefilterui
- , Public Idialogbuildercallback
- {
- ......
- }
This class is actually implemented Cwindowwnd, Inotifyui, that is, a form and message, so he contains virtualvoidnotify (TNOTIFYUI&MSG);
But here again inherits the Cnotifypump, so here the notify can realize this:
[CPP]View Plaincopyprint?
- void Windowimplbase::notify (tnotifyui& msg)
- {
- return Cnotifypump::notifypump (msg);
- }
Notifypump is basically traversing all the virtual windows to deliver the message.
The following code lists the more important functions of Crichlistwnd:
[CPP]View Plaincopyprint?
- Class Crichlistwnd: Public windowimplbase
- {
- Public
- virtual void OnFinalMessage ( HWND);
- virtual void Notify (Tnotifyui &msg);
- Virtual LRESULT onmousewheel ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
- Virtual LRESULT onsyscommand ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
- virtual void Initwindow ();
- Virtual LRESULT onmousehover ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
- Virtual LRESULT OnChar ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
- Dui_declare_message_map ()
- virtual void OnClick (tnotifyui& msg);
- virtual void onselectchanged (Tnotifyui &msg);
- virtual void Onitemclick (Tnotifyui &msg);
- };
Because the Windowimplbase class implements the Handlemessage in the Cwindowwnd, we need to rewrite some important message events.
You can see the OnCreate () in Windowimplbase:
[CPP]View Plaincopyprint?
- LRESULT windowimplbase::oncreate (UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled)
- {
- ......
- Initwindow ();
- return 0;
- }
So we need to rewrite the Initwindow.
In Initwindow, the control properties for each control and XML correspond:
[CPP]View Plaincopyprint?
- Initialized events
- void Crichlistwnd::initwindow ()
- {
- M_PCLOSEBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("closebtn"));
- M_PMAXBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("maxbtn"));
- M_PRESTOREBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("restorebtn"));
- M_PMINBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("minbtn"));
- }
This completes the initialization, and the window is up.
This demo, is used to the virtual page, that is, CPage1, if not used, his message will go back to Crichlistwnd to be processed, but if the CPage1 processing the message, Crichlistwnd do not do the processing
Let's take a look at the message CPage1 is dealing with:
The same Crichlistwnd message
When the page occurs onclick or Onitemclick, the virtual page has been hung CPage1, then the CRICHLISTWND message is invalid
3, about the virtual page cpage
To hang a virtual page like this:
[CPP]View Plaincopyprint?
- Crichlistwnd::crichlistwnd (void)
- {
- M_page1.setpaintmagager (&m_paintmanager);
- Addvirtualwnd (_t ("Page1"), &m_page1);
- }
[CPP]View Plaincopyprint?
- Crichlistwnd::~crichlistwnd (void)
- {
- Removevirtualwnd (_t ("Page1"));
- }
See here is a macro (because inheriting the cnotifypump can be used this way):
[CPP]View Plaincopyprint?
- Dui_begin_message_map (CPage1, Cnotifypump)
- Dui_on_msgtype (Dui_msgtype_click, OnClick)
- Dui_on_msgtype (dui_msgtype_selectchanged, onselectchanged)
- Dui_on_msgtype (Dui_msgtype_itemclick, Onitemclick)
- Dui_end_message_map ()
This is the entire message map, the surface we care about these message functions, the same can be found in the UIDefine.h other message types of events
There is no code in void Cpage1::onitemclick (Tnotifyui &msg), it is necessary to manually glue the portion of the Crichlistwnd (or remove the part that hangs the virtual page)
This function does not execute until we click on the progress bar.
The same mouse hover over the action button will execute the function crichlistwnd::onmousehover
And the rest of the demo is going to be the same thing.
- A simple example of a Duilib Directui library is included in the previous article Listdemo
- The next 116 It tips for efficient people
-
Top
-
4
-
Step
A simple example of the Duilib Directui library Richlistdemo