Kingsoft guard open source code-Analysis of message mechanism (II)

Source: Internet
Author: User

The blog has been migrated to: http://kulv.sinaapp.com /.

Connected to http://blog.csdn.net/hw_henry2008/archive/2011/05/22/6438153.aspx

Address: http://download.csdn.net/source/3301518

 

Hwnd cbkdialogimpl: Public c0000wimpl <t, tbase, twintraits> <br/>: Create (hwnd hwndparent =: getactivewindow (), lprect rect = NULL) <br/> {<br/> // · <br/> // call the function creation window of the parent class, <br/> hwnd = _ super: Create (hwndparent, rcwnd, lpszcaption, m_richview.getdlgstyle (), m_richview.getdlgexstyle ()); <br/> // · <br/> return hwnd; <br/>}</P> <p> // continue to read the code, <br/> hwnd c0000wimpl: Public cwindowimplbaset <tbase, twintraits> <br/>: Create (hwnd hwndparent, _ u_rect rect = NULL, lpctstr szwindowname = NULL, <br/> DWORD dwstyle = 0, DWORD dwexstyle = 0, <br/> _ u_menuorid menuorid = 0u, lpvoid lpcreateparam = NULL) <br/>{< br/> If (T: getwndclassinfo (). m_lpszorigname = NULL) <br/> T: getwndclassinfo (). m_lpszorigname = getwndclassname (); <br/> atom = T: getwndclassinfo (). register (& m_pfnsuperwindowproc); <br/> // · <br/> return cwindowimplbaset <tbase, twintraits>: Create (hwndparent, rect, szwindowname, <br/> dwstyle, dwexstyle, menuorid, Atom, lpcreateparam); <br/>}

 

/* The above Code calls getwndclassinfo to obtain the basic information of the window structure. Specifically, it sets the code getwndclassinfo that is necessary to be pasted by the window processing function, which returns the basic information of a window class. This includes WINDOW processing functions, which are the callback functions we use to register with the operating system. */
Static ATL: cwndclassinfo & cbkdialogimpl: getwndclassinfo () <br/>{< br/> static ATL: cwndclassinfo WC ={< br/> {sizeof (wndclassex ), <br/> cs_hredraw | cs_vredraw | cs_dblclks | (iswinxpandlater ()? Cs_dropshadow: 0), <br/> startwindowproc, 0, 0, null, null, <br/> (hbrush) (color_window + 1), null, null, null },< br/> null, null, idc_arrow, true, 0, _ T ("") <br/>}; <br/> return WC; <br/>}</P> <p> // Where ATL: cwndclassinfo is defined by a series of macros, eventually equal to _ atl_wndclassinfow <br/> struct _ atl_wndclassinfow <br/> {// In fact, this structure basically only uses m_wc, and other Initialization is empty <br/> wndclassexw m_wc; // see the definition below <br/> lpcwstr m_lpszorigname; <br/> wndproc pwndpr OC; <br/> lpcwstr m_lpszcursorid; <br/> bool m_bsystemcursor; <br/> atom m_atom; <br/> wchar m_szautoname [5 + sizeof (void *) * char_bit]; <br/> atom register (wndproc * P) {// this function will be mentioned later, to manipulate the system registration window, use the <br/> return atlwinmoduleregisterwndclassinfow (& _ atlwinmodule, & _ atlbasemodule, this, P); <br/>}< br/> }; </P> <p> typedef struct tagwndclassexw {<br/> uint cbsize; <br/> uint style; <br/> wndproc lpfnwndproc; // readers will The Member is actually the registered message processing function: startwindowproc !!!! <Br/> int cbclsextra; <br/> int cbwndextra; <br/> hinstance; <br/> hicon; <br/> hcursor; <br/> hbrush hbrbackground; <br/> lpcwstr lpszmenuname; <br/> lpcwstr lpszclassname; <br/> hicon hiconsm; <br/>} wndclassexw, * pwndclassexw, near * npwndclassexw, far * lpwndclassexw;

 

/* Well, it's clear how the window handler registers with the operating system. To end the process, let's take a look at the code for creating the window.
The registration of the window is a hidden place In the create function of the preceding csf-wimpl.
Atom atom = T: getwndclassinfo (). Register (& m_pfnsuperwindowproc );
This register is actually a member function of the cwndclassinfo structure. After some tedious calls, the following code is finally called.
P-> m_atom = T: registerclassex (pwinmodule, & P-> m_wc );
Obviously, this is the place where the window class is registered. What about the create window? After the above functions are registered, the following function creation window is called.
*/

 

 Template <class tbase, class twintraits> <br/> hwnd cwindowimplbaset <tbase, twintraits>: Public cwindowimplroot <tbase> <br/>: Create (hwnd hwndparent, _ u_rect rect, lpctstr szwindowname, <br/> DWORD dwstyle, DWORD dwexstyle, _ u_menuorid menuorid, Atom atom, lpvoid lpcreateparam) <br/> {<br/> // · <br/> hwnd =: createmediawex (dwexstyle, makeintatom (atom), szwindowname, <br/> dwstyle, rect. m_lprect-> left, rect. m_lprect-> top, rect. m_lprect-> right-rect. m_lprect-> left, <br/> rect. m_lprect-> bottom-rect. m_lprect-> top, hwndparent, menuorid. m_hmenu, <br/> _ atlbasemodule. getmoduleinstance (), lpcreateparam); </P> <p> atlassume (m_hwnd = hwnd); </P> <p> return hwnd; <br/>}

 

/* Sorry, because I have just read the Kingsoft code, it is very unfamiliar in many places,
Many highlights are missing, and the text is written in a mess and commented out randomly in the code.
Please forgive me for the impact on reading. · A while ago, I asked Yan Xin a question,
He said, "If you don't understand something, try writing it out. you may understand it when you write a blog." It is true.
Understanding the wrong place (certainly have) Please don't hesitate to enlighten me: hw_henry2008@126.com

Todo: ATL: csimplemap <DWORD, cmessageloop *> * m_pmsgloopmap

This code can also lead to another method of message ing. You can check it in another day.
In addition, you have to take a good look at the XML implementation mechanism.
First ···*/

 

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.