标签:
1 class CWindow 2 { 3 public: 4 HWND m_hWnd; 5 6 HWND Detach() throw() 7 { 8 HWND hWnd = m_hWnd; 9 m_hWnd = NULL; 10 return hWnd; 11 } 12 HWND Create(LPCTSTR lpstrWndClass, HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, 13 DWORD dwStyle = 0, DWORD dwExStyle = 0, 14 _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) throw() 15 { 16 ATLASSUME(m_hWnd == NULL); 17 if(rect.m_lpRect == NULL) 18 rect.m_lpRect = &rcDefault; 19 m_hWnd = ::CreateWindowEx(dwExStyle, lpstrWndClass, szWindowName, 20 dwStyle, rect.m_lpRect->left, rect.m_lpRect->top, rect.m_lpRect->right - rect.m_lpRect->left, 21 rect.m_lpRect->bottom - rect.m_lpRect->top, hWndParent, MenuOrID.m_hMenu, 22 _AtlBaseModule.GetModuleInstance(), lpCreateParam); 23 return m_hWnd; 24 } 25 26 BOOL DestroyWindow() throw() 27 { 28 ATLASSERT(::IsWindow(m_hWnd)); 29 30 if(!::DestroyWindow(m_hWnd)) 31 return FALSE; 32 33 m_hWnd = NULL; 34 return TRUE; 35 } 36 37 // Attributes 38 operator HWND() const throw() 39 { 40 return m_hWnd; 41 } 42 DWORD GetStyle() const throw() 43 { 44 ATLASSERT(::IsWindow(m_hWnd)); 45 return (DWORD)::GetWindowLong(m_hWnd, GWL_STYLE); 46 } 47 48 // Message Functions 49 LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) throw() 50 { 51 ATLASSERT(::IsWindow(m_hWnd)); 52 return ::SendMessage(m_hWnd,message,wParam,lParam); 53 } 54 55 BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) throw() 56 { 57 ATLASSERT(::IsWindow(m_hWnd)); 58 return ::PostMessage(m_hWnd,message,wParam,lParam); 59 } 60 ... 61 // Window Text Functions 62 BOOL SetWindowText(LPCTSTR lpszString) throw() 63 { 64 ATLASSERT(::IsWindow(m_hWnd)); 65 return ::SetWindowText(m_hWnd, lpszString); 66 } 67 68 int GetWindowText(_Out_z_cap_post_count_(nMaxCount, return + 1) LPTSTR lpszStringBuf, _In_ int nMaxCount) const throw() 69 { 70 ATLASSERT(::IsWindow(m_hWnd)); 71 return ::GetWindowText(m_hWnd, lpszStringBuf, nMaxCount); 72 } 73 ... 74 }; 75
标签:
原文地址:http://www.cnblogs.com/elitiwin/p/4206033.html