If the reader has copied the code from the Internet and then generated the project, he must have faced this class first. This class is a member variable of the WindowImplBase base class, as shown below:
CPaintManagerUI m_pm;
So each window object that inherits from the WindowImplBase base class has a separate CPaintManagerUI member, which is very clear from the literal meaning, this is a class closely related to drawing. Then look at its source code. It has a lot of source code, some of which are listed first, as follows:
class UILIB_API CPaintManagerUI : public CIDropTarget { public: CPaintManagerUI(); ~CPaintManagerUI(); public: void Init(HWND hWnd, LPCTSTR pstrName = NULL); ...... void Invalidate(); void Invalidate(RECT& rcItem); ...... private: CDuiString m_sName; HWND m_hWndPaint; //the handle of the attached form HDC m_hDcPaint; HDC m_hDcOffscreen; HDC m_hDcBackground; HBITMAP m_hbmpOffscreen; BYTE* m_pOffscreenBits; HBITMAP m_hbmpBackground; COLORREF* m_pBackgroundBits; ...... // CControlUI* m_pRoot; CControlUI* m_pFocus; CControlUI* m_pEventHover; CControlUI* m_pEventClick; CControlUI* m_pEventKey; CControlUI* m_pLastToolTip; ...... bool m_bMouseTracking; bool m_bMouseCapture; bool m_bIsPainting; bool m_bUsedVirtualWnd; bool m_bAsyncNotifyPosted; // CStdPtrArray m_aNotifiers; CStdPtrArray m_aTimers; CStdPtrArray m_aTranslateAccelerator; CStdPtrArray m_aPreMessageFilters; CStdPtrArray m_aMessageFilters; CStdPtrArray m_aPostPaintControls; CStdPtrArray m_aNativeWindow; CStdPtrArray m_aNativeWindowControl; CStdPtrArray m_aDelayedCleanup; CStdPtrArray m_aAsyncNotify; CStdPtrArray m_aFoundControls; CStdPtrArray m_aFonts; CStdPtrArray m_aNeedMouseLeaveNeeded; CStdStringPtrMap m_mNameHash; CStdStringPtrMap m_mWindowCustomAttrHash; CStdStringPtrMap m_mOptionGroup; ...... // drag and drop bool m_bDragMode; HBITMAP m_hDragBitmap; // static HINSTANCE m_hInstance; static HINSTANCE m_hResourceInstance; static CDuiString m_pStrResourcePath; static CDuiString m_pStrResourceZip; static CDuiString m_pStrResourceZipPwd; static HANDLE m_hResourceZip; static bool m_bCachedResourceZip; static int m_nResType; static TResInfo m_SharedResInfo; static bool m_bUseHSL; static short m_H; static short m_S; static short m_L; static CStdPtrArray m_aPreMessages; static CStdPtrArray m_aPlugins; };
From the above code, we can know that it inherits from CIDropTarget. A drag and drop object that supports the basic functions of drag and drop, such as dragging and dropping files to windows. Window interface processing in this process. Use the RegisterDragDrop function to register a window as a drop target.
The biggest function of this part is to handle the drawing of the window. The first is all the shared information drawn, that is, the static member variables of the class, m_hInstance: the instance handle of the module, m_pStrResourcePath: the path of the resource, the ZIP compressed resource, m_nResType: the resource type. Go back to the WindowImplBase base class and look at the message handler function, as shown below:
LRESULT WindowImplBase::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; switch (uMsg) { case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break; case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break; case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break; #if defined(WIN32) && !defined(UNDER_CE) case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break; case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break; case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break; case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break; case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEWHEEL: lRes = OnMouseWheel(uMsg, wParam, lParam, bHandled); break; #endif case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break; case WM_CHAR: lRes = OnChar(uMsg, wParam, lParam, bHandled); break; case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break; case WM_KEYDOWN: lRes = OnKeyDown(uMsg, wParam, lParam, bHandled); break; case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break; case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEMOVE: lRes = OnMouseMove(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEHOVER: lRes = OnMouseHover(uMsg, wParam, lParam, bHandled); break; default: bHandled = FALSE; break; } if (bHandled) return lRes; lRes = HandleCustomMessage(uMsg, wParam, lParam, bHandled); if (bHandled) return lRes; //Enter the message processing of CPaintManagerUI if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes)) return lRes; return CWindowWnd::HandleMessage(uMsg, wParam, lParam); }
In the window base class, the message processing of the member m_pm is called.
Welcome to Zhiuu software development network platform, our company custom develops various software, the main direction is desktop professional software development and plug-in custom development, desktop software mainly includes text and graphics recognition software, information management software, 3D printing software, video Class software and other professional graphics and image processing software. The plug-ins include AE plug-ins, AI plug-ins, PS plug-ins, PDF plug-ins, 3DMAX plug-ins, and Office plug-in development such as Word and Excel. For details, please consult, WeChat QQ:312117271, mobile phone: 18928899728, email: anjingzhi_sea@163.com.
company website: http://www.zhiliaos.com