A simple example of the Duilib Directui library Richlistdemo

Source: Internet
Author: User

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?
    1. Class Uilib_api Windowimplbase
    2. : Public Cwindowwnd
    3. , Public Cnotifypump
    4. , Public Inotifyui
    5. , Public Imessagefilterui
    6. , Public Idialogbuildercallback
    7. {
    8. ......
    9. }

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?
    1. void Windowimplbase::notify (tnotifyui& msg)
    2. {
    3. return Cnotifypump::notifypump (msg);
    4. }

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?
  1. Class Crichlistwnd: Public windowimplbase
  2. {
  3. Public
  4. virtual void OnFinalMessage ( HWND);
  5. virtual void Notify (Tnotifyui &msg);
  6. Virtual LRESULT onmousewheel ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
  7. Virtual LRESULT onsyscommand ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
  8. virtual void Initwindow ();
  9. Virtual LRESULT onmousehover ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
  10. Virtual LRESULT OnChar ( UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled);
  11. Dui_declare_message_map ()
  12. virtual void OnClick (tnotifyui& msg);
  13. virtual void onselectchanged (Tnotifyui &msg);
  14. virtual void Onitemclick (Tnotifyui &msg);
  15. };

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?
    1. LRESULT windowimplbase::oncreate (UINT umsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled)
    2. {
    3. ......
    4. Initwindow ();
    5. return 0;
    6. }


So we need to rewrite the Initwindow.

In Initwindow, the control properties for each control and XML correspond:

[CPP]View Plaincopyprint?
  1. Initialized events
  2. void Crichlistwnd::initwindow ()
  3. {
  4. M_PCLOSEBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("closebtn"));
  5. M_PMAXBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("maxbtn"));
  6. M_PRESTOREBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("restorebtn"));
  7. M_PMINBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("minbtn"));
  8. }


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?
    1. Crichlistwnd::crichlistwnd (void)
    2. {
    3. M_page1.setpaintmagager (&m_paintmanager);
    4. Addvirtualwnd (_t ("Page1"), &m_page1);
    5. }


[CPP]View Plaincopyprint?
    1. Crichlistwnd::~crichlistwnd (void)
    2. {
    3. Removevirtualwnd (_t ("Page1"));
    4. }


See here is a macro (because inheriting the cnotifypump can be used this way):

[CPP]View Plaincopyprint?
    1. Dui_begin_message_map (CPage1, Cnotifypump)
    2. Dui_on_msgtype (Dui_msgtype_click, OnClick)
    3. Dui_on_msgtype (dui_msgtype_selectchanged, onselectchanged)
    4. Dui_on_msgtype (Dui_msgtype_itemclick, Onitemclick)
    5. 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

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.