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 following classes:
\r
41 // CAnimation, CComboBox, CComboBoxEx, CDateTime, CIPAddress,
\r
42 // CHeader, CHotKey, CMonthCalendar, CProgressBar, CScrollBar,
\r
43 // CSlider, CSpinButton, and CToolTip.
\r
46 #ifndef _WIN32XX_CONTROLS_H_
\r
47 #define _WIN32XX_CONTROLS_H_
\r
49 #include "wincore.h"
\r
50 #include "stdcontrols.h"
\r
55 // Forward declarations
\r
56 class CMonthCalendar;
\r
59 class CAnimation : public CWnd
\r
63 virtual ~CAnimation() {}
\r
66 BOOL Open(LPTSTR lpszName) const;
\r
67 BOOL Play(UINT wFrom, UINT wTo, UINT cRepeat) const;
\r
68 BOOL Seek(UINT wFrame) const;
\r
73 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = ANIMATE_CLASS; }
\r
77 class CComboBox : public CWnd
\r
81 virtual ~CComboBox() { ::InitCommonControls(); }
\r
83 int AddString(LPCTSTR lpszString) const;
\r
87 int DeleteString(int nIndex) const;
\r
88 int Dir(UINT attr, LPCTSTR lpszWildCard ) const;
\r
89 int FindString(int nIndexStart, LPCTSTR lpszString) const;
\r
90 int FindStringExact(int nIndexStart, LPCTSTR lpszString) const;
\r
91 int GetCount() const;
\r
92 int GetCurSel() const;
\r
93 CRect GetDroppedControlRect() const;
\r
94 BOOL GetDroppedState() const;
\r
95 int GetDroppedWidth() const;
\r
96 DWORD GetEditSel() const;
\r
97 BOOL GetExtendedUI() const;
\r
98 int GetHorizontalExtent() const;
\r
99 DWORD GetItemData(int nIndex) const;
\r
100 int GetItemHeight(int nIndex) const;
\r
101 int GetLBText(int nIndex, LPTSTR lpszText) const;
\r
102 int GetLBTextLen(int nIndex) const;
\r
103 LCID GetLocale() const;
\r
104 int GetTopIndex() const;
\r
105 int InitStorage(int nItems, int nBytes) const;
\r
106 int InsertString(int nIndex, LPCTSTR lpszString) const;
\r
107 void LimitText(int nMaxChars) const;
\r
108 void Paste() const;
\r
109 void ResetContent() const;
\r
110 int SelectString(int nStartAfter, LPCTSTR lpszString) const;
\r
111 int SetCurSel(int nIndex) const;
\r
112 int SetDroppedWidth(int nWidth) const;
\r
113 BOOL SetEditSel(int nStartChar, int nEndChar) const;
\r
114 int SetExtendedUI(BOOL bExtended = TRUE) const;
\r
115 void SetHorizontalExtent(UINT nExtent ) const;
\r
116 int SetItemData(int nIndex, DWORD dwItemData) const;
\r
117 int SetItemHeight(int nIndex, UINT cyItemHeight) const;
\r
118 LCID SetLocale( LCID NewLocale ) const;
\r
119 int SetTopIndex(int nIndex) const;
\r
120 void ShowDropDown(BOOL bShow = TRUE) const;
\r
124 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = _T("ComboBox"); }
\r
128 class CComboBoxEx : public CComboBox
\r
133 INITCOMMONCONTROLSEX icce;
\r
134 icce.dwSize = sizeof(INITCOMMONCONTROLSEX);
\r
135 icce.dwICC = ICC_USEREX_CLASSES;
\r
136 ::InitCommonControlsEx(&icce);
\r
138 virtual ~CComboBoxEx() {}
\r
140 int DeleteItem(int nIndex ) const;
\r
141 CWnd* GetComboBoxCtrl() const;
\r
142 CEdit* GetEditCtrl() const;
\r
143 DWORD GetExtendedStyle() const;
\r
144 HIMAGELIST GetImageList() const;
\r
145 BOOL GetItem(COMBOBOXEXITEM* pCBItem) const;
\r
146 BOOL HasEditChanged () const;
\r
147 int InsertItem(COMBOBOXEXITEM* lpcCBItem) const;
\r
148 DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyles ) const;
\r
149 HIMAGELIST SetImageList(HIMAGELIST himl) const;
\r
150 BOOL SetItem(PCOMBOBOXEXITEM lpcCBItem) const;
\r
154 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = WC_COMBOBOXEX; }
\r
158 class CDateTime : public CWnd
\r
163 INITCOMMONCONTROLSEX icce;
\r
164 icce.dwSize = sizeof(INITCOMMONCONTROLSEX);
\r
165 icce.dwICC = ICC_DATE_CLASSES;
\r
166 ::InitCommonControlsEx(&icce);
\r
168 virtual ~CDateTime() {}
\r
170 COLORREF GetMonthCalColor(int iColor) const;
\r
171 COLORREF SetMonthCalColor(int iColor, COLORREF ref);
\r
172 BOOL SetFormat(LPCTSTR pstrFormat);
\r
173 CMonthCalendar* GetMonthCalCtrl() const;
\r
174 CFont* GetMonthCalFont() const;
\r
175 void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE);
\r
176 DWORD GetRange(LPSYSTEMTIME lpSysTimeArray) const;
\r
177 BOOL SetRange(DWORD flags, LPSYSTEMTIME lpSysTimeArray);
\r
178 DWORD GetTime(LPSYSTEMTIME pTimeDest) const;
\r
179 BOOL SetTime(DWORD flag, LPSYSTEMTIME pTimeNew = NULL);
\r
183 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = DATETIMEPICK_CLASS; }
\r
186 class CHeader : public CWnd
\r
191 INITCOMMONCONTROLSEX icex;
\r
192 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
\r
193 icex.dwICC = ICC_WIN95_CLASSES;
\r
194 ::InitCommonControlsEx(&icex);
\r
196 virtual ~CHeader() {}
\r
199 HIMAGELIST GetImageList() const;
\r
200 BOOL GetItem(int nPos, HDITEM* pHeaderItem) const;
\r
201 int GetItemCount() const;
\r
202 CRect GetItemRect(int nIndex) const;
\r
203 BOOL GetOrderArray(LPINT piArray, int iCount);
\r
204 int OrderToIndex(int nOrder) const;
\r
205 HIMAGELIST SetImageList(HIMAGELIST himl);
\r
206 BOOL SetItem(int nPos, HDITEM* pHeaderItem);
\r
207 BOOL SetOrderArray(int iCount, LPINT piArray);
\r
208 int GetBitmapMargin() const;
\r
209 int SetBitmapMargin(int nWidth);
\r
212 HIMAGELIST CreateDragImage(int nIndex);
\r
213 BOOL DeleteItem(int nPos);
\r
214 int InsertItem(int nPos, HDITEM* phdi);
\r
215 BOOL Layout(HDLAYOUT* pHeaderLayout);
\r
216 #ifdef Header_SetHotDivider
\r
217 int SetHotDivider(CPoint pt);
\r
218 int SetHotDivider(int nIndex);
\r
220 #ifdef Header_ClearFilter
\r
221 int ClearAllFilters();
\r
222 int ClearFilter(int nColumn);
\r
223 int EditFilter(int nColumn, BOOL bDiscardChanges);
\r
224 int SetFilterChangeTimeout(DWORD dwTimeOut);
\r
229 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = WC_HEADER ; }
\r
232 class CHotKey : public CWnd
\r
235 CHotKey() { ::InitCommonControls(); }
\r
236 virtual ~CHotKey() {}
\r
238 DWORD GetHotKey() const;
\r
239 CString GetKeyName(UINT vk, BOOL fExtended) const;
\r
240 void SetHotKey(DWORD dwKey);
\r
241 void SetRules(WORD wInvalidComb, WORD wModifiers);
\r
245 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = HOTKEY_CLASS; }
\r
248 class CIPAddress : public CWnd
\r
253 INITCOMMONCONTROLSEX icex;
\r
254 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
\r
255 icex.dwICC = ICC_INTERNET_CLASSES;
\r
256 ::InitCommonControlsEx(&icex);
\r
258 virtual ~CIPAddress() {}
\r
260 void ClearAddress();
\r
261 int GetAddress(BYTE& nField0, BYTE& nField1, BYTE& nField2, BYTE& nField3);
\r
262 int GetAddress(DWORD* dwAddress);
\r
263 BOOL IsBlank() const;
\r
264 void SetAddress(BYTE nField0, BYTE nField1, BYTE nField2, BYTE nField3);
\r
265 void SetAddress(DWORD dwAddress);
\r
266 void SetFieldFocus(WORD nField);
\r
267 void SetFieldRange(int nField, BYTE nLower, BYTE nUpper);
\r
271 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = WC_IPADDRESS; }
\r
275 class CMonthCalendar : public CWnd
\r
280 INITCOMMONCONTROLSEX icex;
\r
281 icex.dwSize = sizeof(icex);
\r
282 icex.dwICC = ICC_DATE_CLASSES;
\r
283 InitCommonControlsEx(&icex);
\r
285 virtual ~CMonthCalendar() {}
\r
288 COLORREF GetColor(int nRegion) const;
\r
289 int GetFirstDayOfWeek(BOOL* pbLocal = NULL) const;
\r
290 CRect GetMinReqRect() const;
\r
291 int GetMonthDelta() const;
\r
292 COLORREF SetColor(int nRegion, COLORREF ref);
\r
293 BOOL SetFirstDayOfWeek(int iDay, int* lpnOld = NULL);
\r
294 int SetMonthDelta(int iDelta);
\r
297 BOOL GetCurSel(LPSYSTEMTIME pDateTime) const;
\r
298 int GetMaxSelCount() const;
\r
299 int GetMonthRange(LPSYSTEMTIME pMinRange, LPSYSTEMTIME pMaxRange, DWORD dwFlags) const;
\r
300 DWORD GetRange(LPSYSTEMTIME pMinRange, LPSYSTEMTIME pMaxRange) const;
\r
301 BOOL GetSelRange(LPSYSTEMTIME pMinRange, LPSYSTEMTIME pMaxRange) const;
\r
302 BOOL GetToday(LPSYSTEMTIME pDateTime) const;
\r
303 DWORD HitTest(PMCHITTESTINFO pMCHitTest);
\r
304 BOOL SetCurSel(const LPSYSTEMTIME pDateTime);
\r
305 BOOL SetDayState(int nMonths, LPMONTHDAYSTATE pStates);
\r
306 BOOL SetMaxSelCount(int nMax);
\r
307 BOOL SetRange(const LPSYSTEMTIME pMinRange, const LPSYSTEMTIME pMaxRange);
\r
308 BOOL SetSelRange(const LPSYSTEMTIME pMinRange, const LPSYSTEMTIME pMaxRange);
\r
309 void SetToday(const LPSYSTEMTIME pDateTime);
\r
313 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = MONTHCAL_CLASS; }
\r
316 class CProgressBar : public CWnd
\r
319 CProgressBar() { ::InitCommonControls(); }
\r
320 virtual ~CProgressBar() {}
\r
322 int GetPos() const;
\r
323 int GetRange(BOOL fWhichLimit, PPBRANGE ppBRange) const;
\r
324 int OffsetPos(int nIncrement) const;
\r
325 int SetPos(int nNewPos) const;
\r
326 int SetRange(short nMinRange, short nMaxRange) const;
\r
327 int SetStep(int nStepInc) const;
\r
328 int StepIt() const;
\r
332 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = PROGRESS_CLASS; }
\r
335 class CScrollBar : public CWnd
\r
339 virtual ~CScrollBar() {}
\r
341 BOOL EnableScrollBar( UINT nArrowFlags = ESB_ENABLE_BOTH ) const;
\r
342 BOOL GetScrollInfo(LPSCROLLINFO lpsi) const;
\r
343 int GetScrollPos() const;
\r
344 BOOL GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos ) const;
\r
345 BOOL SetScrollInfo(LPSCROLLINFO lpsi, BOOL bRedraw = TRUE ) const;
\r
346 int SetScrollPos(int nPos, BOOL bRedraw) const;
\r
347 BOOL SetScrollRange( int nMinPos, int nMaxPos, BOOL bRedraw = TRUE ) const;
\r
348 BOOL ShowScrollBar(BOOL bShow) const;
\r
352 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = _T("SCROLLBAR"); ; }
\r
355 class CSlider : public CWnd
\r
358 CSlider() { ::InitCommonControls(); }
\r
359 virtual ~CSlider() {}
\r
361 void ClearSel() const;
\r
362 void ClearTics(BOOL bRedraw = FALSE ) const;
\r
363 CWnd* GetBuddy(BOOL fLocation = TRUE ) const;
\r
364 CRect GetChannelRect() const;
\r
365 int GetLineSize() const;
\r
366 int GetNumTics() const;
\r
367 int GetPageSize() const;
\r
368 int GetPos() const;
\r
369 int GetRangeMax() const;
\r
370 int GetRangeMin() const;
\r
371 int GetSelEnd() const;
\r
372 int GetSelStart() const;
\r
373 int GetThumbLength() const;
\r
374 CRect GetThumbRect() const;
\r
375 int GetTic(int nTic ) const;
\r
376 int GetTicPos(int nTic) const;
\r
377 CToolTip* GetToolTips() const;
\r
378 CWnd* SetBuddy(CWnd* pBuddy, BOOL fLocation = TRUE ) const;
\r
379 int SetLineSize(int nSize) const;
\r
380 int SetPageSize(int nSize) const;
\r
381 void SetPos(int nPos, BOOL bRedraw = FALSE) const;
\r
382 void SetRangeMax(int nMax, BOOL bRedraw = FALSE) const;
\r
383 void SetRangeMin(int nMax, BOOL bRedraw = FALSE) const;
\r
384 void SetSelection(int nMin, int nMax, BOOL bRedraw = FALSE) const;
\r
385 BOOL SetTic(int nTic) const;
\r
386 void SetTicFreq(int nFreq) const;
\r
387 int SetTipSide(int nLocation) const;
\r
388 void SetToolTips(CToolTip* pToolTip) const;
\r
392 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = TRACKBAR_CLASS; }
\r
396 // Also known as an Up/Down control
\r
397 class CSpinButton : public CWnd
\r
400 CSpinButton() { ::InitCommonControls(); }
\r
401 virtual ~CSpinButton() {}
\r
403 int GetAccel(int cAccels, LPUDACCEL paAccels) const;
\r
404 int GetBase() const;
\r
405 CWnd* GetBuddy() const;
\r
406 int GetPos() const;
\r
407 DWORD GetRange() const;
\r
408 BOOL SetAccel(int cAccels, LPUDACCEL paAccels) const;
\r
409 int SetBase(int nBase) const;
\r
410 CWnd* SetBuddy(CWnd* hwndBuddy) const;
\r
411 int SetPos(int nPos) const;
\r
412 void SetRange(int nLower, int nUpper) const;
\r
416 virtual void PreCreate(CREATESTRUCT &cs);
\r
417 virtual void PreRegisterClass(WNDCLASS &wc);
\r
420 class CToolTip : public CWnd
\r
424 virtual ~CToolTip();
\r
427 int GetDelayTime(DWORD dwDuration) const;
\r
428 void GetMargin(LPRECT lprc) const;
\r
429 int GetMaxTipWidth() const;
\r
430 void GetText(CString& str, CWnd* pWnd, UINT_PTR nIDTool = 0) const;
\r
431 COLORREF GetTipBkColor() const;
\r
432 COLORREF GetTipTextColor() const;
\r
433 int GetToolCount() const;
\r
434 BOOL GetToolInfo(TOOLINFO& ToolInfo, CWnd* pWnd, UINT_PTR nIDTool = 0) const;
\r
435 void SetDelayTime(UINT nDelay);
\r
436 void SetDelayTime(DWORD dwDuration, int iTime);
\r
437 void SetMargin(LPRECT lprc);
\r
438 int SetMaxTipWidth(int iWidth);
\r
439 void SetTipBkColor(COLORREF clr);
\r
440 void SetTipTextColor(COLORREF clr);
\r
441 void SetToolInfo(LPTOOLINFO lpToolInfo);
\r
442 #if (defined TTM_SETTITLE) && (_WIN32_IE >=0x0500)
\r
443 CSize GetBubbleSize(LPTOOLINFO lpToolInfo) const;
\r
447 void Activate(BOOL bActivate);
\r
448 BOOL AddTool(CWnd* pWnd, UINT nIDText, LPCRECT lpRectTool = NULL, UINT_PTR nIDTool = 0);
\r
449 BOOL AddTool(CWnd* pWnd, LPCTSTR lpszText = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT_PTR nIDTool = 0);
\r
450 void DelTool(CWnd* pWnd, UINT_PTR nIDTool = 0);
\r
451 BOOL HitTest(CWnd* pWnd, CPoint pt, LPTOOLINFO lpToolInfo) const;
\r
453 void RelayEvent(LPMSG lpMsg);
\r
455 void SetToolRect(CWnd* pWnd, UINT_PTR nIDTool, LPCRECT lpRect);
\r
457 void UpdateTipText(LPCTSTR lpszText, CWnd* pWnd, UINT_PTR nIDTool = 0);
\r
458 void UpdateTipText(UINT nIDText, CWnd* pWnd, UINT_PTR nIDTool = 0);
\r
460 #if (defined TTM_SETTITLE) && (_WIN32_IE >=0x0500)
\r
461 BOOL AdjustRect(LPRECT lprc, BOOL bLarger = TRUE);
\r
462 BOOL SetTitle(UINT uIcon, LPCTSTR lpstrTitle);
\r
464 #if (defined TTM_SETWINDOWTHEME) && (WINVER >= 0x0501)
\r
465 HRESULT SetWindowTheme(LPCWSTR lpstrTheme);
\r
470 virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = TOOLTIPS_CLASS; ; }
\r
471 virtual void PreCreate(CREATESTRUCT &cs)
\r
473 cs.dwExStyle = WS_EX_TOOLWINDOW;
\r
474 cs.style = WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP;
\r
478 void LoadToolInfo(TOOLINFO& ti, CWnd* pWnd, UINT_PTR nIDTool) const;
\r
482 } // namespace Win32xx
\r
484 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
489 ////////////////////////////////////////
\r
490 // Definitions for the CAnimation class
\r
492 inline BOOL CAnimation::Close() const
\r
493 // Closes an AVI clip.
\r
495 assert(IsWindow());
\r
496 return Animate_Close(m_hWnd);
\r
499 inline BOOL CAnimation::Open(LPTSTR lpszName) const
\r
500 // Opens an AVI clip and displays its first frame in an animation control.
\r
502 assert(IsWindow());
\r
503 return Animate_Open(m_hWnd, lpszName);
\r
506 inline BOOL CAnimation::Play(UINT wFrom, UINT wTo, UINT cRepeat) const
\r
507 // Plays an AVI clip in an animation control. The control plays the clip
\r
508 // in the background while the thread continues executing.
\r
510 assert(IsWindow());
\r
511 return Animate_Play(m_hWnd, wFrom, wTo, cRepeat);
\r
514 inline BOOL CAnimation::Seek(UINT wFrame) const
\r
515 // Directs an animation control to display a particular frame of an AVI clip.
\r
516 // The control displays the clip in the background while the thread continues executing.
\r
518 assert(IsWindow());
\r
519 return Animate_Seek(m_hWnd, wFrame);
\r
522 inline BOOL CAnimation::Stop() const
\r
523 // Stops playing an AVI clip in an animation control.
\r
525 assert(IsWindow());
\r
526 return Animate_Stop(m_hWnd);
\r
530 ////////////////////////////////////////
\r
531 // Definitions for the CComboBox class
\r
533 inline int CComboBox::AddString(LPCTSTR lpszString) const
\r
534 // Adds a string to the list box of a combo box. If the combo box does not
\r
535 // have the CBS_SORT style, the string is added to the end of the list.
\r
536 // Otherwise, the string is inserted into the list, and the list is sorted.
\r
538 assert(IsWindow());
\r
539 return (int)SendMessage(CB_ADDSTRING, 0, (LPARAM)lpszString);
\r
542 inline void CComboBox::Clear() const
\r
543 // Deletes the current selection, if any, from the combo box's edit control.
\r
545 assert(IsWindow());
\r
546 SendMessage(WM_CLEAR, 0, 0);
\r
549 inline void CComboBox::Copy() const
\r
550 // Copies the current selection to the clipboard in CF_TEXT format.
\r
552 assert(IsWindow());
\r
553 SendMessage(WM_COPY, 0, 0);
\r
556 inline void CComboBox::Cut() const
\r
557 // Deletes the current selection, if any, in the edit control and copies
\r
558 // the deleted text to the clipboard in CF_TEXT format.
\r
560 assert(IsWindow());
\r
561 SendMessage(WM_CUT, 0, 0);
\r
564 inline int CComboBox::DeleteString(int nIndex) const
\r
565 // Deletes a string in the list box of a combo box.
\r
567 assert(IsWindow());
\r
568 return (int)SendMessage(CB_DELETESTRING, (WPARAM)nIndex, 0);
\r
571 inline int CComboBox::Dir(UINT attr, LPCTSTR lpszWildCard ) const
\r
572 // Adds the names of directories and files that match a specified string
\r
573 // and set of file attributes.
\r
575 assert(IsWindow());
\r
576 return (int)SendMessage(CB_DIR, (WPARAM)attr, (LPARAM)lpszWildCard);
\r
579 inline int CComboBox::FindString(int nIndexStart, LPCTSTR lpszString) const
\r
580 // Search the list box of a combo box for an item beginning with the
\r
581 // characters in a specified string.
\r
583 assert(IsWindow());
\r
584 return (int)SendMessage(CB_FINDSTRING, (WPARAM)nIndexStart, (LPARAM)lpszString);
\r
587 inline int CComboBox::FindStringExact(int nIndexStart, LPCTSTR lpszString) const
\r
588 // Find the first list box string in a combo box that matches the string specified in lpszString.
\r
590 assert(IsWindow());
\r
591 return (int)SendMessage(CB_FINDSTRINGEXACT, (WPARAM)nIndexStart, (LPARAM)lpszString);
\r
594 inline int CComboBox::GetCount() const
\r
595 // Retrieves the number of items in the list box of the combo box.
\r
597 assert(IsWindow());
\r
598 return (int)SendMessage(CB_GETCOUNT, 0,0);
\r
601 inline int CComboBox::GetCurSel() const
\r
602 // Retrieves the index of the currently selected item, if any, in the list box of the combo box.
\r
604 assert(IsWindow());
\r
605 return (int)SendMessage(CB_GETCURSEL, 0,0);
\r
608 inline CRect CComboBox::GetDroppedControlRect() const
\r
609 // Retrieves the screen coordinates of the combo box in its dropped-down state.
\r
611 assert(IsWindow());
\r
613 SendMessage(CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc);
\r
617 inline BOOL CComboBox::GetDroppedState() const
\r
618 // Determines whether the list box of the combo box is dropped down.
\r
620 assert(IsWindow());
\r
621 return (BOOL)SendMessage(CB_GETDROPPEDSTATE, 0, 0);
\r
624 inline int CComboBox::GetDroppedWidth() const
\r
625 // Retrieves the minimum allowable width, in pixels, of the list box of the combo box
\r
626 // with the CBS_DROPDOWN or CBS_DROPDOWNLIST style.
\r
628 assert(IsWindow());
\r
629 return (int)SendMessage(CB_GETDROPPEDWIDTH, 0, 0);
\r
632 inline DWORD CComboBox::GetEditSel() const
\r
633 // Gets the starting and ending character positions of the current selection
\r
634 // in the edit control of the combo box.
\r
636 assert(IsWindow());
\r
637 return (int)SendMessage(CB_GETEDITSEL, 0, 0);
\r
640 inline BOOL CComboBox::GetExtendedUI() const
\r
641 // Determines whether the combo box has the default user interface or the extended user interface.
\r
643 assert(IsWindow());
\r
644 return (BOOL)SendMessage(CB_GETEXTENDEDUI, 0, 0);
\r
647 inline int CComboBox::GetHorizontalExtent() const
\r
648 // Retrieve from the combo box the width, in pixels, by which the list box can
\r
649 // be scrolled horizontally (the scrollable width).
\r
651 assert(IsWindow());
\r
652 return (int)SendMessage(CB_GETHORIZONTALEXTENT, 0, 0);
\r
655 inline DWORD CComboBox::GetItemData(int nIndex) const
\r
656 // Retrieves the application-supplied value associated with the specified item in the combo box.
\r
658 assert(IsWindow());
\r
659 return (DWORD)SendMessage(CB_GETITEMDATA, (WPARAM)nIndex, 0);
\r
662 inline int CComboBox::GetItemHeight(int nIndex) const
\r
663 // Determines the height of list items or the selection field in the combo box.
\r
665 assert(IsWindow());
\r
666 return (int)SendMessage(CB_GETITEMHEIGHT, (WPARAM)nIndex, 0);
\r
669 inline int CComboBox::GetLBText(int nIndex, LPTSTR lpszText) const
\r
670 // Retrieves a string from the list of the combo box.
\r
672 assert(IsWindow());
\r
673 return (int)SendMessage(CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)lpszText);
\r
676 inline int CComboBox::GetLBTextLen(int nIndex) const
\r
677 // Retrieves the length, in characters, of a string in the list of the combo box.
\r
679 assert(IsWindow());
\r
680 return (int)SendMessage(CB_GETLBTEXTLEN, (WPARAM)nIndex, 0);
\r
683 inline LCID CComboBox::GetLocale() const
\r
684 // Retrieves the current locale of the combo box.
\r
686 assert(IsWindow());
\r
687 return (LCID)SendMessage(CB_GETLOCALE, 0, 0);
\r
690 inline int CComboBox::GetTopIndex() const
\r
691 // Retrieves the zero-based index of the first visible item in the list box portion of the combo box.
\r
693 assert(IsWindow());
\r
694 return (int)SendMessage(CB_GETTOPINDEX, 0, 0);
\r
697 inline int CComboBox::InitStorage(int nItems, int nBytes) const
\r
698 // Allocates memory for storing list box items. Use this before adding a
\r
699 // large number of items to the list box portion of a combo box.
\r
701 assert(IsWindow());
\r
702 return (int)SendMessage(CB_INITSTORAGE, (WPARAM)nItems, (LPARAM)nBytes);
\r
705 inline int CComboBox::InsertString(int nIndex, LPCTSTR lpszString) const
\r
706 // Inserts a string into the list box of the combo box. Unlike the AddString,
\r
707 // a list with the CBS_SORT style is not sorted.
\r
709 assert(IsWindow());
\r
710 return (int)SendMessage(CB_INSERTSTRING, (WPARAM)nIndex, (LPARAM)lpszString);
\r
713 inline void CComboBox::Paste() const
\r
714 // Copies the current content of the clipboard to the combo box's edit control at the current caret position.
\r
716 assert(IsWindow());
\r
717 SendMessage(WM_PASTE, 0, 0);
\r
720 inline void CComboBox::LimitText(int nMaxChars) const
\r
721 // Limits the length of the text the user may type into the edit control of the combo box.
\r
723 assert(IsWindow());
\r
724 SendMessage(CB_LIMITTEXT, (WPARAM)nMaxChars, 0);
\r
727 inline void CComboBox::ResetContent() const
\r
728 // Removes all items from the list box and edit control of the combo box.
\r
730 assert(IsWindow());
\r
731 SendMessage(CB_RESETCONTENT, 0, 0);
\r
734 inline int CComboBox::SelectString(int nStartAfter, LPCTSTR lpszString) const
\r
735 // Searches the list of a combo box for an item that begins with the characters in a
\r
736 // specified string. If a matching item is found, it is selected and copied to the edit control.
\r
738 assert(IsWindow());
\r
739 return (int)SendMessage(CB_SELECTSTRING, (WPARAM)nStartAfter, (LPARAM)lpszString);
\r
742 inline int CComboBox::SetCurSel(int nIndex) const
\r
743 // Selects a string in the list of the combo box. If necessary, the list scrolls the string into view.
\r
745 assert(IsWindow());
\r
746 return (int)SendMessage(CB_SETCURSEL, (WPARAM)nIndex, 0);
\r
749 inline int CComboBox::SetDroppedWidth(int nWidth) const
\r
750 // Sets the maximum allowable width, in pixels, of the list box of the combo box with
\r
751 // the CBS_DROPDOWN or CBS_DROPDOWNLIST style.
\r
753 assert(IsWindow());
\r
754 return (int)SendMessage(CB_SETDROPPEDWIDTH, (WPARAM)nWidth, 0);
\r
757 inline BOOL CComboBox::SetEditSel(int nStartChar, int nEndChar) const
\r
758 // Selects characters in the edit control of the combo box.
\r
760 assert(IsWindow());
\r
761 return (BOOL)SendMessage(CB_SETEDITSEL, 0, (LPARAM)MAKELONG(nStartChar,nEndChar));
\r
764 inline int CComboBox::SetExtendedUI(BOOL bExtended) const
\r
765 // Selects either the default user interface or the extended user interface for the combo box that
\r
766 // has the CBS_DROPDOWN or CBS_DROPDOWNLIST style.
\r
768 assert(IsWindow());
\r
769 return (int)SendMessage(CB_SETEXTENDEDUI, (WPARAM)bExtended, 0);
\r
772 inline void CComboBox::SetHorizontalExtent(UINT nExtent ) const
\r
773 // Sets the width, in pixels, by which the list box can be scrolled horizontally (the scrollable width).
\r
775 assert(IsWindow());
\r
776 SendMessage(CB_SETHORIZONTALEXTENT, (WPARAM)nExtent, 0);
\r
779 inline int CComboBox::SetItemData(int nIndex, DWORD dwItemData) const
\r
780 // Sets the value associated with the specified item in the combo box.
\r
782 assert(IsWindow());
\r
783 return (int)SendMessage(CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM)dwItemData);
\r
786 inline int CComboBox::SetItemHeight(int nIndex, UINT cyItemHeight) const
\r
787 // Sets the height of list items or the selection field in the combo box.
\r
789 assert(IsWindow());
\r
790 return (int)SendMessage(CB_SETITEMHEIGHT, (WPARAM)nIndex, (LPARAM)cyItemHeight);
\r
793 inline LCID CComboBox::SetLocale( LCID NewLocale ) const
\r
794 // Sets the current locale of the combo box.
\r
796 assert(IsWindow());
\r
797 return (LCID)SendMessage(CB_SETLOCALE, (WPARAM)NewLocale, 0);
\r
800 inline int CComboBox::SetTopIndex(int nIndex) const
\r
801 // Ensure that a particular item is visible in the list box of the combo box.
\r
803 assert(IsWindow());
\r
804 return (int)SendMessage(CB_SETTOPINDEX, (WPARAM)nIndex, 0);
\r
807 inline void CComboBox::ShowDropDown(BOOL bShow) const
\r
808 // Shows or hides the list box of the combo box that has the CBS_DROPDOWN or CBS_DROPDOWNLIST style.
\r
810 assert(IsWindow());
\r
811 SendMessage(CB_SHOWDROPDOWN, (WPARAM)bShow, 0);
\r
815 ////////////////////////////////////////
\r
816 // Definitions for the CComboBoxEx class
\r
818 inline int CComboBoxEx::DeleteItem(int nIndex ) const
\r
819 // Removes an item from the ComboBoxEx control.
\r
821 assert(IsWindow());
\r
822 return (int)SendMessage(CBEM_DELETEITEM, (WPARAM)nIndex, 0);
\r
825 inline CWnd* CComboBoxEx::GetComboBoxCtrl() const
\r
826 // Retrieves the handle to the child combo box control.
\r
828 assert(IsWindow());
\r
829 return FromHandle((HWND)SendMessage(CBEM_GETCOMBOCONTROL, 0, 0));
\r
832 inline CEdit* CComboBoxEx::GetEditCtrl() const
\r
833 // Retrieves the handle to the edit control portion of the ComboBoxEx control.
\r
835 assert(IsWindow());
\r
836 return (CEdit*)FromHandle((HWND)SendMessage(CBEM_GETEDITCONTROL, 0, 0));
\r
839 inline DWORD CComboBoxEx::GetExtendedStyle() const
\r
840 // Retrieves the extended styles that are in use for the ComboBoxEx control.
\r
842 assert(IsWindow());
\r
843 return (DWORD)SendMessage(CBEM_GETEXTENDEDSTYLE, 0, 0);
\r
846 inline HIMAGELIST CComboBoxEx::GetImageList() const
\r
847 // Retrieves the handle to an image list assigned to the ComboBoxEx control.
\r
849 assert(IsWindow());
\r
850 return (HIMAGELIST)SendMessage(CBEM_GETIMAGELIST, 0, 0);
\r
853 inline BOOL CComboBoxEx::GetItem(COMBOBOXEXITEM* pCBItem) const
\r
854 // Retrieves item information for the given ComboBoxEx item.
\r
856 assert(IsWindow());
\r
857 return (BOOL)SendMessage(CBEM_GETITEM, 0, (LPARAM)pCBItem);
\r
860 inline BOOL CComboBoxEx::HasEditChanged () const
\r
861 // Determines whether or not the user has changed the text of the ComboBoxEx edit control.
\r
863 assert(IsWindow());
\r
864 return (BOOL)SendMessage(CBEM_HASEDITCHANGED, 0, 0);
\r
867 inline int CComboBoxEx::InsertItem(COMBOBOXEXITEM* lpcCBItem) const
\r
868 // Inserts a new item in the ComboBoxEx control.
\r
870 assert(IsWindow());
\r
871 return (int)SendMessage(CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem);
\r
874 inline DWORD CComboBoxEx::SetExtendedStyle(DWORD dwExMask, DWORD dwExStyles ) const
\r
875 // Sets extended styles within the ComboBoxEx control.
\r
877 assert(IsWindow());
\r
878 return (DWORD)SendMessage(CBEM_SETEXTENDEDSTYLE, (WPARAM)dwExMask, (LPARAM)dwExStyles);
\r
881 inline HIMAGELIST CComboBoxEx::SetImageList(HIMAGELIST himl) const
\r
882 // Sets an image list for the ComboBoxEx control.
\r
884 assert(IsWindow());
\r
885 return (HIMAGELIST)SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)himl);
\r
888 inline BOOL CComboBoxEx::SetItem(PCOMBOBOXEXITEM lpcCBItem) const
\r
889 // Sets the attributes for an item in the ComboBoxEx control.
\r
891 assert(IsWindow());
\r
892 return (BOOL)SendMessage(CBEM_SETITEM, 0, (LPARAM)lpcCBItem);
\r
895 ////////////////////////////////////////
\r
896 // Definitions for the CDateTime class
\r
898 inline COLORREF CDateTime::GetMonthCalColor(int iColor) const
\r
900 assert(IsWindow());
\r
901 return (COLORREF)DateTime_GetMonthCalColor(m_hWnd, iColor);
\r
904 inline COLORREF CDateTime::SetMonthCalColor(int iColor, COLORREF clr)
\r
906 assert(IsWindow());
\r
907 return (COLORREF)DateTime_SetMonthCalColor(m_hWnd, iColor, clr);
\r
910 inline BOOL CDateTime::SetFormat(LPCTSTR pszFormat)
\r
912 assert(IsWindow());
\r
913 return DateTime_SetFormat(m_hWnd, pszFormat);
\r
916 inline CMonthCalendar* CDateTime::GetMonthCalCtrl() const
\r
918 assert(IsWindow());
\r
919 return (CMonthCalendar*)FromHandle((HWND)DateTime_GetMonthCal(m_hWnd));
\r
922 inline CFont* CDateTime::GetMonthCalFont() const
\r
924 assert(IsWindow());
\r
925 return FromHandle((HFONT)DateTime_GetMonthCalFont(m_hWnd));
\r
928 inline void CDateTime::SetMonthCalFont(HFONT hFont, BOOL bRedraw /*= TRUE*/)
\r
930 assert(IsWindow());
\r
931 DateTime_SetMonthCalFont(m_hWnd, hFont, MAKELONG(bRedraw, 0));
\r
934 inline DWORD CDateTime::GetRange(LPSYSTEMTIME lpSysTimeArray) const
\r
936 assert(IsWindow());
\r
937 return DateTime_GetRange(m_hWnd, lpSysTimeArray);
\r
940 inline BOOL CDateTime::SetRange(DWORD flags, LPSYSTEMTIME lpSysTimeArray)
\r
942 assert(IsWindow());
\r
943 return DateTime_SetRange(m_hWnd, flags, lpSysTimeArray);
\r
946 inline DWORD CDateTime::GetTime(LPSYSTEMTIME pTimeDest) const
\r
948 assert(IsWindow());
\r
949 return DateTime_GetSystemtime(m_hWnd, pTimeDest);
\r
952 inline BOOL CDateTime::SetTime(DWORD flag, LPSYSTEMTIME pTimeNew /*= NULL*/)
\r
954 assert(IsWindow());
\r
955 return DateTime_SetSystemtime(m_hWnd, flag, pTimeNew);
\r
959 ////////////////////////////////////////
\r
960 // Definitions for the CHotKey class
\r
962 inline DWORD CHotKey::GetHotKey() const
\r
964 assert(IsWindow());
\r
965 return (DWORD)SendMessage(HKM_GETHOTKEY, 0, 0);
\r
968 inline CString CHotKey::GetKeyName(UINT vk, BOOL fExtended) const
\r
970 // Translate the virtual-key code to a scan code
\r
971 LONG lScan = MapVirtualKey(vk, 0);
\r
973 // Construct an LPARAM with the scan code in Bits 16-23, and an extended flag in bit 24
\r
974 LPARAM lParam = lScan << 16;
\r
976 lParam |= 0x01000000L;
\r
979 int nBufferLen = 64;
\r
980 int nStrLen = nBufferLen;
\r
982 // Loop until we have retrieved the entire string
\r
983 while(nStrLen == nBufferLen)
\r
986 LPTSTR pszStr = str.GetBuffer(nBufferLen);
\r
987 nStrLen = ::GetKeyNameText((LONG)lParam, pszStr, nBufferLen + 1);
\r
988 str.ReleaseBuffer();
\r
994 inline void CHotKey::SetHotKey(DWORD dwKey)
\r
996 assert(IsWindow());
\r
997 SendMessage(HKM_SETHOTKEY, (WPARAM)dwKey, 0);
\r
1000 inline void CHotKey::SetRules(WORD wInvalidComb, WORD wModifiers)
\r
1002 assert(IsWindow());
\r
1003 SendMessage(HKM_SETRULES, wInvalidComb, wModifiers);
\r
1007 ////////////////////////////////////////
\r
1008 // Definitions for the CHeader class
\r
1010 inline HIMAGELIST CHeader::CreateDragImage(int nIndex)
\r
1012 assert(IsWindow());
\r
1013 return Header_CreateDragImage(m_hWnd, nIndex);
\r
1016 inline BOOL CHeader::DeleteItem(int nPos)
\r
1018 assert(IsWindow());
\r
1019 return Header_DeleteItem(m_hWnd, nPos);
\r
1022 inline HIMAGELIST CHeader::GetImageList() const
\r
1024 assert(IsWindow());
\r
1025 return Header_GetImageList(m_hWnd);
\r
1028 inline BOOL CHeader::GetItem(int nPos, HDITEM* pHeaderItem) const
\r
1030 assert(IsWindow());
\r
1031 return Header_GetItem(m_hWnd, nPos, pHeaderItem);
\r
1034 inline int CHeader::GetItemCount() const
\r
1036 assert(IsWindow());
\r
1037 return Header_GetItemCount(m_hWnd);
\r
1040 inline CRect CHeader::GetItemRect(int nIndex) const
\r
1042 assert(IsWindow());
\r
1044 Header_GetItemRect(m_hWnd, nIndex, &rc);
\r
1048 inline BOOL CHeader::GetOrderArray(LPINT piArray, int iCount)
\r
1050 assert(IsWindow());
\r
1051 return Header_GetOrderArray(m_hWnd, piArray, iCount);
\r
1054 inline int CHeader::InsertItem(int nPos, HDITEM* phdi)
\r
1056 assert(IsWindow());
\r
1057 return Header_InsertItem(m_hWnd, nPos, phdi);
\r
1060 inline BOOL CHeader::Layout(HDLAYOUT* pHeaderLayout)
\r
1062 assert(IsWindow());
\r
1063 return Header_Layout(m_hWnd, pHeaderLayout);
\r
1066 inline int CHeader::OrderToIndex(int nOrder) const
\r
1068 assert(IsWindow());
\r
1069 return Header_OrderToIndex( m_hWnd, nOrder);
\r
1072 #ifdef Header_SetHotDivider
\r
1073 inline int CHeader::SetHotDivider(CPoint pt)
\r
1075 assert(IsWindow());
\r
1076 return Header_SetHotDivider(m_hWnd, TRUE, MAKELPARAM(pt.x, pt.y));
\r
1079 inline int CHeader::SetHotDivider(int nIndex)
\r
1081 assert(IsWindow());
\r
1082 return Header_SetHotDivider(m_hWnd, FALSE, nIndex);
\r
1086 inline HIMAGELIST CHeader::SetImageList(HIMAGELIST himl)
\r
1088 assert(IsWindow());
\r
1089 return Header_SetImageList(m_hWnd, himl);
\r
1092 inline BOOL CHeader::SetItem(int nPos, HDITEM* pHeaderItem)
\r
1094 assert(IsWindow());
\r
1095 return Header_SetItem(m_hWnd, nPos, pHeaderItem);
\r
1098 inline BOOL CHeader::SetOrderArray(int iCount, LPINT piArray)
\r
1100 assert(IsWindow());
\r
1101 return Header_SetOrderArray(m_hWnd, iCount, piArray);
\r
1104 #ifdef Header_ClearFilter
\r
1105 inline int CHeader::ClearFilter(int nColumn)
\r
1107 assert(IsWindow());
\r
1108 return Header_ClearFilter(m_hWnd, nColumn);
\r
1111 inline int CHeader::ClearAllFilters()
\r
1113 assert(IsWindow());
\r
1114 return Header_ClearAllFilters(m_hWnd);
\r
1117 inline int CHeader::EditFilter(int nColumn, BOOL bDiscardChanges)
\r
1119 assert(IsWindow());
\r
1120 return Header_EditFilter(m_hWnd, nColumn, LPARAM MAKELPARAM(bDiscardChanges, 0));
\r
1123 inline int CHeader::GetBitmapMargin() const
\r
1125 assert(IsWindow());
\r
1126 return Header_GetBitmapMargin(m_hWnd);
\r
1129 inline int CHeader::SetBitmapMargin(int nWidth)
\r
1131 assert(IsWindow());
\r
1132 return Header_SetBitmapMargin(m_hWnd, nWidth);
\r
1135 inline int CHeader::SetFilterChangeTimeout(DWORD dwTimeOut)
\r
1137 assert(IsWindow());
\r
1138 return Header_SetFilterChangeTimeout(m_hWnd, dwTimeOut);
\r
1142 ////////////////////////////////////////
\r
1143 // Definitions for the CIPAddress class
\r
1145 inline void CIPAddress::ClearAddress()
\r
1147 assert(IsWindow());
\r
1148 SendMessage(IPM_CLEARADDRESS, 0, 0);
\r
1151 inline int CIPAddress::GetAddress(BYTE& nField0, BYTE& nField1, BYTE& nField2, BYTE& nField3)
\r
1154 int iValue = GetAddress(&dwAddr);
\r
1155 nField0 = (BYTE)FIRST_IPADDRESS(dwAddr);
\r
1156 nField1 = (BYTE)SECOND_IPADDRESS(dwAddr);
\r
1157 nField2 = (BYTE)THIRD_IPADDRESS(dwAddr);
\r
1158 nField3 = (BYTE)FOURTH_IPADDRESS(dwAddr);
\r
1162 inline int CIPAddress::GetAddress(DWORD* dwAddress)
\r
1164 assert(IsWindow());
\r
1165 return (int)SendMessage(IPM_GETADDRESS, 0, (LPARAM)&dwAddress);
\r
1168 inline BOOL CIPAddress::IsBlank() const
\r
1170 assert(IsWindow());
\r
1171 return (BOOL)SendMessage(IPM_ISBLANK, 0, 0);
\r
1174 inline void CIPAddress::SetAddress(BYTE nField0, BYTE nField1, BYTE nField2, BYTE nField3)
\r
1176 assert(IsWindow());
\r
1177 SendMessage(IPM_SETADDRESS, 0, (LPARAM)MAKEIPADDRESS(nField0, nField1, nField2, nField3));
\r
1180 inline void CIPAddress::SetAddress(DWORD dwAddress)
\r
1182 assert(IsWindow());
\r
1183 SendMessage(IPM_SETADDRESS, 0, (LPARAM)dwAddress);
\r
1186 inline void CIPAddress::SetFieldFocus(WORD nField)
\r
1188 assert(IsWindow());
\r
1189 SendMessage(IPM_SETFOCUS, nField, 0);
\r
1192 inline void CIPAddress::SetFieldRange(int nField, BYTE nLower, BYTE nUpper)
\r
1194 assert(IsWindow());
\r
1195 SendMessage(IPM_SETRANGE, MAKEIPRANGE(nLower, nUpper), nField);
\r
1199 ///////////////////////////////////////////
\r
1200 // Definitions for the CMonthCalendar class
\r
1202 inline COLORREF CMonthCalendar::GetColor(int nRegion) const
\r
1204 assert(IsWindow());
\r
1205 return (COLORREF)MonthCal_GetColor(m_hWnd, nRegion);
\r
1208 inline BOOL CMonthCalendar::GetCurSel(LPSYSTEMTIME pDateTime) const
\r
1210 assert(IsWindow());
\r
1211 return MonthCal_GetCurSel(m_hWnd, pDateTime);
\r
1214 inline int CMonthCalendar::GetFirstDayOfWeek(BOOL* pbLocal /*= NULL*/) const
\r
1216 assert(IsWindow());
\r
1217 DWORD dwValue = MonthCal_GetFirstDayOfWeek(m_hWnd);
\r
1220 *pbLocal = HIWORD(dwValue);
\r
1222 return LOWORD(dwValue);
\r
1225 inline int CMonthCalendar::GetMaxSelCount() const
\r
1227 assert(IsWindow());
\r
1228 return MonthCal_GetMaxSelCount(m_hWnd);
\r
1231 inline CRect CMonthCalendar::GetMinReqRect() const
\r
1233 assert(IsWindow());
\r
1235 MonthCal_GetMinReqRect(m_hWnd, &rc);
\r
1239 inline int CMonthCalendar::GetMonthDelta() const
\r
1241 assert(IsWindow());
\r
1242 return MonthCal_GetMonthDelta(m_hWnd);
\r
1245 inline int CMonthCalendar::GetMonthRange(LPSYSTEMTIME pMinRange, LPSYSTEMTIME pMaxRange, DWORD dwFlags) const
\r
1247 assert(IsWindow());
\r
1248 SYSTEMTIME MinMax[2];
\r
1249 memcpy(&MinMax[0], pMinRange, sizeof(SYSTEMTIME));
\r
1250 memcpy(&MinMax[1], pMaxRange, sizeof(SYSTEMTIME));
\r
1251 int nCount = MonthCal_GetMonthRange(m_hWnd, dwFlags, MinMax);
\r
1255 inline DWORD CMonthCalendar::GetRange(LPSYSTEMTIME pMinRange, LPSYSTEMTIME pMaxRange) const
\r
1257 assert(IsWindow());
\r
1258 SYSTEMTIME MinMax[2];
\r
1259 DWORD dwValue = MonthCal_GetRange(m_hWnd, &MinMax);
\r
1260 memcpy(pMinRange, &MinMax[0], sizeof(SYSTEMTIME));
\r
1261 memcpy(pMaxRange, &MinMax[1], sizeof(SYSTEMTIME));
\r
1265 inline BOOL CMonthCalendar::GetSelRange(LPSYSTEMTIME pMinRange, LPSYSTEMTIME pMaxRange) const
\r
1267 assert(IsWindow());
\r
1268 SYSTEMTIME MinMax[2];
\r
1269 memcpy(&MinMax[0], pMinRange, sizeof(SYSTEMTIME));
\r
1270 memcpy(&MinMax[1], pMaxRange, sizeof(SYSTEMTIME));
\r
1271 return (BOOL)MonthCal_GetSelRange(m_hWnd, &MinMax);
\r
1274 inline BOOL CMonthCalendar::GetToday(LPSYSTEMTIME pDateTime) const
\r
1276 assert(IsWindow());
\r
1277 return MonthCal_GetToday(m_hWnd, pDateTime);
\r
1280 inline DWORD CMonthCalendar::HitTest(PMCHITTESTINFO pMCHitTest)
\r
1282 assert(IsWindow());
\r
1283 return (DWORD)MonthCal_HitTest(m_hWnd, pMCHitTest);
\r
1286 inline COLORREF CMonthCalendar::SetColor(int nRegion, COLORREF clr)
\r
1288 assert(IsWindow());
\r
1289 return (COLORREF)MonthCal_SetColor(m_hWnd, nRegion, clr);
\r
1292 inline BOOL CMonthCalendar::SetCurSel(const LPSYSTEMTIME pDateTime)
\r
1294 assert(IsWindow());
\r
1295 return MonthCal_SetCurSel(m_hWnd, pDateTime);
\r
1298 inline BOOL CMonthCalendar::SetDayState(int nMonths, LPMONTHDAYSTATE pStates)
\r
1300 assert(IsWindow());
\r
1301 return (BOOL)MonthCal_SetDayState(m_hWnd, nMonths, pStates);
\r
1304 inline BOOL CMonthCalendar::SetFirstDayOfWeek(int iDay, int* pnOld/* = NULL*/)
\r
1306 assert(IsWindow());
\r
1307 DWORD dwValue = (DWORD)MonthCal_SetFirstDayOfWeek(m_hWnd, iDay);
\r
1310 *pnOld = LOWORD(dwValue);
\r
1312 return (BOOL)HIWORD(dwValue);
\r
1315 inline BOOL CMonthCalendar::SetMaxSelCount(int nMax)
\r
1317 assert(IsWindow());
\r
1318 return MonthCal_SetMaxSelCount(m_hWnd, nMax);
\r
1321 inline int CMonthCalendar::SetMonthDelta(int iDelta)
\r
1323 assert(IsWindow());
\r
1324 return MonthCal_SetMonthDelta(m_hWnd, iDelta);
\r
1327 inline BOOL CMonthCalendar::SetRange(const LPSYSTEMTIME pMinRange, const LPSYSTEMTIME pMaxRange)
\r
1330 SYSTEMTIME MinMax[2];
\r
1333 if (pMinRange != NULL)
\r
1335 memcpy(&MinMax[0], pMinRange, sizeof(SYSTEMTIME));
\r
1336 dwLimit = GDTR_MIN;
\r
1341 memcpy(&MinMax[1], pMaxRange, sizeof(SYSTEMTIME));
\r
1342 dwLimit |= GDTR_MAX;
\r
1345 return (BOOL)MonthCal_SetRange(m_hWnd, dwLimit, &MinMax);
\r
1348 inline BOOL CMonthCalendar::SetSelRange(const LPSYSTEMTIME pMinRange, const LPSYSTEMTIME pMaxRange)
\r
1350 SYSTEMTIME MinMax[2];
\r
1351 memcpy(&MinMax[0], pMinRange, sizeof(SYSTEMTIME));
\r
1352 memcpy(&MinMax[1], pMaxRange, sizeof(SYSTEMTIME));
\r
1353 return (BOOL)MonthCal_SetSelRange(m_hWnd, &MinMax);
\r
1356 inline void CMonthCalendar::SetToday(const LPSYSTEMTIME pDateTime)
\r
1358 assert(IsWindow());
\r
1359 MonthCal_SetToday(m_hWnd, pDateTime);
\r
1363 ////////////////////////////////////////
\r
1364 // Definitions for the CProgressBar class
\r
1366 inline int CProgressBar::GetPos() const
\r
1367 // Retrieves the current position of the progress bar.
\r
1369 assert(IsWindow());
\r
1370 return (int)SendMessage(PBM_GETPOS, 0, 0);
\r
1373 inline int CProgressBar::GetRange(BOOL fWhichLimit, PPBRANGE ppBRange) const
\r
1374 // Retrieves information about the current high and low limits of the progress bar control.
\r
1376 assert(IsWindow());
\r
1377 return (int)SendMessage(PBM_GETRANGE, (WPARAM)fWhichLimit, (LPARAM) (PPBRANGE) ppBRange);
\r
1380 inline int CProgressBar::OffsetPos(int nIncrement) const
\r
1381 // Advances the current position of the progress bar by a specified increment and redraws
\r
1382 // the bar to reflect the new position.
\r
1384 assert(IsWindow());
\r
1385 return (int)SendMessage(PBM_DELTAPOS, (WPARAM)nIncrement, 0);
\r
1388 inline int CProgressBar::SetPos(int nNewPos) const
\r
1389 // Sets the current position for the progress bar and redraws the bar to reflect the new position.
\r
1391 assert(IsWindow());
\r
1392 return (int)SendMessage(PBM_SETPOS, (WPARAM)nNewPos, 0);
\r
1395 inline int CProgressBar::SetRange(short nMinRange, short nMaxRange) const
\r
1396 // Sets the minimum and maximum values for the progress bar and redraws the bar to reflect the new range.
\r
1398 assert(IsWindow());
\r
1399 return (int)SendMessage(PBM_SETRANGE, 0, (LPARAM) MAKELPARAM (nMinRange, nMaxRange));
\r
1402 inline int CProgressBar::SetStep(int nStepInc) const
\r
1403 // Specifies the step increment for the progress bar.
\r
1405 assert(IsWindow());
\r
1406 return (int)SendMessage(PBM_SETSTEP, (WPARAM)nStepInc, 0);
\r
1409 inline int CProgressBar::StepIt() const
\r
1410 // Advances the current position for a progress bar by the step increment and
\r
1411 // redraws the bar to reflect the new position.
\r
1413 assert(IsWindow());
\r
1414 return (int)SendMessage(PBM_STEPIT, 0, 0);
\r
1418 ////////////////////////////////////////
\r
1419 // Definitions for the CScrollBar class
\r
1421 inline BOOL CScrollBar::EnableScrollBar( UINT nArrowFlags ) const
\r
1422 // Enables or disables the scroll bar arrows.
\r
1424 assert(IsWindow());
\r
1425 return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags);
\r
1428 inline BOOL CScrollBar::GetScrollInfo(LPSCROLLINFO lpsi) const
\r
1429 // Retrieves the parameters of a scroll bar, including the minimum and maximum
\r
1430 // scrolling positions, the page size, and the position of the scroll box (thumb).
\r
1432 assert(IsWindow());
\r
1433 return ::GetScrollInfo(m_hWnd, SB_CTL, lpsi);
\r
1436 inline int CScrollBar::GetScrollPos() const
\r
1437 // Retrieves the current position of the scroll box (thumb) in the scroll bar.
\r
1439 assert(IsWindow());
\r
1440 return ::GetScrollPos(m_hWnd, SB_CTL);
\r
1443 inline BOOL CScrollBar::GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos ) const
\r
1444 // Retrieves the current minimum and maximum scroll box (thumb) positions for the scroll bar.
\r
1446 assert(IsWindow());
\r
1447 return ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos);
\r
1450 inline BOOL CScrollBar::SetScrollInfo(LPSCROLLINFO lpsi, BOOL bRedraw ) const
\r
1451 // Sets the parameters of the scroll bar, including the minimum and maximum scrolling positions,
\r
1452 // the page size, and the position of the scroll box (thumb).
\r
1454 assert(IsWindow());
\r
1455 return ::SetScrollInfo(m_hWnd, SB_CTL, lpsi, bRedraw);
\r
1458 inline int CScrollBar::SetScrollPos(int nPos, BOOL bRedraw) const
\r
1459 // Sets the position of the scroll box (thumb) in the scroll bar and, if requested,
\r
1460 // redraws the scroll bar to reflect the new position of the scroll box.
\r
1462 assert(IsWindow());
\r
1463 return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw);
\r
1466 inline BOOL CScrollBar::SetScrollRange( int nMinPos, int nMaxPos, BOOL bRedraw ) const
\r
1467 // Sets the minimum and maximum scroll box positions for the scroll bar.
\r
1469 assert(IsWindow());
\r
1470 return ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw);
\r
1473 inline BOOL CScrollBar::ShowScrollBar(BOOL bShow) const
\r
1474 // Shows or hides the scroll bar.
\r
1476 assert(IsWindow());
\r
1477 return ::ShowScrollBar(m_hWnd, SB_CTL, bShow);
\r
1480 ////////////////////////////////////////
\r
1481 // Definitions for the CSlider class
\r
1483 inline void CSlider::ClearSel() const
\r
1484 // Clears the current selection range in the trackbar.
\r
1486 assert(IsWindow());
\r
1487 SendMessage(TBM_CLEARSEL, 0, 0);
\r
1490 inline void CSlider::ClearTics(BOOL bRedraw) const
\r
1491 // Removes the current tick marks from the trackbar.
\r
1493 assert(IsWindow());
\r
1494 SendMessage(TBM_CLEARTICS, (WPARAM)bRedraw, 0);
\r
1497 inline CWnd* CSlider::GetBuddy(BOOL fLocation) const
\r
1498 // Retrieves the handle to the trackbar control buddy window at a given location.
\r
1500 assert(IsWindow());
\r
1501 return FromHandle((HWND)SendMessage(TBM_GETBUDDY, (WPARAM)fLocation, 0));
\r
1504 inline CRect CSlider::GetChannelRect() const
\r
1505 // Retrieves the size and position of the bounding rectangle for the trackbar's channel.
\r
1507 assert(IsWindow());
\r
1509 SendMessage(TBM_GETCHANNELRECT, 0, (LPARAM)&rc);
\r
1513 inline int CSlider::GetLineSize() const
\r
1514 // Retrieves the number of logical positions the trackbar's slider moves in response
\r
1515 // to keyboard input from the arrow keys.
\r
1517 assert(IsWindow());
\r
1518 return (int)SendMessage(TBM_GETLINESIZE, 0, 0);
\r
1521 inline int CSlider::GetNumTics() const
\r
1522 // Retrieves the number of tick marks in the trackbar.
\r
1524 assert(IsWindow());
\r
1525 return (int)SendMessage(TBM_GETNUMTICS, 0, 0);
\r
1528 inline int CSlider::GetPageSize() const
\r
1529 // Retrieves the number of logical positions the trackbar's slider moves in response to
\r
1530 // keyboard input, or mouse input, such as clicks in the trackbar's channel.
\r
1532 assert(IsWindow());
\r
1533 return (int)SendMessage(TBM_GETPAGESIZE, 0, 0);
\r
1536 inline int CSlider::GetPos() const
\r
1537 // Retrieves the current logical position of the slider in the trackbar.
\r
1539 assert(IsWindow());
\r
1540 return (int)SendMessage(TBM_GETPOS, 0, 0);
\r
1543 inline int CSlider::GetRangeMax() const
\r
1544 // Retrieves the maximum position for the slider in the trackbar.
\r
1546 assert(IsWindow());
\r
1547 return (int)SendMessage(TBM_GETRANGEMAX, 0, 0);
\r
1550 inline int CSlider::GetRangeMin() const
\r
1551 // Retrieves the minimum position for the slider in the trackbar.
\r
1553 assert(IsWindow());
\r
1554 return (int)SendMessage(TBM_GETRANGEMIN, 0, 0);
\r
1557 inline int CSlider::GetSelEnd() const
\r
1558 // Retrieves the ending position of the current selection range in the trackbar.
\r
1560 assert(IsWindow());
\r
1561 return (int)SendMessage(TBM_GETSELEND, 0, 0);
\r
1564 inline int CSlider::GetSelStart() const
\r
1565 // Retrieves the starting position of the current selection range in the trackbar.
\r
1567 assert(IsWindow());
\r
1568 return (int)SendMessage(TBM_GETSELSTART, 0, 0);
\r
1571 inline int CSlider::GetThumbLength() const
\r
1572 // Retrieves the length of the slider in the trackbar.
\r
1574 assert(IsWindow());
\r
1575 return (int)SendMessage(TBM_GETTHUMBLENGTH, 0, 0);
\r
1578 inline CRect CSlider::GetThumbRect() const
\r
1579 // Retrieves the size and position of the bounding rectangle for the slider in the trackbar.
\r
1582 SendMessage(TBM_GETTHUMBRECT, 0, (LPARAM)&rc);
\r
1586 inline int CSlider::GetTic(int nTic ) const
\r
1587 // Retrieves the logical position of a tick mark in the trackbar.
\r
1589 assert(IsWindow());
\r
1590 return (int)SendMessage(TBM_GETTIC, (WPARAM)nTic, 0);
\r
1593 inline int CSlider::GetTicPos(int nTic) const
\r
1594 // Retrieves the current physical position of a tick mark in the trackbar.
\r
1596 assert(IsWindow());
\r
1597 return (int)SendMessage(TBM_GETTICPOS, (WPARAM)nTic, 0);
\r
1600 inline CToolTip* CSlider::GetToolTips() const
\r
1601 // Retrieves the handle to the ToolTip control assigned to the trackbar, if any.
\r
1603 assert(IsWindow());
\r
1604 return (CToolTip*)FromHandle((HWND)SendMessage(TBM_GETTOOLTIPS, 0, 0));
\r
1607 inline CWnd* CSlider::SetBuddy(CWnd* pBuddy, BOOL fLocation /*= TRUE*/ ) const
\r
1608 // Assigns a window as the buddy window for the trackbar control.
\r
1610 assert(IsWindow());
\r
1611 return FromHandle((HWND)SendMessage(TBM_SETBUDDY, (WPARAM)fLocation, (LPARAM)pBuddy->GetHwnd()));
\r
1614 inline int CSlider::SetLineSize(int nSize) const
\r
1615 // Sets the number of logical positions the trackbar's slider moves in response to
\r
1616 // keyboard input from the arrow keys.
\r
1618 assert(IsWindow());
\r
1619 return(int)SendMessage(TBM_SETLINESIZE, 0, (LPARAM)nSize);
\r
1622 inline int CSlider::SetPageSize(int nSize) const
\r
1623 // Sets the number of logical positions the trackbar's slider moves in response to
\r
1624 // keyboard input, or mouse input such as clicks in the trackbar's channel.
\r
1626 assert(IsWindow());
\r
1627 return(int)SendMessage(TBM_SETPAGESIZE, 0, (LPARAM)nSize);
\r
1630 inline void CSlider::SetPos(int nPos, BOOL bRedraw) const
\r
1631 // Sets the current logical position of the slider in the trackbar.
\r
1633 assert(IsWindow());
\r
1634 SendMessage(TBM_SETPOS, (WPARAM)bRedraw, (LPARAM)nPos);
\r
1637 inline void CSlider::SetRangeMax(int nMax, BOOL bRedraw) const
\r
1638 // Sets the maximum logical position for the slider in the trackbar.
\r
1640 assert(IsWindow());
\r
1641 SendMessage(TBM_SETRANGEMAX, (WPARAM)bRedraw, (LPARAM)nMax);
\r
1644 inline void CSlider::SetRangeMin(int nMax, BOOL bRedraw) const
\r
1645 // Sets the minimum logical position for the slider in the trackbar.
\r
1647 assert(IsWindow());
\r
1648 SendMessage(TBM_SETRANGEMIN, (WPARAM)bRedraw, (LPARAM)nMax);
\r
1651 inline void CSlider::SetSelection(int nMin, int nMax, BOOL bRedraw) const
\r
1652 // Sets the starting and ending positions for the available selection range in the trackbar.
\r
1654 assert(IsWindow());
\r
1655 SendMessage(TBM_SETSEL, (WPARAM)bRedraw, (LPARAM)MAKELONG(nMax, nMin));
\r
1658 inline BOOL CSlider::SetTic(int nTic) const
\r
1659 // Sets a tick mark in the trackbar at the specified logical position.
\r
1661 assert(IsWindow());
\r
1662 return (BOOL)SendMessage(TBM_SETTIC, 0, nTic);
\r
1665 inline void CSlider::SetTicFreq(int nFreq) const
\r
1666 // Sets the interval frequency for tick marks in the trackbar.
\r
1668 assert(IsWindow());
\r
1669 SendMessage(TBM_SETTICFREQ, (WPARAM)nFreq, 0);
\r
1672 inline int CSlider::SetTipSide(int nLocation) const
\r
1673 // Positions a ToolTip control used by the trackbar control.
\r
1675 assert(IsWindow());
\r
1676 return (int)SendMessage(TBM_SETTIPSIDE, (WPARAM)nLocation, 0);
\r
1679 inline void CSlider::SetToolTips(CToolTip* pToolTip) const
\r
1680 // Assigns a ToolTip control to the trackbar control.
\r
1682 assert(IsWindow());
\r
1683 HWND hToolTip = pToolTip? pToolTip->GetHwnd() : 0;
\r
1684 SendMessage(TBM_SETTOOLTIPS, (WPARAM)hToolTip, 0);
\r
1687 ////////////////////////////////////////
\r
1688 // Definitions for the CSpinButton class
\r
1690 inline int CSpinButton::GetAccel(int cAccels, LPUDACCEL paAccels) const
\r
1691 // Retrieves acceleration information for the up-down control.
\r
1693 assert(IsWindow());
\r
1694 return (int)SendMessage(UDM_GETACCEL, (WPARAM)cAccels, (LPARAM)paAccels);
\r
1697 inline int CSpinButton::GetBase() const
\r
1698 // Retrieves the current radix base (that is, either base 10 or 16) for the up-down control.
\r
1700 assert(IsWindow());
\r
1701 return (int)SendMessage(UDM_GETBASE, 0, 0);
\r
1704 inline CWnd* CSpinButton::GetBuddy() const
\r
1705 // Retrieves the handle to the current buddy window.
\r
1707 assert(IsWindow());
\r
1708 return FromHandle((HWND)SendMessage(UDM_GETBUDDY, 0, 0));
\r
1711 inline int CSpinButton::GetPos() const
\r
1712 // Retrieves the current position of the up-down control with 16-bit precision.
\r
1714 assert(IsWindow());
\r
1715 return (int)SendMessage(UDM_GETPOS, 0, 0);
\r
1718 inline DWORD CSpinButton::GetRange() const
\r
1719 // Retrieves the minimum and maximum positions (range) for the up-down control.
\r
1721 assert(IsWindow());
\r
1722 return (DWORD)SendMessage(UDM_GETRANGE, 0, 0);
\r
1725 inline void CSpinButton::PreCreate(CREATESTRUCT &cs)
\r
1727 cs.style = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VISIBLE |UDS_SETBUDDYINT;
\r
1730 inline void CSpinButton::PreRegisterClass(WNDCLASS &wc)
\r
1732 wc.lpszClassName = UPDOWN_CLASS;
\r
1735 inline BOOL CSpinButton::SetAccel(int cAccels, LPUDACCEL paAccels) const
\r
1736 // Sets the acceleration for the up-down control.
\r
1738 assert(IsWindow());
\r
1739 return (BOOL)SendMessage(UDM_SETACCEL, (WPARAM)cAccels, (LPARAM)paAccels);
\r
1742 inline int CSpinButton::SetBase(int nBase) const
\r
1743 // Sets the radix base for the up-down control.
\r
1745 assert(IsWindow());
\r
1746 return (int)SendMessage(UDM_SETBASE, (WPARAM)nBase, 0);
\r
1749 inline CWnd* CSpinButton::SetBuddy(CWnd* pBuddy) const
\r
1750 // Sets the buddy window for the up-down control.
\r
1752 assert(IsWindow());
\r
1753 return FromHandle((HWND)SendMessage(UDM_SETBUDDY, (WPARAM)pBuddy->GetHwnd(), 0));
\r
1756 inline int CSpinButton::SetPos(int nPos) const
\r
1757 // Sets the current position for the up-down control with 16-bit precision.
\r
1759 assert(IsWindow());
\r
1760 return (int)SendMessage(UDM_SETPOS, 0, (LPARAM)MAKELONG ((short) nPos, 0));
\r
1763 inline void CSpinButton::SetRange(int nLower, int nUpper) const
\r
1764 // Sets the minimum and maximum positions (range) for the up-down control.
\r
1766 assert(IsWindow());
\r
1767 SendMessage(UDM_SETRANGE, 0, (LPARAM)MAKELONG(nUpper, nLower));
\r
1770 ////////////////////////////////////////
\r
1771 // Definitions for the CToolTip class
\r
1774 inline CToolTip::CToolTip()
\r
1777 inline CToolTip::~CToolTip()
\r
1780 inline void CToolTip::Activate(BOOL bActivate)
\r
1781 // Activates or deactivates a ToolTip control.
\r
1783 assert(IsWindow());
\r
1784 SendMessage(TTM_ACTIVATE, bActivate, 0);
\r
1787 inline BOOL CToolTip::AddTool(CWnd* pWnd, UINT nIDText, LPCRECT lpRectTool /*= NULL*/, UINT_PTR nIDTool /*= 0*/)
\r
1788 // Registers a tool with a ToolTip control.
\r
1790 assert(IsWindow());
\r
1793 LoadToolInfo(ti, pWnd, nIDTool);
\r
1794 ti.hinst = GetApp()->GetResourceHandle();
\r
1795 ti.lpszText = (LPTSTR)MAKEINTRESOURCE(nIDText);
\r
1797 ti.rect = *lpRectTool;
\r
1798 return (BOOL)SendMessage(TTM_ADDTOOL, 0, (LPARAM)&ti);
\r
1801 inline BOOL CToolTip::AddTool(CWnd* pWnd, LPCTSTR lpszText /*= LPSTR_TEXTCALLBACK*/, LPCRECT lpRectTool /*= NULL*/, UINT_PTR nIDTool /*= 0*/)
\r
1802 // Registers a tool with a ToolTip control.
\r
1804 assert(IsWindow());
\r
1807 LoadToolInfo(ti, pWnd, nIDTool);
\r
1808 ti.lpszText = (LPTSTR)lpszText;
\r
1810 ti.rect = *lpRectTool;
\r
1811 return (BOOL)SendMessage(TTM_ADDTOOL, 0, (LPARAM)&ti);
\r
1814 inline void CToolTip::DelTool(CWnd* pWnd, UINT_PTR nIDTool /*= 0*/)
\r
1815 // Removes a tool from a ToolTip control.
\r
1817 assert(IsWindow());
\r
1819 LoadToolInfo(ti, pWnd, nIDTool);
\r
1820 SendMessage(TTM_DELTOOL, 0, (LPARAM)&ti);
\r
1823 inline int CToolTip::GetDelayTime(DWORD dwDuration) const
\r
1824 // Retrieves the initial, pop-up, and reshow durations currently set for a ToolTip control.
\r
1826 assert(IsWindow());
\r
1827 return (int)SendMessage(TTM_GETDELAYTIME, dwDuration, 0);
\r
1830 inline void CToolTip::GetMargin(LPRECT lprc) const
\r
1831 // Retrieves the top, left, bottom, and right margins set for a ToolTip window.
\r
1833 assert(IsWindow());
\r
1834 SendMessage(TTM_GETMARGIN, 0, (LPARAM)lprc);
\r
1837 inline int CToolTip::GetMaxTipWidth() const
\r
1838 // Retrieves the maximum width for a ToolTip window.
\r
1840 assert(IsWindow());
\r
1841 return (int)SendMessage(TTM_GETMAXTIPWIDTH, 0, 0);
\r
1844 inline void CToolTip::GetText(CString& str, CWnd* pWnd, UINT_PTR nIDTool /*= 0*/) const
\r
1845 // Retrieves the information a ToolTip control maintains about a tool.
\r
1847 assert(IsWindow());
\r
1849 LPTSTR pszText = str.GetBuffer(80); // Maximum allowed Tooltip is 80 characters for Windows XP and below
\r
1851 LoadToolInfo(ti, pWnd, nIDTool);
\r
1852 ti.lpszText = pszText;
\r
1853 SendMessage(TTM_GETTEXT, 0, (LPARAM)&ti);
\r
1854 str.ReleaseBuffer();
\r
1857 inline COLORREF CToolTip::GetTipBkColor() const
\r
1858 // Retrieves the background color in a ToolTip window.
\r
1860 assert(IsWindow());
\r
1861 return (COLORREF)SendMessage(TTM_GETTIPBKCOLOR, 0,0);
\r
1864 inline COLORREF CToolTip::GetTipTextColor() const
\r
1865 // Retrieves the text color in a ToolTip window.
\r
1867 assert(IsWindow());
\r
1868 return (COLORREF)SendMessage(TTM_GETTIPTEXTCOLOR, 0, 0);
\r
1871 inline int CToolTip::GetToolCount() const
\r
1872 // Retrieves a count of the tools maintained by a ToolTip control.
\r
1874 assert(IsWindow());
\r
1875 return (int)SendMessage(TTM_GETTOOLCOUNT, 0, 0);
\r
1878 inline BOOL CToolTip::GetToolInfo(TOOLINFO& ToolInfo, CWnd* pWnd, UINT_PTR nIDTool /*= 0*/) const
\r
1879 // Retrieves the information that a ToolTip control maintains about a tool.
\r
1881 assert(IsWindow());
\r
1883 LoadToolInfo(ToolInfo, pWnd, nIDTool);
\r
1884 return (BOOL)SendMessage(TTM_GETTOOLINFO, 0, (LPARAM)&ToolInfo);
\r
1887 inline BOOL CToolTip::HitTest(CWnd* pWnd, CPoint pt, LPTOOLINFO lpToolInfo) const
\r
1888 // Tests a point to determine whether it is within the bounding rectangle of the
\r
1889 // specified tool and, if it is, retrieves information about the tool.
\r
1891 assert(IsWindow());
\r
1893 assert(lpToolInfo);
\r
1894 TTHITTESTINFO hti = {0};
\r
1895 hti.hwnd = pWnd->GetHwnd();
\r
1897 hti.ti = *lpToolInfo;
\r
1898 return (BOOL)SendMessage(TTM_HITTEST, 0, (LPARAM)&hti);
\r
1901 inline void CToolTip::LoadToolInfo(TOOLINFO& ti, CWnd* pWnd, UINT_PTR nIDTool) const
\r
1903 ZeroMemory(&ti, sizeof(TOOLINFO));
\r
1904 ti.cbSize = sizeof(TOOLINFO);
\r
1905 HWND hWnd = pWnd->GetHwnd();
\r
1908 ti.hwnd = ::GetParent(hWnd);
\r
1909 ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
\r
1910 ti.uId = (UINT)hWnd;
\r
1919 inline void CToolTip::Pop()
\r
1920 // Removes a displayed ToolTip window from view.
\r
1922 assert(IsWindow());
\r
1923 SendMessage(TTM_POP, 0, 0);
\r
1926 inline void CToolTip::RelayEvent(LPMSG lpMsg)
\r
1927 // Passes a mouse message to a ToolTip control for processing.
\r
1929 assert(IsWindow());
\r
1930 SendMessage(TTM_RELAYEVENT, 0, (LPARAM)lpMsg);
\r
1933 inline void CToolTip::SetDelayTime(UINT nDelay)
\r
1934 // Sets the initial delay for a ToolTip control.
\r
1936 assert(IsWindow());
\r
1937 SendMessage(TTM_SETDELAYTIME, TTDT_INITIAL, nDelay);
\r
1940 inline void CToolTip::SetDelayTime(DWORD dwDuration, int iTime)
\r
1941 // Sets the initial, pop-up, and reshow durations for a ToolTip control.
\r
1943 assert(IsWindow());
\r
1944 SendMessage(TTM_SETDELAYTIME, dwDuration, iTime);
\r
1947 inline void CToolTip::SetMargin(LPRECT lprc)
\r
1948 // Sets the top, left, bottom, and right margins for a ToolTip window.
\r
1950 assert(IsWindow());
\r
1952 SendMessage(TTM_SETMARGIN, 0, (LPARAM)lprc);
\r
1955 inline int CToolTip::SetMaxTipWidth(int iWidth)
\r
1956 // Sets the maximum width for a ToolTip window.
\r
1958 assert(IsWindow());
\r
1959 return (int)SendMessage(TTM_SETMAXTIPWIDTH, 0, iWidth);
\r
1962 inline void CToolTip::SetTipBkColor(COLORREF clr)
\r
1963 // Sets the background color in a ToolTip window.
\r
1964 // Ignored when XP themes are active.
\r
1966 assert(IsWindow());
\r
1967 SendMessage(TTM_SETTIPBKCOLOR, clr, 0);
\r
1970 inline void CToolTip::SetTipTextColor(COLORREF clr)
\r
1971 // Sets the text color in a ToolTip window.
\r
1972 // Ignored when XP themes are active.
\r
1974 assert(IsWindow());
\r
1975 SendMessage(TTM_SETTIPTEXTCOLOR, clr, 0);
\r
1978 inline void CToolTip::SetToolInfo(LPTOOLINFO lpToolInfo)
\r
1979 // Sets the information that a ToolTip control maintains for a tool.
\r
1981 assert(IsWindow());
\r
1982 SendMessage(TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo);
\r
1985 inline void CToolTip::SetToolRect(CWnd* pWnd, UINT_PTR nIDTool, LPCRECT lpRect)
\r
1986 // Sets a new bounding rectangle for a tool.
\r
1988 assert(IsWindow());
\r
1992 LoadToolInfo(ti, pWnd, nIDTool);
\r
1993 ti.rect = *lpRect;
\r
1994 SendMessage(TTM_NEWTOOLRECT, 0, (LPARAM)&ti);
\r
1997 inline void CToolTip::Update()
\r
1998 // Forces the current tool to be redrawn.
\r
2000 assert(IsWindow());
\r
2001 SendMessage(TTM_UPDATE, 0, 0);
\r
2004 inline void CToolTip::UpdateTipText(LPCTSTR lpszText, CWnd* pWnd, UINT_PTR nIDTool /*= 0*/)
\r
2005 // Sets the ToolTip text for a tool.
\r
2007 assert(IsWindow());
\r
2010 LoadToolInfo(ti, pWnd, nIDTool);
\r
2011 ti.lpszText = (LPTSTR)lpszText;
\r
2012 SendMessage(TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
\r
2015 inline void CToolTip::UpdateTipText(UINT nIDText, CWnd* pWnd, UINT_PTR nIDTool /*= 0*/)
\r
2016 // Sets the ToolTip text for a tool.
\r
2018 assert(IsWindow());
\r
2021 LoadToolInfo(ti, pWnd, nIDTool);
\r
2022 ti.hinst = GetApp()->GetResourceHandle();
\r
2023 ti.lpszText = (LPTSTR)MAKEINTRESOURCE(nIDText);
\r
2024 SendMessage(TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
\r
2027 #if (defined TTM_SETTITLE) && (_WIN32_IE >=0x0500)
\r
2028 inline BOOL CToolTip::AdjustRect(LPRECT lprc, BOOL bLarger /*= TRUE*/)
\r
2029 // Calculates a ToolTip control's text display rectangle from its window rectangle, or the
\r
2030 // ToolTip window rectangle needed to display a specified text display rectangle.
\r
2032 assert(IsWindow());
\r
2033 return (BOOL)SendMessage(TTM_ADJUSTRECT, bLarger, (LPARAM)lprc);
\r
2036 inline CSize CToolTip::GetBubbleSize(LPTOOLINFO lpToolInfo) const
\r
2037 // Returns the width and height of a ToolTip control.
\r
2039 assert(IsWindow());
\r
2040 LRESULT lr = SendMessage(TTM_GETBUBBLESIZE, (LPARAM)lpToolInfo);
\r
2041 CSize sz(LOWORD(lr), HIWORD(lr));
\r
2045 inline BOOL CToolTip::SetTitle(UINT uIcon, LPCTSTR lpstrTitle)
\r
2046 // Adds a standard icon and title string to a ToolTip.
\r
2048 assert(IsWindow());
\r
2049 return (BOOL)SendMessage(TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle);
\r
2053 #if (defined TTM_SETWINDOWTHEME) && (WINVER >= 0x0501)
\r
2054 inline HRESULT CToolTip::SetWindowTheme(LPCWSTR lpstrTheme)
\r
2055 // Sets the visual style of a ToolTip control.
\r
2057 assert(IsWindow());
\r
2058 SendMessage(TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme);
\r
2063 } // namespace Win32xx
\r
2065 #endif // define _WIN32XX_CONTROLS_H_
\r