123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef __UIBASE_H__
- #define __UIBASE_H__
- #pragma once
- namespace DuiLib {
- #define UI_WNDSTYLE_CONTAINER (0)
- #define UI_WNDSTYLE_FRAME (WS_VISIBLE | WS_OVERLAPPEDWINDOW)
- #define UI_WNDSTYLE_CHILD (WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)
- #define UI_WNDSTYLE_DIALOG (WS_VISIBLE | WS_POPUPWINDOW | WS_CAPTION | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)
- #define UI_WNDSTYLE_EX_FRAME (WS_EX_WINDOWEDGE)
- #define UI_WNDSTYLE_EX_DIALOG (WS_EX_TOOLWINDOW | WS_EX_DLGMODALFRAME)
- #define UI_CLASSSTYLE_CONTAINER (0)
- #define UI_CLASSSTYLE_FRAME (CS_VREDRAW | CS_HREDRAW)
- #define UI_CLASSSTYLE_CHILD (CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_SAVEBITS)
- #define UI_CLASSSTYLE_DIALOG (CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_SAVEBITS)
- #ifdef NDEBUG
- #define ASSERT(expr) ((void)0)
- #else
- #ifndef ASSERT
- #define ASSERT(expr) _ASSERTE(expr)
- #endif
- #endif
- #ifdef _DEBUG
- #ifndef DUITRACE
- #define DUITRACE DUI__Trace
- #endif
- #define DUITRACEMSG DUI__TraceMsg
- #else
- #ifndef DUITRACE
- #define DUITRACE
- #endif
- #define DUITRACEMSG _T("")
- #endif
- void UILIB_API DUI__Trace(LPCTSTR pstrFormat, ...);
- void UILIB_API DUI__TraceMsg(UINT uMsg);
- class UILIB_API CNotifyPump
- {
- public:
- bool AddVirtualWnd(CDuiString strName,CNotifyPump* pObject);
- bool RemoveVirtualWnd(CDuiString strName);
- void NotifyPump(TNotifyUI& msg);
- bool LoopDispatch(TNotifyUI& msg);
- DUI_DECLARE_MESSAGE_MAP()
- private:
- CStdStringPtrMap m_VirtualWndMap;
- };
- class UILIB_API CWindowWnd
- {
- public:
- CWindowWnd();
- HWND GetHWND() const;
- operator HWND() const;
- bool RegisterWindowClass();
- bool RegisterSuperclass();
- HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, const RECT rc, HMENU hMenu = NULL);
- HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT, HMENU hMenu = NULL);
- HWND CreateDuiWindow(HWND hwndParent, LPCTSTR pstrWindowName,DWORD dwStyle =0, DWORD dwExStyle =0);
- HWND Subclass(HWND hWnd);
- void Unsubclass();
- void ShowWindow(bool bShow = true, bool bTakeFocus = true);
- UINT ShowModal();
- virtual void Close(UINT nRet = IDOK);
- void CenterWindow();
- void SetIcon(UINT nRes);
- LRESULT SendMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
- LRESULT PostMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
- void ResizeClient(int cx = -1, int cy = -1);
- protected:
- virtual LPCTSTR GetWindowClassName() const = 0;
- virtual LPCTSTR GetSuperClassName() const;
- virtual UINT GetClassStyle() const;
- virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void OnFinalMessage(HWND hWnd);
- static LRESULT CALLBACK __WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- static LRESULT CALLBACK __ControlProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- protected:
- HWND m_hWnd;
- WNDPROC m_OldWndProc;
- bool m_bSubclassed;
- };
- }
- #endif
|