--- /dev/null
+// Win32++ Version 7.3\r
+// Released: 30th November 2011\r
+//\r
+// David Nash\r
+// url: https://sourceforge.net/projects/win32-framework\r
+//\r
+//\r
+// Copyright (c) 2005-2011 David Nash\r
+//\r
+// Permission is hereby granted, free of charge, to\r
+// any person obtaining a copy of this software and\r
+// associated documentation files (the "Software"),\r
+// to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify,\r
+// merge, publish, distribute, sublicense, and/or sell\r
+// copies of the Software, and to permit persons to whom\r
+// the Software is furnished to do so, subject to the\r
+// following conditions:\r
+//\r
+// The above copyright notice and this permission notice\r
+// shall be included in all copies or substantial portions\r
+// of the Software.\r
+//\r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF\r
+// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\r
+// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\r
+// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\r
+// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR\r
+// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\r
+// OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+////////////////////////////////////////////////////////\r
+\r
+\r
+////////////////////////////////////////////////////////\r
+// stdcontrols.h\r
+// Declaration of the CButton, CEdit, CListBox and CStatic classes\r
+\r
+// The Button, Edit, ListBox and Static controls are often referred to \r
+// as "standard controls". These set of older controls were originally \r
+// developed for Win16 operating systems (Windows 3.1 and 3.11). They use an\r
+// older form of notification, and send their notifications via a WM_COMMAND\r
+// message. Newer controls send their notifications via a WM_NOTIFY message.\r
+\r
+\r
+#ifndef _WIN32XX_STDCONTROLS_H_\r
+#define _WIN32XX_STDCONTROLS_H_\r
+\r
+#include "wincore.h"\r
+\r
+\r
+namespace Win32xx\r
+{\r
+ class CButton : public CWnd\r
+ {\r
+ public:\r
+ CButton() {}\r
+ virtual ~CButton() {}\r
+\r
+ // Attributes\r
+ HBITMAP GetBitmap() const;\r
+ UINT GetButtonStyle() const;\r
+ int GetCheck() const;\r
+ HCURSOR GetCursor() const;\r
+ HICON GetIcon() const;\r
+ UINT GetState() const;\r
+ HBITMAP SetBitmap(HBITMAP hBitmap) const;\r
+ void SetButtonStyle(DWORD dwStyle, BOOL bRedraw) const;\r
+ void SetCheck(int nCheckState) const;\r
+ HCURSOR SetCursor(HCURSOR hCursor) const;\r
+ HICON SetIcon(HICON hIcon) const;\r
+ void SetState(BOOL bHighlight) const;\r
+\r
+ protected:\r
+ // Overridables\r
+ virtual void PreCreate(CREATESTRUCT& cs);\r
+ };\r
+\r
+ class CEdit : public CWnd\r
+ {\r
+ public:\r
+ // Construction\r
+ CEdit() {}\r
+ virtual ~CEdit() {}\r
+\r
+ // Attributes\r
+ BOOL CanUndo() const;\r
+ int CharFromPos(CPoint pt) const;\r
+ int GetFirstVisibleLine() const;\r
+ HLOCAL GetHandle() const;\r
+ UINT GetLimitText() const;\r
+ int GetLine(int nIndex, LPTSTR lpszBuffer) const;\r
+ int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const;\r
+ int GetLineCount() const;\r
+ DWORD GetMargins() const;\r
+ BOOL GetModify() const;\r
+ TCHAR GetPasswordChar() const;\r
+ void GetRect(LPRECT lpRect) const;\r
+ void GetSel(int& nStartChar, int& nEndChar) const;\r
+ DWORD GetSel() const;\r
+ CPoint PosFromChar(UINT nChar) const;\r
+ void SetHandle(HLOCAL hBuffer) const;\r
+ void SetLimitText(UINT nMax) const;\r
+ void SetMargins(UINT nLeft, UINT nRight) const;\r
+ void SetModify(BOOL bModified = TRUE) const;\r
+\r
+ // Operations\r
+ void EmptyUndoBuffer() const;\r
+ BOOL FmtLines(BOOL bAddEOL) const;\r
+ void LimitText(int nChars = 0) const;\r
+ int LineFromChar(int nIndex = -1) const;\r
+ int LineIndex(int nLine = -1) const;\r
+ int LineLength(int nLine = -1) const;\r
+ void LineScroll(int nLines, int nChars = 0) const;\r
+ void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo) const;\r
+ void SetPasswordChar(TCHAR ch) const;\r
+ BOOL SetReadOnly(BOOL bReadOnly = TRUE) const;\r
+ void SetRect(LPCRECT lpRect) const;\r
+ void SetRectNP(LPCRECT lpRect) const;\r
+ void SetSel(DWORD dwSelection, BOOL bNoScroll) const;\r
+ void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll) const;\r
+ BOOL SetTabStops(int nTabStops, LPINT rgTabStops) const;\r
+ BOOL SetTabStops() const;\r
+ BOOL SetTabStops(const int& cxEachStop) const;\r
+\r
+ //Clipboard Operations\r
+ void Clear() const;\r
+ void Copy() const;\r
+ void Cut() const;\r
+ void Paste() const;\r
+ void Undo() const;\r
+\r
+ protected:\r
+ // Overridables\r
+ virtual void PreRegisterClass(WNDCLASS &wc);\r
+ };\r
+\r
+ class CListBox : public CWnd\r
+ {\r
+ public:\r
+ CListBox() {}\r
+ virtual ~CListBox() {}\r
+\r
+ // General Operations\r
+ int GetCount() const;\r
+ int GetHorizontalExtent() const;\r
+ DWORD GetItemData(int nIndex) const;\r
+ void* GetItemDataPtr(int nIndex) const;\r
+ int GetItemHeight(int nIndex) const;\r
+ int GetItemRect(int nIndex, LPRECT lpRect) const;\r
+ LCID GetLocale() const;\r
+ int GetSel(int nIndex) const;\r
+ int GetText(int nIndex, LPTSTR lpszBuffer) const;\r
+ int GetTextLen(int nIndex) const;\r
+ int GetTopIndex() const;\r
+ UINT ItemFromPoint(CPoint pt, BOOL& bOutside ) const;\r
+ void SetColumnWidth(int cxWidth) const;\r
+ void SetHorizontalExtent(int cxExtent) const;\r
+ int SetItemData(int nIndex, DWORD dwItemData) const;\r
+ int SetItemDataPtr(int nIndex, void* pData) const;\r
+ int SetItemHeight(int nIndex, UINT cyItemHeight) const;\r
+ LCID SetLocale(LCID nNewLocale) const;\r
+ BOOL SetTabStops(int nTabStops, LPINT rgTabStops) const;\r
+ void SetTabStops() const;\r
+ BOOL SetTabStops(const int& cxEachStop) const;\r
+ int SetTopIndex(int nIndex) const;\r
+\r
+ // Single-Selection Operations\r
+ int GetCurSel() const;\r
+ int SetCurSel(int nSelect) const;\r
+\r
+ // Multiple-Selection Operations\r
+ int GetAnchorIndex() const;\r
+ int GetCaretIndex() const;\r
+ int GetSelCount() const;\r
+ int GetSelItems(int nMaxItems, LPINT rgIndex) const;\r
+ int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) const;\r
+ void SetAnchorIndex(int nIndex) const;\r
+ int SetCaretIndex(int nIndex, BOOL bScroll) const;\r
+ int SetSel(int nIndex, BOOL bSelect) const;\r
+\r
+ // String Operations\r
+ int AddString(LPCTSTR lpszItem) const;\r
+ int DeleteString(UINT nIndex) const;\r
+ int Dir(UINT attr, LPCTSTR lpszWildCard) const;\r
+ int FindString(int nStartAfter, LPCTSTR lpszItem) const;\r
+ int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;\r
+ int InsertString(int nIndex, LPCTSTR lpszItem) const;\r
+ void ResetContent() const;\r
+ int SelectString(int nStartAfter, LPCTSTR lpszItem) const;\r
+\r
+ protected:\r
+ // Overridables\r
+ virtual void PreRegisterClass(WNDCLASS &wc);\r
+ };\r
+\r
+ class CStatic : public CWnd\r
+ {\r
+ public:\r
+ CStatic() {}\r
+ virtual ~CStatic() {}\r
+\r
+ // Operations\r
+ HBITMAP GetBitmap() const;\r
+ HCURSOR GetCursor() const;\r
+ HENHMETAFILE GetEnhMetaFile() const;\r
+ HICON GetIcon() const;\r
+ HBITMAP SetBitmap(HBITMAP hBitmap) const;\r
+ HCURSOR SetCursor(HCURSOR hCursor) const;\r
+ HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) const;\r
+ HICON SetIcon(HICON hIcon) const;\r
+\r
+ protected:\r
+ // Overridables\r
+ virtual void PreRegisterClass(WNDCLASS &wc);\r
+\r
+ };\r
+\r
+}\r
+\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+\r
+namespace Win32xx\r
+{\r
+\r
+ ////////////////////////////////////////\r
+ // Definitions for the CButton class\r
+ //\r
+ inline HBITMAP CButton::GetBitmap() const\r
+ // returns the handle to the bitmap associated with the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HBITMAP)SendMessage(BM_GETIMAGE, IMAGE_BITMAP, 0);\r
+ }\r
+\r
+ inline UINT CButton::GetButtonStyle() const\r
+ // returns the style of the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (UINT)GetWindowLongPtr(GWL_STYLE) & 0xff;\r
+ }\r
+\r
+ inline int CButton::GetCheck() const\r
+ // returns the check state of the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(BM_GETCHECK, 0, 0);\r
+ }\r
+\r
+ inline HCURSOR CButton::GetCursor() const\r
+ // returns the handle to the cursor associated withe the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HCURSOR)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_CURSOR, 0L);\r
+ }\r
+\r
+ inline HICON CButton::GetIcon() const\r
+ // returns the handle to the icon associated withe the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HICON)SendMessage(BM_GETIMAGE, IMAGE_ICON, 0);\r
+ }\r
+\r
+ inline UINT CButton::GetState() const\r
+ // returns the state of the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (UINT)SendMessage(BM_GETSTATE, 0, 0);\r
+ }\r
+\r
+ inline HBITMAP CButton::SetBitmap(HBITMAP hBitmap) const\r
+ // sets the bitmap associated with the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HBITMAP)SendMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);\r
+ }\r
+\r
+ inline void CButton::SetButtonStyle(DWORD dwStyle, BOOL bRedraw) const\r
+ // sets the button style\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(BM_SETSTYLE, dwStyle, bRedraw);\r
+ }\r
+\r
+ inline void CButton::SetCheck(int nCheckState) const\r
+ // sets the button check state\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(BM_SETCHECK, nCheckState, 0);\r
+ }\r
+\r
+ inline HCURSOR CButton::SetCursor(HCURSOR hCursor) const\r
+ // sets the cursor associated with the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HCURSOR)SendMessage(STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);\r
+ }\r
+\r
+ inline HICON CButton::SetIcon(HICON hIcon) const\r
+ // sets the icon associated with the button\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HICON)SendMessage( BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);\r
+ }\r
+\r
+ inline void CButton::SetState(BOOL bHighlight) const\r
+ // sets the button state\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(BM_SETSTATE, bHighlight, 0);\r
+ }\r
+\r
+ inline void CButton::PreCreate(CREATESTRUCT& cs)\r
+ {\r
+ cs.lpszClass = _T("Button");\r
+ }\r
+\r
+\r
+ ////////////////////////////////////////\r
+ // Definitions for the CEdit class\r
+ //\r
+ inline BOOL CEdit::CanUndo() const\r
+ // Returns TRUE if the edit control operation can be undone.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(EM_CANUNDO, 0, 0);\r
+ }\r
+\r
+ inline int CEdit::CharFromPos(CPoint pt) const\r
+ // Returns the character index and line index of the character nearest the specified point.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y));\r
+ }\r
+\r
+ inline int CEdit::GetFirstVisibleLine() const\r
+ // Returns the zero-based index of the first visible character in a single-line edit control \r
+ // or the zero-based index of the uppermost visible line in a multiline edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0);\r
+ }\r
+\r
+ inline HLOCAL CEdit::GetHandle() const\r
+ // Returns a handle identifying the buffer containing the multiline edit control's text. \r
+ // It is not processed by single-line edit controls.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HLOCAL)SendMessage(EM_GETHANDLE, 0, 0);\r
+ }\r
+\r
+ inline UINT CEdit::GetLimitText() const\r
+ // Returns the current text limit, in characters.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (UINT)SendMessage(EM_GETLIMITTEXT, 0, 0);\r
+ }\r
+\r
+ inline int CEdit::GetLine(int nIndex, LPTSTR lpszBuffer) const\r
+ // Copies characters to a buffer and returns the number of characters copied.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);\r
+ }\r
+\r
+ inline int CEdit::GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const\r
+ // Copies characters to a buffer and returns the number of characters copied.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ *(LPWORD)lpszBuffer = (WORD)nMaxLength;\r
+ return (int)SendMessage(EM_GETLINE, nIndex, (LPARAM)lpszBuffer);\r
+ }\r
+\r
+ inline int CEdit::GetLineCount() const\r
+ // Returns the number of lines in the edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(EM_GETLINECOUNT, 0, 0);\r
+ }\r
+\r
+ inline DWORD CEdit::GetMargins() const\r
+ // Returns the widths of the left and right margins.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (DWORD)SendMessage(EM_GETMARGINS, 0, 0);\r
+ }\r
+\r
+ inline BOOL CEdit::GetModify() const\r
+ // Returns a flag indicating whether the content of an edit control has been modified.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(EM_GETMODIFY, 0, 0);\r
+ }\r
+\r
+ inline TCHAR CEdit::GetPasswordChar() const\r
+ // Returns the character that edit controls use in conjunction with the ES_PASSWORD style.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (TCHAR)SendMessage(EM_GETPASSWORDCHAR, 0, 0);\r
+ }\r
+\r
+ inline void CEdit::GetRect(LPRECT lpRect) const\r
+ // Returns the coordinates of the formatting rectangle in an edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_GETRECT, 0, (LPARAM)lpRect);\r
+ }\r
+\r
+ inline void CEdit::GetSel(int& nStartChar, int& nEndChar) const\r
+ // Returns the starting and ending character positions of the current selection in the edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_GETSEL, (WPARAM)&nStartChar,(LPARAM)&nEndChar);\r
+ }\r
+\r
+ inline DWORD CEdit::GetSel() const\r
+ // Returns the starting and ending character positions of the current selection in the edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (DWORD)SendMessage(EM_GETSEL, 0, 0);\r
+ }\r
+\r
+ inline CPoint CEdit::PosFromChar(UINT nChar) const\r
+ // Returns the client coordinates of the specified character.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return CPoint( (DWORD)SendMessage(EM_POSFROMCHAR, nChar, 0));\r
+ }\r
+\r
+ inline void CEdit::SetHandle(HLOCAL hBuffer) const\r
+ // Sets a handle to the memory used as a text buffer, empties the undo buffer, \r
+ // resets the scroll positions to zero, and redraws the window.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETHANDLE, (WPARAM)hBuffer, 0);\r
+ }\r
+\r
+ inline void CEdit::SetLimitText(UINT nMax) const\r
+ // Sets the maximum number of characters the user may enter in the edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETLIMITTEXT, (WPARAM)nMax, 0);\r
+ }\r
+\r
+ inline void CEdit::SetMargins(UINT nLeft, UINT nRight) const\r
+ // Sets the widths of the left and right margins, and redraws the edit control to reflect the new margins.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(nLeft, nRight));\r
+ }\r
+\r
+ inline void CEdit::SetModify(BOOL bModified) const\r
+ // Sets or clears the modification flag to indicate whether the edit control has been modified.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETMODIFY, bModified, 0);\r
+ }\r
+\r
+ inline void CEdit::EmptyUndoBuffer() const\r
+ // Empties the undo buffer and sets the undo flag retrieved by the EM_CANUNDO message to FALSE.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_EMPTYUNDOBUFFER, 0, 0);\r
+ }\r
+\r
+ inline BOOL CEdit::FmtLines(BOOL bAddEOL) const\r
+ // Adds or removes soft line-break characters (two carriage returns and a line feed) to the ends of wrapped lines \r
+ // in a multiline edit control. It is not processed by single-line edit controls.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(EM_FMTLINES, bAddEOL, 0);\r
+ }\r
+\r
+ inline void CEdit::LimitText(int nChars) const\r
+ // Sets the text limit of an edit control. The text limit is the maximum amount of text, in TCHARs, \r
+ // that the user can type into the edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_LIMITTEXT, nChars, 0);\r
+ }\r
+\r
+ inline int CEdit::LineFromChar(int nIndex) const\r
+ // Returns the zero-based number of the line in a multiline edit control that contains a specified character index.\r
+ // This message is the reverse of the EM_LINEINDEX message.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(EM_LINEFROMCHAR, (WPARAM)nIndex, 0);\r
+ }\r
+\r
+ inline int CEdit::LineIndex(int nLine) const\r
+ // Returns the character of a line in a multiline edit control. \r
+ // This message is the reverse of the EM_LINEFROMCHAR message\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(EM_LINEINDEX, (WPARAM)nLine, 0);\r
+ }\r
+\r
+ inline int CEdit::LineLength(int nLine) const\r
+ // Returns the length, in characters, of a single-line edit control. In a multiline edit control, \r
+ // returns the length, in characters, of a specified line.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(EM_LINELENGTH, (WPARAM)nLine, 0);\r
+ }\r
+\r
+ inline void CEdit::LineScroll(int nLines, int nChars) const\r
+ // Scrolls the text vertically in a single-line edit control or horizontally in a multiline edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd)); \r
+ SendMessage(EM_LINESCROLL, (WPARAM)nChars, (LPARAM)nLines);\r
+ }\r
+\r
+ inline void CEdit::ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo) const\r
+ // Replaces the current selection with the text in an application-supplied buffer, sends the parent window \r
+ // EN_UPDATE and EN_CHANGE messages, and updates the undo buffer.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText);\r
+ }\r
+\r
+ inline void CEdit::SetPasswordChar(TCHAR ch) const\r
+ // Defines the character that edit controls use in conjunction with the ES_PASSWORD style.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETPASSWORDCHAR, ch, 0);\r
+ }\r
+\r
+ inline BOOL CEdit::SetReadOnly(BOOL bReadOnly) const\r
+ // Sets or removes the read-only style (ES_READONLY) in an edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(EM_SETREADONLY, bReadOnly, 0);\r
+ }\r
+\r
+ inline void CEdit::SetRect(LPCRECT lpRect) const\r
+ // Sets the formatting rectangle for the multiline edit control and redraws the window.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETRECT, 0, (LPARAM)lpRect);\r
+ }\r
+\r
+ inline void CEdit::SetRectNP(LPCRECT lpRect) const\r
+ // Sets the formatting rectangle for the multiline edit control but does not redraw the window.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETRECTNP, 0, (LPARAM)lpRect);\r
+ }\r
+\r
+ inline void CEdit::SetSel(DWORD dwSelection, BOOL bNoScroll) const\r
+ // Selects a range of characters in the edit control by setting the starting and ending positions to be selected.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection));\r
+ if (!bNoScroll)\r
+ SendMessage(EM_SCROLLCARET, 0, 0);\r
+ }\r
+\r
+ inline void CEdit::SetSel(int nStartChar, int nEndChar, BOOL bNoScroll) const\r
+ // Selects a range of characters in the edit control by setting the starting and ending positions to be selected.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);\r
+ if (!bNoScroll)\r
+ SendMessage(EM_SCROLLCARET, 0, 0);\r
+ }\r
+\r
+ inline BOOL CEdit::SetTabStops(int nTabStops, LPINT rgTabStops) const\r
+ // Sets tab-stop positions in the multiline edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);\r
+ }\r
+\r
+ inline BOOL CEdit::SetTabStops() const\r
+ // Sets tab-stop positions in the multiline edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage( EM_SETTABSTOPS, 0, 0);\r
+ }\r
+\r
+ inline BOOL CEdit::SetTabStops(const int& cxEachStop) const\r
+ // Sets tab-stop positions in the multiline edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);\r
+ }\r
+\r
+ inline void CEdit::Clear() const\r
+ // Clears the current selection, if any, in an edit control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(WM_CLEAR, 0, 0);\r
+ }\r
+\r
+ inline void CEdit::Copy() const\r
+ // Copies text to the clipboard unless the style is ES_PASSWORD, in which case the message returns zero.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(WM_COPY, 0, 0);\r
+ }\r
+\r
+ inline void CEdit::Cut() const\r
+ // Cuts the selection to the clipboard, or deletes the character to the left of the cursor if there is no selection.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(WM_CUT, 0, 0);\r
+ }\r
+\r
+ inline void CEdit::Paste() const\r
+ // Pastes text from the clipboard into the edit control window at the caret position.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(WM_PASTE, 0, 0);\r
+ }\r
+\r
+ inline void CEdit::Undo() const\r
+ // Removes any text that was just inserted or inserts any deleted characters and sets the selection to the inserted text.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(EM_UNDO, 0, 0);\r
+ }\r
+\r
+ inline void CEdit::PreRegisterClass(WNDCLASS &wc)\r
+ {\r
+ // Set the Window Class\r
+ wc.lpszClassName = _T("Edit");\r
+ }\r
+\r
+\r
+ ////////////////////////////////////////\r
+ // Definitions for the CListbox class\r
+ //\r
+ inline int CListBox::GetCount() const\r
+ // Returns the number of items in the list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETCOUNT, 0, 0);\r
+ }\r
+\r
+ inline int CListBox::GetHorizontalExtent() const\r
+ // Returns the scrollable width, in pixels, of a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETHORIZONTALEXTENT, 0, 0);\r
+ }\r
+\r
+ inline DWORD CListBox::GetItemData(int nIndex) const\r
+ // Returns the value associated with the specified item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (DWORD)SendMessage(LB_GETITEMDATA, nIndex, 0);\r
+ }\r
+\r
+ inline void* CListBox::GetItemDataPtr(int nIndex) const\r
+ // Returns the value associated with the specified item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (LPVOID)SendMessage(LB_GETITEMDATA, nIndex, 0);\r
+ }\r
+\r
+ inline int CListBox::GetItemHeight(int nIndex) const\r
+ // Returns the height, in pixels, of an item in a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETITEMHEIGHT, nIndex, 0L);\r
+ }\r
+\r
+ inline int CListBox::GetItemRect(int nIndex, LPRECT lpRect) const\r
+ // Retrieves the client coordinates of the specified list box item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETITEMRECT, nIndex, (LPARAM)lpRect);\r
+ }\r
+\r
+ inline LCID CListBox::GetLocale() const\r
+ // Retrieves the locale of the list box. The high-order word contains the country/region code \r
+ // and the low-order word contains the language identifier.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0);\r
+ }\r
+\r
+ inline int CListBox::GetSel(int nIndex) const\r
+ // Returns the selection state of a list box item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETSEL, nIndex, 0);\r
+ }\r
+\r
+ inline int CListBox::GetText(int nIndex, LPTSTR lpszBuffer) const\r
+ // Retrieves the string associated with a specified item and the length of the string.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer);\r
+ }\r
+\r
+ inline int CListBox::GetTextLen(int nIndex) const\r
+ // Returns the length, in characters, of the string associated with a specified item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage( LB_GETTEXTLEN, nIndex, 0);\r
+ }\r
+\r
+ inline int CListBox::GetTopIndex() const\r
+ // Returns the index of the first visible item in a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETTOPINDEX, 0, 0);\r
+ }\r
+\r
+ inline UINT CListBox::ItemFromPoint(CPoint pt, BOOL& bOutside) const\r
+ // Retrieves the zero-based index of the item nearest the specified point in a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));\r
+ bOutside = !!HIWORD(dw);\r
+ return LOWORD(dw);\r
+ }\r
+\r
+ inline void CListBox::SetColumnWidth(int cxWidth) const\r
+ // Sets the width, in pixels, of all columns in a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(LB_SETCOLUMNWIDTH, cxWidth, 0);\r
+ }\r
+\r
+ inline void CListBox::SetHorizontalExtent(int cxExtent) const\r
+ // Sets the scrollable width, in pixels, of a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(LB_SETHORIZONTALEXTENT, cxExtent, 0);\r
+ }\r
+\r
+ inline int CListBox::SetItemData(int nIndex, DWORD dwItemData) const\r
+ // Associates a value with a list box item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_SETITEMDATA, nIndex, (LPARAM)dwItemData);\r
+ }\r
+\r
+ inline int CListBox::SetItemDataPtr(int nIndex, void* pData) const\r
+ // Associates a value with a list box item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return SetItemData(nIndex, (DWORD)(DWORD_PTR)pData);\r
+ }\r
+\r
+ inline int CListBox::SetItemHeight(int nIndex, UINT cyItemHeight) const\r
+ // Sets the height, in pixels, of an item or items in a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));\r
+ }\r
+\r
+ inline LCID CListBox::SetLocale(LCID nNewLocale) const\r
+ // Sets the locale of a list box and returns the previous locale identifier.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0);\r
+ }\r
+\r
+ inline BOOL CListBox::SetTabStops(int nTabStops, LPINT rgTabStops) const\r
+ // Sets the tab stops to those specified in a specified array.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);\r
+ }\r
+\r
+ inline void CListBox::SetTabStops() const\r
+ // Sets the tab stops to those specified in a specified array.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(LB_SETTABSTOPS, 0, 0);\r
+ }\r
+\r
+ inline BOOL CListBox::SetTabStops(const int& cxEachStop) const\r
+ // Sets the tab stops to those specified in a specified array.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);\r
+ }\r
+\r
+ inline int CListBox::SetTopIndex(int nIndex) const\r
+ // Scrolls the list box so the specified item is at the top of the visible range.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_SETTOPINDEX, nIndex, 0);\r
+ }\r
+\r
+ inline int CListBox::GetCurSel() const\r
+ // Returns the index of the currently selected item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETCURSEL, 0, 0);\r
+ }\r
+\r
+ inline int CListBox::SetCurSel(int nSelect) const\r
+ // Selects a specified list box item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_SETCURSEL, nSelect, 0);\r
+ }\r
+\r
+ inline int CListBox::GetAnchorIndex() const\r
+ // Returns the index of the item that the mouse last selected.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETANCHORINDEX, 0, 0);\r
+ }\r
+\r
+ inline int CListBox::GetCaretIndex() const\r
+ // Returns the index of the item that has the focus rectangle.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETCARETINDEX, 0, 0L);\r
+ }\r
+\r
+ inline int CListBox::GetSelCount() const\r
+ // Returns the number of selected items in a multiple-selection list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETSELCOUNT, 0, 0);\r
+ }\r
+\r
+ inline int CListBox::GetSelItems(int nMaxItems, LPINT rgIndex) const\r
+ // Creates an array of the indexes of all selected items in a multiple-selection list box \r
+ // and returns the total number of selected items.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex);\r
+ }\r
+\r
+ inline int CListBox::SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) const\r
+ // Selects a specified range of items in a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ if (bSelect)\r
+ return (int)SendMessage(LB_SELITEMRANGEEX, nFirstItem, nLastItem);\r
+ else\r
+ return (int)SendMessage(LB_SELITEMRANGEEX, nLastItem, nFirstItem);\r
+ }\r
+\r
+ inline void CListBox::SetAnchorIndex(int nIndex) const\r
+ // Sets the item that the mouse last selected to a specified item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(LB_SETANCHORINDEX, nIndex, 0);\r
+ }\r
+\r
+ inline int CListBox::SetCaretIndex(int nIndex, BOOL bScroll) const\r
+ // Sets the focus rectangle to a specified list box item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0));\r
+ }\r
+\r
+ inline int CListBox::SetSel(int nIndex, BOOL bSelect) const\r
+ // Selects an item in a multiple-selection list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_SETSEL, bSelect, nIndex);\r
+ }\r
+\r
+ inline int CListBox::AddString(LPCTSTR lpszItem) const\r
+ // Adds a string to a list box and returns its index.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_ADDSTRING, 0, (LPARAM)lpszItem);\r
+ }\r
+\r
+ inline int CListBox::DeleteString(UINT nIndex) const\r
+ // Removes a string from a list box and returns the number of strings remaining in the list.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_DELETESTRING, nIndex, 0);\r
+ }\r
+\r
+ inline int CListBox::Dir(UINT attr, LPCTSTR lpszWildCard) const\r
+ // Adds a list of filenames to a list box and returns the index of the last filename added.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_DIR, attr, (LPARAM)lpszWildCard);\r
+ }\r
+\r
+ inline int CListBox::FindString(int nStartAfter, LPCTSTR lpszItem) const\r
+ // Returns the index of the first string in the list box that begins with a specified string.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem);\r
+ }\r
+\r
+ inline int CListBox::FindStringExact(int nIndexStart, LPCTSTR lpszFind) const\r
+ // Returns the index of the string in the list box that is equal to a specified string.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);\r
+ }\r
+\r
+ inline int CListBox::InsertString(int nIndex, LPCTSTR lpszItem) const\r
+ // Inserts a string at a specified index in a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(LB_INSERTSTRING, nIndex, (LPARAM)lpszItem);\r
+ }\r
+\r
+ inline void CListBox::ResetContent() const\r
+ // Removes all items from a list box.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(LB_RESETCONTENT, 0, 0);\r
+ }\r
+\r
+ inline int CListBox::SelectString(int nStartAfter, LPCTSTR lpszItem) const\r
+ // Selects the first string it finds that matches a specified prefix.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem);\r
+ }\r
+\r
+ inline void CListBox::PreRegisterClass(WNDCLASS &wc)\r
+ {\r
+ // Set the Window Class\r
+ wc.lpszClassName = _T("ListBox");\r
+ }\r
+\r
+\r
+ ////////////////////////////////////////\r
+ // Definitions for the CStatic class\r
+ //\r
+ inline HBITMAP CStatic::GetBitmap() const\r
+ // Returns the handle to the bitmap for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HBITMAP)SendMessage(STM_GETIMAGE, IMAGE_BITMAP, 0);\r
+ }\r
+\r
+ inline HCURSOR CStatic::GetCursor() const\r
+ // Returns the handle to the icon for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HCURSOR)SendMessage(STM_GETIMAGE, IMAGE_CURSOR, 0);\r
+ }\r
+\r
+ inline HENHMETAFILE CStatic::GetEnhMetaFile() const\r
+ // Returns the handle to the enhanced metafile for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HENHMETAFILE)SendMessage(STM_GETIMAGE, IMAGE_ENHMETAFILE, 0);\r
+ }\r
+\r
+ inline HICON CStatic::GetIcon() const\r
+ // Returns the handle to the icon for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HICON)SendMessage(STM_GETIMAGE, IMAGE_ICON, 0);\r
+ }\r
+\r
+ inline HBITMAP CStatic::SetBitmap(HBITMAP hBitmap) const\r
+ // Sets the handle to the bitmap for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HBITMAP)SendMessage(STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);\r
+ }\r
+\r
+ inline HCURSOR CStatic::SetCursor(HCURSOR hCursor) const\r
+ // Sets the handle to the cursor for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HCURSOR)SendMessage(STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);\r
+ }\r
+\r
+ inline HENHMETAFILE CStatic::SetEnhMetaFile(HENHMETAFILE hMetaFile) const\r
+ // Sets the handle to the enhanced metafile for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HENHMETAFILE)SendMessage(STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile);\r
+ }\r
+\r
+ inline HICON CStatic::SetIcon(HICON hIcon) const\r
+ // Sets the handle to the icon for the static control\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (HICON)SendMessage(STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);\r
+ }\r
+\r
+ inline void CStatic::PreRegisterClass(WNDCLASS &wc)\r
+ {\r
+ // Set the Window Class\r
+ wc.lpszClassName = _T("Static");\r
+ }\r
+\r
+}\r
+\r
+#endif // _WIN32XX_STDCONTROLS_H_\r
+\r