#include "SRButton.h" #include "SRApp.h" #include using namespace SRFramework; SRButton::SRButton(void) { INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&InitCtrlEx); m_hInstance = SRFramework::SRApp::GetInstanceHandle(); m_wcsClassName = "button"; m_wcsWindowName = ""; } SRButton::~SRButton(void) { } BOOL SRButton::Create(SRWnd *pParentWnd, const WCString &wcsLabel, RECT bounds, INT nChildID, DWORD dwStyle) { if(!Register()) return FALSE; m_wcsWindowName = wcsLabel; if(!SRWnd::Create(m_wcsClassName, m_wcsWindowName, dwStyle, bounds, pParentWnd, (HMENU)nChildID, m_hInstance)) return FALSE; return TRUE; } WCString SRButton::GetText() { TCHAR *strQuery = NULL; INT nQueryLen = ::SendMessage(m_hWnd, WM_GETTEXTLENGTH, NULL, NULL) + 1; strQuery = new TCHAR[nQueryLen]; ::SendMessage(m_hWnd,WM_GETTEXT,(WPARAM)nQueryLen,(LPARAM)strQuery); strQuery[nQueryLen - 1] = 0; // in case the buffer was exceeded return strQuery; }