1 // Win32++ Version 7.3
\r
2 // Released: 30th November 2011
\r
6 // url: https://sourceforge.net/projects/win32-framework
\r
9 // Copyright (c) 2005-2011 David Nash
\r
11 // Permission is hereby granted, free of charge, to
\r
12 // any person obtaining a copy of this software and
\r
13 // associated documentation files (the "Software"),
\r
14 // to deal in the Software without restriction, including
\r
15 // without limitation the rights to use, copy, modify,
\r
16 // merge, publish, distribute, sublicense, and/or sell
\r
17 // copies of the Software, and to permit persons to whom
\r
18 // the Software is furnished to do so, subject to the
\r
19 // following conditions:
\r
21 // The above copyright notice and this permission notice
\r
22 // shall be included in all copies or substantial portions
\r
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
\r
26 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
\r
27 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
\r
28 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
\r
29 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
\r
30 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
31 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
32 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
\r
33 // OR OTHER DEALINGS IN THE SOFTWARE.
\r
35 ////////////////////////////////////////////////////////
\r
38 ////////////////////////////////////////////////////////
\r
40 // Declaration of the CButton, CEdit, CListBox and CStatic classes
\r
42 // The Button, Edit, ListBox and Static controls are often referred to
\r
43 // as "standard controls". These set of older controls were originally
\r
44 // developed for Win16 operating systems (Windows 3.1 and 3.11). They use an
\r
45 // older form of notification, and send their notifications via a WM_COMMAND
\r
46 // message. Newer controls send their notifications via a WM_NOTIFY message.
\r
49 #ifndef _WIN32XX_STDCONTROLS_H_
\r
50 #define _WIN32XX_STDCONTROLS_H_
\r
52 #include "wincore.h"
\r
57 class CButton : public CWnd
\r
61 virtual ~CButton() {}
\r
64 HBITMAP GetBitmap() const;
\r
65 UINT GetButtonStyle() const;
\r
66 int GetCheck() const;
\r
67 HCURSOR GetCursor() const;
\r
68 HICON GetIcon() const;
\r
69 UINT GetState() const;
\r
70 HBITMAP SetBitmap(HBITMAP hBitmap) const;
\r
71 void SetButtonStyle(DWORD dwStyle, BOOL bRedraw) const;
\r
72 void SetCheck(int nCheckState) const;
\r
73 HCURSOR SetCursor(HCURSOR hCursor) const;
\r
74 HICON SetIcon(HICON hIcon) const;
\r
75 void SetState(BOOL bHighlight) const;
\r
79 virtual void PreCreate(CREATESTRUCT& cs);
\r
82 class CEdit : public CWnd
\r
90 BOOL CanUndo() const;
\r
91 int CharFromPos(CPoint pt) const;
\r
92 int GetFirstVisibleLine() const;
\r
93 HLOCAL GetHandle() const;
\r
94 UINT GetLimitText() const;
\r
95 int GetLine(int nIndex, LPTSTR lpszBuffer) const;
\r
96 int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const;
\r
97 int GetLineCount() const;
\r
98 DWORD GetMargins() const;
\r
99 BOOL GetModify() const;
\r
100 TCHAR GetPasswordChar() const;
\r
101 void GetRect(LPRECT lpRect) const;
\r
102 void GetSel(int& nStartChar, int& nEndChar) const;
\r
103 DWORD GetSel() const;
\r
104 CPoint PosFromChar(UINT nChar) const;
\r
105 void SetHandle(HLOCAL hBuffer) const;
\r
106 void SetLimitText(UINT nMax) const;
\r
107 void SetMargins(UINT nLeft, UINT nRight) const;
\r
108 void SetModify(BOOL bModified = TRUE) const;
\r
111 void EmptyUndoBuffer() const;
\r
112 BOOL FmtLines(BOOL bAddEOL) const;
\r
113 void LimitText(int nChars = 0) const;
\r
114 int LineFromChar(int nIndex = -1) const;
\r
115 int LineIndex(int nLine = -1) const;
\r
116 int LineLength(int nLine = -1) const;
\r
117 void LineScroll(int nLines, int nChars = 0) const;
\r
118 void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo) const;
\r
119 void SetPasswordChar(TCHAR ch) const;
\r
120 BOOL SetReadOnly(BOOL bReadOnly = TRUE) const;
\r
121 void SetRect(LPCRECT lpRect) const;
\r
122 void SetRectNP(LPCRECT lpRect) const;
\r
123 void SetSel(DWORD dwSelection, BOOL bNoScroll) const;
\r
124 void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll) const;
\r
125 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) const;
\r
126 BOOL SetTabStops() const;
\r
127 BOOL SetTabStops(const int& cxEachStop) const;
\r
129 //Clipboard Operations
\r
130 void Clear() const;
\r
133 void Paste() const;
\r
138 virtual void PreRegisterClass(WNDCLASS &wc);
\r
141 class CListBox : public CWnd
\r
145 virtual ~CListBox() {}
\r
147 // General Operations
\r
148 int GetCount() const;
\r
149 int GetHorizontalExtent() const;
\r
150 DWORD GetItemData(int nIndex) const;
\r
151 void* GetItemDataPtr(int nIndex) const;
\r
152 int GetItemHeight(int nIndex) const;
\r
153 int GetItemRect(int nIndex, LPRECT lpRect) const;
\r
154 LCID GetLocale() const;
\r
155 int GetSel(int nIndex) const;
\r
156 int GetText(int nIndex, LPTSTR lpszBuffer) const;
\r
157 int GetTextLen(int nIndex) const;
\r
158 int GetTopIndex() const;
\r
159 UINT ItemFromPoint(CPoint pt, BOOL& bOutside ) const;
\r
160 void SetColumnWidth(int cxWidth) const;
\r
161 void SetHorizontalExtent(int cxExtent) const;
\r
162 int SetItemData(int nIndex, DWORD dwItemData) const;
\r
163 int SetItemDataPtr(int nIndex, void* pData) const;
\r
164 int SetItemHeight(int nIndex, UINT cyItemHeight) const;
\r
165 LCID SetLocale(LCID nNewLocale) const;
\r
166 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) const;
\r
167 void SetTabStops() const;
\r
168 BOOL SetTabStops(const int& cxEachStop) const;
\r
169 int SetTopIndex(int nIndex) const;
\r
171 // Single-Selection Operations
\r
172 int GetCurSel() const;
\r
173 int SetCurSel(int nSelect) const;
\r
175 // Multiple-Selection Operations
\r
176 int GetAnchorIndex() const;
\r
177 int GetCaretIndex() const;
\r
178 int GetSelCount() const;
\r
179 int GetSelItems(int nMaxItems, LPINT rgIndex) const;
\r
180 int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) const;
\r
181 void SetAnchorIndex(int nIndex) const;
\r
182 int SetCaretIndex(int nIndex, BOOL bScroll) const;
\r
183 int SetSel(int nIndex, BOOL bSelect) const;
\r
185 // String Operations
\r
186 int AddString(LPCTSTR lpszItem) const;
\r
187 int DeleteString(UINT nIndex) const;
\r
188 int Dir(UINT attr, LPCTSTR lpszWildCard) const;
\r
189 int FindString(int nStartAfter, LPCTSTR lpszItem) const;
\r
190 int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
\r
191 int InsertString(int nIndex, LPCTSTR lpszItem) const;
\r
192 void ResetContent() const;
\r
193 int SelectString(int nStartAfter, LPCTSTR lpszItem) const;
\r
197 virtual void PreRegisterClass(WNDCLASS &wc);
\r
200 class CStatic : public CWnd
\r
204 virtual ~CStatic() {}
\r
207 HBITMAP GetBitmap() const;
\r
208 HCURSOR GetCursor() const;
\r
209 HENHMETAFILE GetEnhMetaFile() const;
\r
210 HICON GetIcon() const;
\r
211 HBITMAP SetBitmap(HBITMAP hBitmap) const;
\r
212 HCURSOR SetCursor(HCURSOR hCursor) const;
\r
213 HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) const;
\r
214 HICON SetIcon(HICON hIcon) const;
\r
218 virtual void PreRegisterClass(WNDCLASS &wc);
\r
225 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
231 ////////////////////////////////////////
\r
232 // Definitions for the CButton class
\r
234 inline HBITMAP CButton::GetBitmap() const
\r
235 // returns the handle to the bitmap associated with the button
\r
237 assert(::IsWindow(m_hWnd));
\r
238 return (HBITMAP)SendMessage(BM_GETIMAGE, IMAGE_BITMAP, 0);
\r
241 inline UINT CButton::GetButtonStyle() const
\r
242 // returns the style of the button
\r
244 assert(::IsWindow(m_hWnd));
\r
245 return (UINT)GetWindowLongPtr(GWL_STYLE) & 0xff;
\r
248 inline int CButton::GetCheck() const
\r
249 // returns the check state of the button
\r
251 assert(::IsWindow(m_hWnd));
\r
252 return (int)SendMessage(BM_GETCHECK, 0, 0);
\r
255 inline HCURSOR CButton::GetCursor() const
\r
256 // returns the handle to the cursor associated withe the button
\r
258 assert(::IsWindow(m_hWnd));
\r
259 return (HCURSOR)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_CURSOR, 0L);
\r
262 inline HICON CButton::GetIcon() const
\r
263 // returns the handle to the icon associated withe the button
\r
265 assert(::IsWindow(m_hWnd));
\r
266 return (HICON)SendMessage(BM_GETIMAGE, IMAGE_ICON, 0);
\r
269 inline UINT CButton::GetState() const
\r
270 // returns the state of the button
\r
272 assert(::IsWindow(m_hWnd));
\r
273 return (UINT)SendMessage(BM_GETSTATE, 0, 0);
\r
276 inline HBITMAP CButton::SetBitmap(HBITMAP hBitmap) const
\r
277 // sets the bitmap associated with the button
\r
279 assert(::IsWindow(m_hWnd));
\r
280 return (HBITMAP)SendMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
\r
283 inline void CButton::SetButtonStyle(DWORD dwStyle, BOOL bRedraw) const
\r
284 // sets the button style
\r
286 assert(::IsWindow(m_hWnd));
\r
287 SendMessage(BM_SETSTYLE, dwStyle, bRedraw);
\r
290 inline void CButton::SetCheck(int nCheckState) const
\r
291 // sets the button check state
\r
293 assert(::IsWindow(m_hWnd));
\r
294 SendMessage(BM_SETCHECK, nCheckState, 0);
\r
297 inline HCURSOR CButton::SetCursor(HCURSOR hCursor) const
\r
298 // sets the cursor associated with the button
\r
300 assert(::IsWindow(m_hWnd));
\r
301 return (HCURSOR)SendMessage(STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);
\r
304 inline HICON CButton::SetIcon(HICON hIcon) const
\r
305 // sets the icon associated with the button
\r
307 assert(::IsWindow(m_hWnd));
\r
308 return (HICON)SendMessage( BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
\r
311 inline void CButton::SetState(BOOL bHighlight) const
\r
312 // sets the button state
\r
314 assert(::IsWindow(m_hWnd));
\r
315 SendMessage(BM_SETSTATE, bHighlight, 0);
\r
318 inline void CButton::PreCreate(CREATESTRUCT& cs)
\r
320 cs.lpszClass = _T("Button");
\r
324 ////////////////////////////////////////
\r
325 // Definitions for the CEdit class
\r
327 inline BOOL CEdit::CanUndo() const
\r
328 // Returns TRUE if the edit control operation can be undone.
\r
330 assert(::IsWindow(m_hWnd));
\r
331 return (BOOL)SendMessage(EM_CANUNDO, 0, 0);
\r
334 inline int CEdit::CharFromPos(CPoint pt) const
\r
335 // Returns the character index and line index of the character nearest the specified point.
\r
337 assert(::IsWindow(m_hWnd));
\r
338 return (int)SendMessage(EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y));
\r
341 inline int CEdit::GetFirstVisibleLine() const
\r
342 // Returns the zero-based index of the first visible character in a single-line edit control
\r
343 // or the zero-based index of the uppermost visible line in a multiline edit control.
\r
345 assert(::IsWindow(m_hWnd));
\r
346 return (int)SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0);
\r
349 inline HLOCAL CEdit::GetHandle() const
\r
350 // Returns a handle identifying the buffer containing the multiline edit control's text.
\r
351 // It is not processed by single-line edit controls.
\r
353 assert(::IsWindow(m_hWnd));
\r
354 return (HLOCAL)SendMessage(EM_GETHANDLE, 0, 0);
\r
357 inline UINT CEdit::GetLimitText() const
\r
358 // Returns the current text limit, in characters.
\r
360 assert(::IsWindow(m_hWnd));
\r
361 return (UINT)SendMessage(EM_GETLIMITTEXT, 0, 0);
\r
364 inline int CEdit::GetLine(int nIndex, LPTSTR lpszBuffer) const
\r
365 // Copies characters to a buffer and returns the number of characters copied.
\r
367 assert(::IsWindow(m_hWnd));
\r
368 return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
\r
371 inline int CEdit::GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const
\r
372 // Copies characters to a buffer and returns the number of characters copied.
\r
374 assert(::IsWindow(m_hWnd));
\r
375 *(LPWORD)lpszBuffer = (WORD)nMaxLength;
\r
376 return (int)SendMessage(EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
\r
379 inline int CEdit::GetLineCount() const
\r
380 // Returns the number of lines in the edit control.
\r
382 assert(::IsWindow(m_hWnd));
\r
383 return (int)SendMessage(EM_GETLINECOUNT, 0, 0);
\r
386 inline DWORD CEdit::GetMargins() const
\r
387 // Returns the widths of the left and right margins.
\r
389 assert(::IsWindow(m_hWnd));
\r
390 return (DWORD)SendMessage(EM_GETMARGINS, 0, 0);
\r
393 inline BOOL CEdit::GetModify() const
\r
394 // Returns a flag indicating whether the content of an edit control has been modified.
\r
396 assert(::IsWindow(m_hWnd));
\r
397 return (BOOL)SendMessage(EM_GETMODIFY, 0, 0);
\r
400 inline TCHAR CEdit::GetPasswordChar() const
\r
401 // Returns the character that edit controls use in conjunction with the ES_PASSWORD style.
\r
403 assert(::IsWindow(m_hWnd));
\r
404 return (TCHAR)SendMessage(EM_GETPASSWORDCHAR, 0, 0);
\r
407 inline void CEdit::GetRect(LPRECT lpRect) const
\r
408 // Returns the coordinates of the formatting rectangle in an edit control.
\r
410 assert(::IsWindow(m_hWnd));
\r
411 SendMessage(EM_GETRECT, 0, (LPARAM)lpRect);
\r
414 inline void CEdit::GetSel(int& nStartChar, int& nEndChar) const
\r
415 // Returns the starting and ending character positions of the current selection in the edit control.
\r
417 assert(::IsWindow(m_hWnd));
\r
418 SendMessage(EM_GETSEL, (WPARAM)&nStartChar,(LPARAM)&nEndChar);
\r
421 inline DWORD CEdit::GetSel() const
\r
422 // Returns the starting and ending character positions of the current selection in the edit control.
\r
424 assert(::IsWindow(m_hWnd));
\r
425 return (DWORD)SendMessage(EM_GETSEL, 0, 0);
\r
428 inline CPoint CEdit::PosFromChar(UINT nChar) const
\r
429 // Returns the client coordinates of the specified character.
\r
431 assert(::IsWindow(m_hWnd));
\r
432 return CPoint( (DWORD)SendMessage(EM_POSFROMCHAR, nChar, 0));
\r
435 inline void CEdit::SetHandle(HLOCAL hBuffer) const
\r
436 // Sets a handle to the memory used as a text buffer, empties the undo buffer,
\r
437 // resets the scroll positions to zero, and redraws the window.
\r
439 assert(::IsWindow(m_hWnd));
\r
440 SendMessage(EM_SETHANDLE, (WPARAM)hBuffer, 0);
\r
443 inline void CEdit::SetLimitText(UINT nMax) const
\r
444 // Sets the maximum number of characters the user may enter in the edit control.
\r
446 assert(::IsWindow(m_hWnd));
\r
447 SendMessage(EM_SETLIMITTEXT, (WPARAM)nMax, 0);
\r
450 inline void CEdit::SetMargins(UINT nLeft, UINT nRight) const
\r
451 // Sets the widths of the left and right margins, and redraws the edit control to reflect the new margins.
\r
453 assert(::IsWindow(m_hWnd));
\r
454 SendMessage(EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(nLeft, nRight));
\r
457 inline void CEdit::SetModify(BOOL bModified) const
\r
458 // Sets or clears the modification flag to indicate whether the edit control has been modified.
\r
460 assert(::IsWindow(m_hWnd));
\r
461 SendMessage(EM_SETMODIFY, bModified, 0);
\r
464 inline void CEdit::EmptyUndoBuffer() const
\r
465 // Empties the undo buffer and sets the undo flag retrieved by the EM_CANUNDO message to FALSE.
\r
467 assert(::IsWindow(m_hWnd));
\r
468 SendMessage(EM_EMPTYUNDOBUFFER, 0, 0);
\r
471 inline BOOL CEdit::FmtLines(BOOL bAddEOL) const
\r
472 // Adds or removes soft line-break characters (two carriage returns and a line feed) to the ends of wrapped lines
\r
473 // in a multiline edit control. It is not processed by single-line edit controls.
\r
475 assert(::IsWindow(m_hWnd));
\r
476 return (BOOL)SendMessage(EM_FMTLINES, bAddEOL, 0);
\r
479 inline void CEdit::LimitText(int nChars) const
\r
480 // Sets the text limit of an edit control. The text limit is the maximum amount of text, in TCHARs,
\r
481 // that the user can type into the edit control.
\r
483 assert(::IsWindow(m_hWnd));
\r
484 SendMessage(EM_LIMITTEXT, nChars, 0);
\r
487 inline int CEdit::LineFromChar(int nIndex) const
\r
488 // Returns the zero-based number of the line in a multiline edit control that contains a specified character index.
\r
489 // This message is the reverse of the EM_LINEINDEX message.
\r
491 assert(::IsWindow(m_hWnd));
\r
492 return (int)SendMessage(EM_LINEFROMCHAR, (WPARAM)nIndex, 0);
\r
495 inline int CEdit::LineIndex(int nLine) const
\r
496 // Returns the character of a line in a multiline edit control.
\r
497 // This message is the reverse of the EM_LINEFROMCHAR message
\r
499 assert(::IsWindow(m_hWnd));
\r
500 return (int)SendMessage(EM_LINEINDEX, (WPARAM)nLine, 0);
\r
503 inline int CEdit::LineLength(int nLine) const
\r
504 // Returns the length, in characters, of a single-line edit control. In a multiline edit control,
\r
505 // returns the length, in characters, of a specified line.
\r
507 assert(::IsWindow(m_hWnd));
\r
508 return (int)SendMessage(EM_LINELENGTH, (WPARAM)nLine, 0);
\r
511 inline void CEdit::LineScroll(int nLines, int nChars) const
\r
512 // Scrolls the text vertically in a single-line edit control or horizontally in a multiline edit control.
\r
514 assert(::IsWindow(m_hWnd));
\r
515 SendMessage(EM_LINESCROLL, (WPARAM)nChars, (LPARAM)nLines);
\r
518 inline void CEdit::ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo) const
\r
519 // Replaces the current selection with the text in an application-supplied buffer, sends the parent window
\r
520 // EN_UPDATE and EN_CHANGE messages, and updates the undo buffer.
\r
522 assert(::IsWindow(m_hWnd));
\r
523 SendMessage(EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText);
\r
526 inline void CEdit::SetPasswordChar(TCHAR ch) const
\r
527 // Defines the character that edit controls use in conjunction with the ES_PASSWORD style.
\r
529 assert(::IsWindow(m_hWnd));
\r
530 SendMessage(EM_SETPASSWORDCHAR, ch, 0);
\r
533 inline BOOL CEdit::SetReadOnly(BOOL bReadOnly) const
\r
534 // Sets or removes the read-only style (ES_READONLY) in an edit control.
\r
536 assert(::IsWindow(m_hWnd));
\r
537 return (BOOL)SendMessage(EM_SETREADONLY, bReadOnly, 0);
\r
540 inline void CEdit::SetRect(LPCRECT lpRect) const
\r
541 // Sets the formatting rectangle for the multiline edit control and redraws the window.
\r
543 assert(::IsWindow(m_hWnd));
\r
544 SendMessage(EM_SETRECT, 0, (LPARAM)lpRect);
\r
547 inline void CEdit::SetRectNP(LPCRECT lpRect) const
\r
548 // Sets the formatting rectangle for the multiline edit control but does not redraw the window.
\r
550 assert(::IsWindow(m_hWnd));
\r
551 SendMessage(EM_SETRECTNP, 0, (LPARAM)lpRect);
\r
554 inline void CEdit::SetSel(DWORD dwSelection, BOOL bNoScroll) const
\r
555 // Selects a range of characters in the edit control by setting the starting and ending positions to be selected.
\r
557 assert(::IsWindow(m_hWnd));
\r
558 SendMessage(EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection));
\r
560 SendMessage(EM_SCROLLCARET, 0, 0);
\r
563 inline void CEdit::SetSel(int nStartChar, int nEndChar, BOOL bNoScroll) const
\r
564 // Selects a range of characters in the edit control by setting the starting and ending positions to be selected.
\r
566 assert(::IsWindow(m_hWnd));
\r
567 SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);
\r
569 SendMessage(EM_SCROLLCARET, 0, 0);
\r
572 inline BOOL CEdit::SetTabStops(int nTabStops, LPINT rgTabStops) const
\r
573 // Sets tab-stop positions in the multiline edit control.
\r
575 assert(::IsWindow(m_hWnd));
\r
576 return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
\r
579 inline BOOL CEdit::SetTabStops() const
\r
580 // Sets tab-stop positions in the multiline edit control.
\r
582 assert(::IsWindow(m_hWnd));
\r
583 return (BOOL)SendMessage( EM_SETTABSTOPS, 0, 0);
\r
586 inline BOOL CEdit::SetTabStops(const int& cxEachStop) const
\r
587 // Sets tab-stop positions in the multiline edit control.
\r
589 assert(::IsWindow(m_hWnd));
\r
590 return (BOOL)SendMessage(EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
\r
593 inline void CEdit::Clear() const
\r
594 // Clears the current selection, if any, in an edit control.
\r
596 assert(::IsWindow(m_hWnd));
\r
597 SendMessage(WM_CLEAR, 0, 0);
\r
600 inline void CEdit::Copy() const
\r
601 // Copies text to the clipboard unless the style is ES_PASSWORD, in which case the message returns zero.
\r
603 assert(::IsWindow(m_hWnd));
\r
604 SendMessage(WM_COPY, 0, 0);
\r
607 inline void CEdit::Cut() const
\r
608 // Cuts the selection to the clipboard, or deletes the character to the left of the cursor if there is no selection.
\r
610 assert(::IsWindow(m_hWnd));
\r
611 SendMessage(WM_CUT, 0, 0);
\r
614 inline void CEdit::Paste() const
\r
615 // Pastes text from the clipboard into the edit control window at the caret position.
\r
617 assert(::IsWindow(m_hWnd));
\r
618 SendMessage(WM_PASTE, 0, 0);
\r
621 inline void CEdit::Undo() const
\r
622 // Removes any text that was just inserted or inserts any deleted characters and sets the selection to the inserted text.
\r
624 assert(::IsWindow(m_hWnd));
\r
625 SendMessage(EM_UNDO, 0, 0);
\r
628 inline void CEdit::PreRegisterClass(WNDCLASS &wc)
\r
630 // Set the Window Class
\r
631 wc.lpszClassName = _T("Edit");
\r
635 ////////////////////////////////////////
\r
636 // Definitions for the CListbox class
\r
638 inline int CListBox::GetCount() const
\r
639 // Returns the number of items in the list box.
\r
641 assert(::IsWindow(m_hWnd));
\r
642 return (int)SendMessage(LB_GETCOUNT, 0, 0);
\r
645 inline int CListBox::GetHorizontalExtent() const
\r
646 // Returns the scrollable width, in pixels, of a list box.
\r
648 assert(::IsWindow(m_hWnd));
\r
649 return (int)SendMessage(LB_GETHORIZONTALEXTENT, 0, 0);
\r
652 inline DWORD CListBox::GetItemData(int nIndex) const
\r
653 // Returns the value associated with the specified item.
\r
655 assert(::IsWindow(m_hWnd));
\r
656 return (DWORD)SendMessage(LB_GETITEMDATA, nIndex, 0);
\r
659 inline void* CListBox::GetItemDataPtr(int nIndex) const
\r
660 // Returns the value associated with the specified item.
\r
662 assert(::IsWindow(m_hWnd));
\r
663 return (LPVOID)SendMessage(LB_GETITEMDATA, nIndex, 0);
\r
666 inline int CListBox::GetItemHeight(int nIndex) const
\r
667 // Returns the height, in pixels, of an item in a list box.
\r
669 assert(::IsWindow(m_hWnd));
\r
670 return (int)SendMessage(LB_GETITEMHEIGHT, nIndex, 0L);
\r
673 inline int CListBox::GetItemRect(int nIndex, LPRECT lpRect) const
\r
674 // Retrieves the client coordinates of the specified list box item.
\r
676 assert(::IsWindow(m_hWnd));
\r
677 return (int)SendMessage(LB_GETITEMRECT, nIndex, (LPARAM)lpRect);
\r
680 inline LCID CListBox::GetLocale() const
\r
681 // Retrieves the locale of the list box. The high-order word contains the country/region code
\r
682 // and the low-order word contains the language identifier.
\r
684 assert(::IsWindow(m_hWnd));
\r
685 return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0);
\r
688 inline int CListBox::GetSel(int nIndex) const
\r
689 // Returns the selection state of a list box item.
\r
691 assert(::IsWindow(m_hWnd));
\r
692 return (int)SendMessage(LB_GETSEL, nIndex, 0);
\r
695 inline int CListBox::GetText(int nIndex, LPTSTR lpszBuffer) const
\r
696 // Retrieves the string associated with a specified item and the length of the string.
\r
698 assert(::IsWindow(m_hWnd));
\r
699 return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer);
\r
702 inline int CListBox::GetTextLen(int nIndex) const
\r
703 // Returns the length, in characters, of the string associated with a specified item.
\r
705 assert(::IsWindow(m_hWnd));
\r
706 return (int)SendMessage( LB_GETTEXTLEN, nIndex, 0);
\r
709 inline int CListBox::GetTopIndex() const
\r
710 // Returns the index of the first visible item in a list box.
\r
712 assert(::IsWindow(m_hWnd));
\r
713 return (int)SendMessage(LB_GETTOPINDEX, 0, 0);
\r
716 inline UINT CListBox::ItemFromPoint(CPoint pt, BOOL& bOutside) const
\r
717 // Retrieves the zero-based index of the item nearest the specified point in a list box.
\r
719 assert(::IsWindow(m_hWnd));
\r
720 DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
\r
721 bOutside = !!HIWORD(dw);
\r
725 inline void CListBox::SetColumnWidth(int cxWidth) const
\r
726 // Sets the width, in pixels, of all columns in a list box.
\r
728 assert(::IsWindow(m_hWnd));
\r
729 SendMessage(LB_SETCOLUMNWIDTH, cxWidth, 0);
\r
732 inline void CListBox::SetHorizontalExtent(int cxExtent) const
\r
733 // Sets the scrollable width, in pixels, of a list box.
\r
735 assert(::IsWindow(m_hWnd));
\r
736 SendMessage(LB_SETHORIZONTALEXTENT, cxExtent, 0);
\r
739 inline int CListBox::SetItemData(int nIndex, DWORD dwItemData) const
\r
740 // Associates a value with a list box item.
\r
742 assert(::IsWindow(m_hWnd));
\r
743 return (int)SendMessage(LB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
\r
746 inline int CListBox::SetItemDataPtr(int nIndex, void* pData) const
\r
747 // Associates a value with a list box item.
\r
749 assert(::IsWindow(m_hWnd));
\r
750 return SetItemData(nIndex, (DWORD)(DWORD_PTR)pData);
\r
753 inline int CListBox::SetItemHeight(int nIndex, UINT cyItemHeight) const
\r
754 // Sets the height, in pixels, of an item or items in a list box.
\r
756 assert(::IsWindow(m_hWnd));
\r
757 return (int)SendMessage(LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
\r
760 inline LCID CListBox::SetLocale(LCID nNewLocale) const
\r
761 // Sets the locale of a list box and returns the previous locale identifier.
\r
763 assert(::IsWindow(m_hWnd));
\r
764 return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0);
\r
767 inline BOOL CListBox::SetTabStops(int nTabStops, LPINT rgTabStops) const
\r
768 // Sets the tab stops to those specified in a specified array.
\r
770 assert(::IsWindow(m_hWnd));
\r
771 return (BOOL)SendMessage(LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
\r
774 inline void CListBox::SetTabStops() const
\r
775 // Sets the tab stops to those specified in a specified array.
\r
777 assert(::IsWindow(m_hWnd));
\r
778 SendMessage(LB_SETTABSTOPS, 0, 0);
\r
781 inline BOOL CListBox::SetTabStops(const int& cxEachStop) const
\r
782 // Sets the tab stops to those specified in a specified array.
\r
784 assert(::IsWindow(m_hWnd));
\r
785 return (BOOL)SendMessage(LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
\r
788 inline int CListBox::SetTopIndex(int nIndex) const
\r
789 // Scrolls the list box so the specified item is at the top of the visible range.
\r
791 assert(::IsWindow(m_hWnd));
\r
792 return (int)SendMessage(LB_SETTOPINDEX, nIndex, 0);
\r
795 inline int CListBox::GetCurSel() const
\r
796 // Returns the index of the currently selected item.
\r
798 assert(::IsWindow(m_hWnd));
\r
799 return (int)SendMessage(LB_GETCURSEL, 0, 0);
\r
802 inline int CListBox::SetCurSel(int nSelect) const
\r
803 // Selects a specified list box item.
\r
805 assert(::IsWindow(m_hWnd));
\r
806 return (int)SendMessage(LB_SETCURSEL, nSelect, 0);
\r
809 inline int CListBox::GetAnchorIndex() const
\r
810 // Returns the index of the item that the mouse last selected.
\r
812 assert(::IsWindow(m_hWnd));
\r
813 return (int)SendMessage(LB_GETANCHORINDEX, 0, 0);
\r
816 inline int CListBox::GetCaretIndex() const
\r
817 // Returns the index of the item that has the focus rectangle.
\r
819 assert(::IsWindow(m_hWnd));
\r
820 return (int)SendMessage(LB_GETCARETINDEX, 0, 0L);
\r
823 inline int CListBox::GetSelCount() const
\r
824 // Returns the number of selected items in a multiple-selection list box.
\r
826 assert(::IsWindow(m_hWnd));
\r
827 return (int)SendMessage(LB_GETSELCOUNT, 0, 0);
\r
830 inline int CListBox::GetSelItems(int nMaxItems, LPINT rgIndex) const
\r
831 // Creates an array of the indexes of all selected items in a multiple-selection list box
\r
832 // and returns the total number of selected items.
\r
834 assert(::IsWindow(m_hWnd));
\r
835 return (int)SendMessage(LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex);
\r
838 inline int CListBox::SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) const
\r
839 // Selects a specified range of items in a list box.
\r
841 assert(::IsWindow(m_hWnd));
\r
843 return (int)SendMessage(LB_SELITEMRANGEEX, nFirstItem, nLastItem);
\r
845 return (int)SendMessage(LB_SELITEMRANGEEX, nLastItem, nFirstItem);
\r
848 inline void CListBox::SetAnchorIndex(int nIndex) const
\r
849 // Sets the item that the mouse last selected to a specified item.
\r
851 assert(::IsWindow(m_hWnd));
\r
852 SendMessage(LB_SETANCHORINDEX, nIndex, 0);
\r
855 inline int CListBox::SetCaretIndex(int nIndex, BOOL bScroll) const
\r
856 // Sets the focus rectangle to a specified list box item.
\r
858 assert(::IsWindow(m_hWnd));
\r
859 return (int)SendMessage(LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0));
\r
862 inline int CListBox::SetSel(int nIndex, BOOL bSelect) const
\r
863 // Selects an item in a multiple-selection list box.
\r
865 assert(::IsWindow(m_hWnd));
\r
866 return (int)SendMessage(LB_SETSEL, bSelect, nIndex);
\r
869 inline int CListBox::AddString(LPCTSTR lpszItem) const
\r
870 // Adds a string to a list box and returns its index.
\r
872 assert(::IsWindow(m_hWnd));
\r
873 return (int)SendMessage(LB_ADDSTRING, 0, (LPARAM)lpszItem);
\r
876 inline int CListBox::DeleteString(UINT nIndex) const
\r
877 // Removes a string from a list box and returns the number of strings remaining in the list.
\r
879 assert(::IsWindow(m_hWnd));
\r
880 return (int)SendMessage(LB_DELETESTRING, nIndex, 0);
\r
883 inline int CListBox::Dir(UINT attr, LPCTSTR lpszWildCard) const
\r
884 // Adds a list of filenames to a list box and returns the index of the last filename added.
\r
886 assert(::IsWindow(m_hWnd));
\r
887 return (int)SendMessage(LB_DIR, attr, (LPARAM)lpszWildCard);
\r
890 inline int CListBox::FindString(int nStartAfter, LPCTSTR lpszItem) const
\r
891 // Returns the index of the first string in the list box that begins with a specified string.
\r
893 assert(::IsWindow(m_hWnd));
\r
894 return (int)SendMessage(LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem);
\r
897 inline int CListBox::FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
\r
898 // Returns the index of the string in the list box that is equal to a specified string.
\r
900 assert(::IsWindow(m_hWnd));
\r
901 return (int)SendMessage(LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
\r
904 inline int CListBox::InsertString(int nIndex, LPCTSTR lpszItem) const
\r
905 // Inserts a string at a specified index in a list box.
\r
907 assert(::IsWindow(m_hWnd));
\r
908 return (int)SendMessage(LB_INSERTSTRING, nIndex, (LPARAM)lpszItem);
\r
911 inline void CListBox::ResetContent() const
\r
912 // Removes all items from a list box.
\r
914 assert(::IsWindow(m_hWnd));
\r
915 SendMessage(LB_RESETCONTENT, 0, 0);
\r
918 inline int CListBox::SelectString(int nStartAfter, LPCTSTR lpszItem) const
\r
919 // Selects the first string it finds that matches a specified prefix.
\r
921 assert(::IsWindow(m_hWnd));
\r
922 return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem);
\r
925 inline void CListBox::PreRegisterClass(WNDCLASS &wc)
\r
927 // Set the Window Class
\r
928 wc.lpszClassName = _T("ListBox");
\r
932 ////////////////////////////////////////
\r
933 // Definitions for the CStatic class
\r
935 inline HBITMAP CStatic::GetBitmap() const
\r
936 // Returns the handle to the bitmap for the static control
\r
938 assert(::IsWindow(m_hWnd));
\r
939 return (HBITMAP)SendMessage(STM_GETIMAGE, IMAGE_BITMAP, 0);
\r
942 inline HCURSOR CStatic::GetCursor() const
\r
943 // Returns the handle to the icon for the static control
\r
945 assert(::IsWindow(m_hWnd));
\r
946 return (HCURSOR)SendMessage(STM_GETIMAGE, IMAGE_CURSOR, 0);
\r
949 inline HENHMETAFILE CStatic::GetEnhMetaFile() const
\r
950 // Returns the handle to the enhanced metafile for the static control
\r
952 assert(::IsWindow(m_hWnd));
\r
953 return (HENHMETAFILE)SendMessage(STM_GETIMAGE, IMAGE_ENHMETAFILE, 0);
\r
956 inline HICON CStatic::GetIcon() const
\r
957 // Returns the handle to the icon for the static control
\r
959 assert(::IsWindow(m_hWnd));
\r
960 return (HICON)SendMessage(STM_GETIMAGE, IMAGE_ICON, 0);
\r
963 inline HBITMAP CStatic::SetBitmap(HBITMAP hBitmap) const
\r
964 // Sets the handle to the bitmap for the static control
\r
966 assert(::IsWindow(m_hWnd));
\r
967 return (HBITMAP)SendMessage(STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
\r
970 inline HCURSOR CStatic::SetCursor(HCURSOR hCursor) const
\r
971 // Sets the handle to the cursor for the static control
\r
973 assert(::IsWindow(m_hWnd));
\r
974 return (HCURSOR)SendMessage(STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);
\r
977 inline HENHMETAFILE CStatic::SetEnhMetaFile(HENHMETAFILE hMetaFile) const
\r
978 // Sets the handle to the enhanced metafile for the static control
\r
980 assert(::IsWindow(m_hWnd));
\r
981 return (HENHMETAFILE)SendMessage(STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile);
\r
984 inline HICON CStatic::SetIcon(HICON hIcon) const
\r
985 // Sets the handle to the icon for the static control
\r
987 assert(::IsWindow(m_hWnd));
\r
988 return (HICON)SendMessage(STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
\r
991 inline void CStatic::PreRegisterClass(WNDCLASS &wc)
\r
993 // Set the Window Class
\r
994 wc.lpszClassName = _T("Static");
\r
999 #endif // _WIN32XX_STDCONTROLS_H_
\r