sprint 1-alpha
|
00001 /****************************************************************************** 00002 * GTL: GUI Template Library 00003 * A Cross Platform C++ Wrapper for Win32 users 00004 * Copyright (C) 2007-2011 Paolo Medici (www.pmx.it) 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 *******************************************************************************/ 00021 00022 #ifndef _SPRINT_TOOLBAR_H 00023 #define _SPRINT_TOOLBAR_H 00024 00028 #include <sprint/gtl/Window.h> 00029 #include <sprint/gtl/detail/commctrl.h> 00030 00031 namespace sprint { 00032 namespace gtl { 00033 00035 class ToolBar: public CWindow { 00036 public: 00037 // 00038 void Create(HWND hParent, int id, int style = TBSTYLE_FLAT | TBSTYLE_TOOLTIPS) 00039 { 00040 CommonControl::Instance(); 00041 00042 m_hwnd = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | style, 0, 0, 0, 0, 00043 hParent, (HMENU)id, GetModuleHandle(NULL), NULL); 00044 00045 // Send the TB_BUTTONSTRUCTSIZE message, which is required for 00046 // backward compatibility. 00047 ::SendMessage(m_hwnd, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); 00048 00049 } 00050 00051 void OnSize() 00052 { 00053 ::SendMessage(m_hwnd, TB_AUTOSIZE, 0, 0); 00054 } 00055 00056 bool IsButtonEnabled(int nID) const 00057 { 00058 return (bool)::SendMessage(m_hwnd, TB_ISBUTTONENABLED, nID, 0L); 00059 } 00060 00061 bool IsButtonChecked(int nID) const 00062 { 00063 return (bool)::SendMessage(m_hwnd, TB_ISBUTTONCHECKED, nID, 0L); 00064 } 00065 00066 bool IsButtonPressed(int nID) const 00067 { 00068 return (bool)::SendMessage(m_hwnd, TB_ISBUTTONPRESSED, nID, 0L); 00069 } 00070 00071 bool IsButtonHidden(int nID) const 00072 { 00073 return(bool) ::SendMessage(m_hwnd, TB_ISBUTTONHIDDEN, nID, 0L); 00074 } 00075 00076 bool IsButtonIndeterminate(int nID) const 00077 { 00078 return (bool)::SendMessage(m_hwnd, TB_ISBUTTONINDETERMINATE, nID, 0L); 00079 } 00080 00081 int GetState(int nID) const 00082 { 00083 return (int)::SendMessage(m_hwnd, TB_GETSTATE, nID, 0L); 00084 } 00085 00086 bool SetState(int nID, UINT nState) 00087 { 00088 return (bool)::SendMessage(m_hwnd, TB_SETSTATE, nID, MAKELPARAM(nState, 0)); 00089 } 00090 00091 bool GetButton(int nIndex, LPTBBUTTON lpButton) const 00092 { 00093 return (bool)::SendMessage(m_hwnd, TB_GETBUTTON, nIndex, (LPARAM)lpButton); 00094 } 00095 00096 int GetButtonCount() const 00097 { 00098 return (int)::SendMessage(m_hwnd, TB_BUTTONCOUNT, 0, 0L); 00099 } 00100 00101 bool GetItemRect(int nIndex, LPRECT lpRect) const 00102 { 00103 return (bool)::SendMessage(m_hwnd, TB_GETITEMRECT, nIndex, (LPARAM)lpRect); 00104 } 00105 00106 void SetButtonStructSize(int nSize = sizeof(TBBUTTON)) 00107 { 00108 ::SendMessage(m_hwnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); 00109 } 00110 00111 bool SetButtonSize(SIZE size) 00112 { 00113 return (bool)::SendMessage(m_hwnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(size.cx, size.cy)); 00114 } 00115 00116 bool SetButtonSize(int cx, int cy) 00117 { 00118 return (bool)::SendMessage(m_hwnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cy)); 00119 } 00120 00121 bool SetBitmapSize(SIZE size) 00122 { 00123 return (bool)::SendMessage(m_hwnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(size.cx, size.cy)); 00124 } 00125 00126 bool SetBitmapSize(int cx, int cy) 00127 { 00128 return (bool)::SendMessage(m_hwnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(cx, cy)); 00129 } 00130 00131 void SetNotifyWnd(HWND hWnd) 00132 { 00133 ::SendMessage(m_hwnd, TB_SETPARENT, (WPARAM)hWnd, 0L); 00134 } 00135 00136 int GetRows() const 00137 { 00138 return (int)::SendMessage(m_hwnd, TB_GETROWS, 0, 0L); 00139 } 00140 00141 void SetRows(int nRows, bool bLarger, LPRECT lpRect) 00142 { 00143 ::SendMessage(m_hwnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); 00144 } 00145 00146 bool SetCmdID(int nIndex, UINT nID) 00147 { 00148 return (bool)::SendMessage(m_hwnd, TB_SETCMDID, nIndex, nID); 00149 } 00150 00151 DWORD GetBitmapFlags() const 00152 { 00153 return (DWORD)::SendMessage(m_hwnd, TB_GETBITMAPFLAGS, 0, 0L); 00154 } 00155 00156 int GetBitmap(int nID) const 00157 { 00158 return (int)::SendMessage(m_hwnd, TB_GETBITMAP, nID, 0L); 00159 } 00160 00161 int GetButtonText(int nID, LPTSTR lpstrText) const 00162 { 00163 return (int)::SendMessage(m_hwnd, TB_GETBUTTONTEXT, nID, (LPARAM)lpstrText); 00164 } 00165 00166 // nIndex - IE5 or higher only 00167 HIMAGELIST GetImageList(int nIndex = 0) const 00168 { 00169 return (HIMAGELIST)::SendMessage(m_hwnd, TB_GETIMAGELIST, nIndex, 0L); 00170 } 00171 00172 // nIndex - IE5 or higher only 00173 HIMAGELIST SetImageList(HIMAGELIST hImageList, int nIndex = 0) 00174 { 00175 return (HIMAGELIST)::SendMessage(m_hwnd, TB_SETIMAGELIST, nIndex, (LPARAM)hImageList); 00176 } 00177 00178 // nIndex - IE5 or higher only 00179 HIMAGELIST GetDisabledImageList(int nIndex = 0) const 00180 { 00181 return (HIMAGELIST)::SendMessage(m_hwnd, TB_GETDISABLEDIMAGELIST, nIndex, 0L); 00182 } 00183 00184 // nIndex - IE5 or higher only 00185 HIMAGELIST SetDisabledImageList(HIMAGELIST hImageList, int nIndex = 0) 00186 { 00187 return (HIMAGELIST)::SendMessage(m_hwnd, TB_SETDISABLEDIMAGELIST, nIndex, (LPARAM)hImageList); 00188 } 00189 00190 00191 DWORD GetStyle() const 00192 { 00193 return (DWORD)::SendMessage(m_hwnd, TB_GETSTYLE, 0, 0L); 00194 } 00195 00196 void SetStyle(DWORD dwStyle) 00197 { 00198 ::SendMessage(m_hwnd, TB_SETSTYLE, 0, dwStyle); 00199 } 00200 00201 SIZE GetButtonSize() const 00202 { 00203 SIZE size; 00204 DWORD dwRet = (DWORD)::SendMessage(m_hwnd, TB_GETBUTTONSIZE, 0, 0L); 00205 size.cx = LOWORD(dwRet); 00206 size.cy = HIWORD(dwRet); 00207 return size; 00208 } 00209 00210 bool GetRect(int nID, LPRECT lpRect) const 00211 { 00212 return (bool)::SendMessage(m_hwnd, TB_GETRECT, nID, (LPARAM)lpRect); 00213 } 00214 00215 int GetTextRows() const 00216 { 00217 return (int)::SendMessage(m_hwnd, TB_GETTEXTROWS, 0, 0L); 00218 } 00219 00220 bool SetButtonWidth(int cxMin, int cxMax) 00221 { 00222 return (bool)::SendMessage(m_hwnd, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cxMin, cxMax)); 00223 } 00224 00225 bool SetIndent(int nIndent) 00226 { 00227 return (bool)::SendMessage(m_hwnd, TB_SETINDENT, nIndent, 0L); 00228 } 00229 00230 bool SetMaxTextRows(int nMaxTextRows) 00231 { 00232 return (bool)::SendMessage(m_hwnd, TB_SETMAXTEXTROWS, nMaxTextRows, 0L); 00233 } 00234 00235 #if (_WIN32_IE >= 0x0400) 00236 #ifndef _WIN32_WCE 00237 bool GetAnchorHighlight() const 00238 { 00239 return (bool)::SendMessage(m_hwnd, TB_GETANCHORHIGHLIGHT, 0, 0L); 00240 } 00241 00242 bool SetAnchorHighlight(bool bEnable = TRUE) 00243 { 00244 return (bool)::SendMessage(m_hwnd, TB_SETANCHORHIGHLIGHT, bEnable, 0L); 00245 } 00246 #endif // !_WIN32_WCE 00247 00248 int GetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) const 00249 { 00250 return (int)::SendMessage(m_hwnd, TB_GETBUTTONINFO, nID, (LPARAM)lptbbi); 00251 } 00252 00253 bool SetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) 00254 { 00255 return (bool)::SendMessage(m_hwnd, TB_SETBUTTONINFO, nID, (LPARAM)lptbbi); 00256 } 00257 00258 bool SetButtonInfo(int nID, DWORD dwMask, BYTE Style, BYTE State, LPCTSTR lpszItem, 00259 int iImage, WORD cx, int iCommand, DWORD_PTR lParam) 00260 { 00261 TBBUTTONINFO tbbi = { 0 }; 00262 tbbi.cbSize = sizeof(TBBUTTONINFO); 00263 tbbi.dwMask = dwMask; 00264 tbbi.idCommand = iCommand; 00265 tbbi.iImage = iImage; 00266 tbbi.fsState = State; 00267 tbbi.fsStyle = Style; 00268 tbbi.cx = cx; 00269 tbbi.pszText = (LPTSTR) lpszItem; 00270 tbbi.lParam = lParam; 00271 return (bool)::SendMessage(m_hwnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); 00272 } 00273 00274 bool SetButtonState(int nID, BYTE State) 00275 { 00276 TBBUTTONINFO tbbi = { 0 }; 00277 tbbi.cbSize = sizeof(TBBUTTONINFO); 00278 tbbi.dwMask = TBIF_STATE; 00279 tbbi.fsState = State; 00280 return (bool)::SendMessage(m_hwnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); 00281 } 00282 00283 #ifndef _WIN32_WCE 00284 int GetHotItem() const 00285 { 00286 return (int)::SendMessage(m_hwnd, TB_GETHOTITEM, 0, 0L); 00287 } 00288 00289 int SetHotItem(int nItem) 00290 { 00291 return (int)::SendMessage(m_hwnd, TB_SETHOTITEM, nItem, 0L); 00292 } 00293 #endif // !_WIN32_WCE 00294 00295 bool IsButtonHighlighted(int nButtonID) const 00296 { 00297 return (bool)::SendMessage(m_hwnd, TB_ISBUTTONHIGHLIGHTED, nButtonID, 0L); 00298 } 00299 00300 DWORD SetDrawTextFlags(DWORD dwMask, DWORD dwFlags) 00301 { 00302 return (DWORD)::SendMessage(m_hwnd, TB_SETDRAWTEXTFLAGS, dwMask, dwFlags); 00303 } 00304 00305 #ifndef _WIN32_WCE 00306 bool GetColorScheme(LPCOLORSCHEME lpcs) const 00307 { 00308 return (bool)::SendMessage(m_hwnd, TB_GETCOLORSCHEME, 0, (LPARAM)lpcs); 00309 } 00310 00311 void SetColorScheme(LPCOLORSCHEME lpcs) 00312 { 00313 ::SendMessage(m_hwnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); 00314 } 00315 00316 DWORD GetExtendedStyle() const 00317 { 00318 return (DWORD)::SendMessage(m_hwnd, TB_GETEXTENDEDSTYLE, 0, 0L); 00319 } 00320 00321 DWORD SetExtendedStyle(DWORD dwStyle) 00322 { 00323 return (DWORD)::SendMessage(m_hwnd, TB_SETEXTENDEDSTYLE, 0, dwStyle); 00324 } 00325 00326 void GetInsertMark(LPTBINSERTMARK lptbim) const 00327 { 00328 ::SendMessage(m_hwnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); 00329 } 00330 00331 void SetInsertMark(LPTBINSERTMARK lptbim) 00332 { 00333 ::SendMessage(m_hwnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); 00334 } 00335 00336 COLORREF GetInsertMarkColor() const 00337 { 00338 return (COLORREF)::SendMessage(m_hwnd, TB_GETINSERTMARKCOLOR, 0, 0L); 00339 } 00340 00341 COLORREF SetInsertMarkColor(COLORREF clr) 00342 { 00343 return (COLORREF)::SendMessage(m_hwnd, TB_SETINSERTMARKCOLOR, 0, (LPARAM)clr); 00344 } 00345 00346 bool GetMaxSize(LPSIZE lpSize) const 00347 { 00348 return (bool)::SendMessage(m_hwnd, TB_GETMAXSIZE, 0, (LPARAM)lpSize); 00349 } 00350 #if 0 00351 void GetPadding(LPSIZE lpSizePadding) const 00352 { 00353 DWORD dwRet = (DWORD)::SendMessage(m_hwnd, TB_GETPADDING, 0, 0L); 00354 lpSizePadding->cx = GET_X_LPARAM(dwRet); 00355 lpSizePadding->cy = GET_Y_LPARAM(dwRet); 00356 } 00357 00358 void SetPadding(int cx, int cy, LPSIZE lpSizePadding = NULL) 00359 { 00360 DWORD dwRet = (DWORD)::SendMessage(m_hwnd, TB_SETPADDING, 0, MAKELPARAM(cx, cy)); 00361 if(lpSizePadding != NULL) 00362 { 00363 lpSizePadding->cx = GET_X_LPARAM(dwRet); 00364 lpSizePadding->cy = GET_Y_LPARAM(dwRet); 00365 } 00366 } 00367 #endif 00368 bool GetUnicodeFormat() const 00369 { 00370 return (bool)::SendMessage(m_hwnd, TB_GETUNICODEFORMAT, 0, 0L); 00371 } 00372 00373 bool SetUnicodeFormat(bool bUnicode = TRUE) 00374 { 00375 return (bool)::SendMessage(m_hwnd, TB_SETUNICODEFORMAT, bUnicode, 0L); 00376 } 00377 #endif // !_WIN32_WCE 00378 #endif // (_WIN32_IE >= 0x0400) 00379 00380 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 00381 int GetString(int nString, LPTSTR lpstrString, int cchMaxLen) const 00382 { 00383 return (int)::SendMessage(m_hwnd, TB_GETSTRING, MAKEWPARAM(cchMaxLen, nString), (LPARAM)lpstrString); 00384 } 00385 00386 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 00387 00388 #if (_WIN32_WINNT >= 0x0501) 00389 void GetMetrics(LPTBMETRICS lptbm) const 00390 { 00391 ::SendMessage(m_hwnd, TB_GETMETRICS, 0, (LPARAM)lptbm); 00392 } 00393 00394 void SetMetrics(LPTBMETRICS lptbm) 00395 { 00396 ::SendMessage(m_hwnd, TB_SETMETRICS, 0, (LPARAM)lptbm); 00397 } 00398 00399 void SetWindowTheme(LPCWSTR lpstrTheme) 00400 { 00401 ::SendMessage(m_hwnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); 00402 } 00403 #endif // (_WIN32_WINNT >= 0x0501) 00404 00405 #if (_WIN32_WINNT >= 0x0600) 00406 HIMAGELIST GetPressedImageList(int nIndex = 0) const 00407 { 00408 return (HIMAGELIST)::SendMessage(m_hwnd, TB_GETPRESSEDIMAGELIST, nIndex, 0L); 00409 } 00410 00411 HIMAGELIST SetPressedImageList(HIMAGELIST hImageList, int nIndex = 0) 00412 { 00413 return (HIMAGELIST)::SendMessage(m_hwnd, TB_SETPRESSEDIMAGELIST, nIndex, (LPARAM)hImageList); 00414 } 00415 #endif // (_WIN32_WINNT >= 0x0600) 00416 00417 // Operations 00418 bool EnableButton(int nID, bool bEnable = TRUE) 00419 { 00420 return (bool)::SendMessage(m_hwnd, TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); 00421 } 00422 00423 bool CheckButton(int nID, bool bCheck = TRUE) 00424 { 00425 return (bool)::SendMessage(m_hwnd, TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); 00426 } 00427 00428 bool PressButton(int nID, bool bPress = TRUE) 00429 { 00430 return (bool)::SendMessage(m_hwnd, TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); 00431 } 00432 00433 bool HideButton(int nID, bool bHide = TRUE) 00434 { 00435 return (bool)::SendMessage(m_hwnd, TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); 00436 } 00437 00438 bool Indeterminate(int nID, bool bIndeterminate = TRUE) 00439 { 00440 return (bool)::SendMessage(m_hwnd, TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); 00441 } 00442 00443 int AddBitmap(int nNumButtons, UINT nBitmapID) 00444 { 00445 TBADDBITMAP tbab = { 0 }; 00446 tbab.hInst = ::GetModuleHandle(NULL); 00447 tbab.nID = nBitmapID; 00448 return (int)::SendMessage(m_hwnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); 00449 } 00450 00451 int AddBitmap(int nNumButtons, HBITMAP hBitmap) 00452 { 00453 TBADDBITMAP tbab = { 0 }; 00454 tbab.hInst = NULL; 00455 tbab.nID = (UINT_PTR)hBitmap; 00456 return (int)::SendMessage(m_hwnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); 00457 } 00458 00459 bool AddButtons(int nNumButtons, LPTBBUTTON lpButtons) 00460 { 00461 return (bool)::SendMessage(m_hwnd, TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); 00462 } 00463 00464 bool InsertButton(int nIndex, LPTBBUTTON lpButton) 00465 { 00466 return (bool)::SendMessage(m_hwnd, TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); 00467 } 00468 00469 bool InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, 00470 INT_PTR iString, DWORD_PTR lParam) 00471 { 00472 TBBUTTON tbb = { 0 }; 00473 tbb.fsStyle = Style; 00474 tbb.fsState = State; 00475 tbb.idCommand = iCommand; 00476 tbb.iBitmap = iBitmap; 00477 tbb.iString = iString; 00478 tbb.dwData = lParam; 00479 return (bool)::SendMessage(m_hwnd, TB_INSERTBUTTON, nIndex, (LPARAM)&tbb); 00480 } 00481 00482 bool InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, 00483 LPCTSTR lpszItem, DWORD_PTR lParam) 00484 { 00485 return InsertButton(nIndex, iCommand, Style, State, iBitmap, (INT_PTR)lpszItem, lParam); 00486 } 00487 00488 bool AddButton(LPTBBUTTON lpButton) 00489 { 00490 return InsertButton(-1, lpButton); 00491 } 00492 00493 bool AddSeparator() 00494 { 00495 return InsertButton(-1, 0, TBSTYLE_SEP, 0, 0, 0, 0); 00496 } 00497 00498 bool AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap) 00499 { 00500 return InsertButton(-1, iCommand, Style, State, iBitmap, 0, 0); 00501 } 00502 00503 bool AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, INT_PTR iString, DWORD_PTR lParam) 00504 { 00505 return InsertButton(-1, iCommand, Style, State, iBitmap, iString, lParam); 00506 } 00507 00508 bool AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, LPCTSTR lpszItem, DWORD_PTR lParam) 00509 { 00510 return InsertButton(-1, iCommand, Style, State, iBitmap, lpszItem, lParam); 00511 } 00512 00513 bool DeleteButton(int nIndex) 00514 { 00515 return (bool)::SendMessage(m_hwnd, TB_DELETEBUTTON, nIndex, 0L); 00516 } 00517 00518 UINT CommandToIndex(UINT nID) const 00519 { 00520 return (UINT)::SendMessage(m_hwnd, TB_COMMANDTOINDEX, nID, 0L); 00521 } 00522 00523 #ifndef _WIN32_WCE 00524 void SaveState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) 00525 { 00526 TBSAVEPARAMS tbs = { 0 }; 00527 tbs.hkr = hKeyRoot; 00528 tbs.pszSubKey = lpszSubKey; 00529 tbs.pszValueName = lpszValueName; 00530 ::SendMessage(m_hwnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs); 00531 } 00532 00533 void RestoreState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) 00534 { 00535 TBSAVEPARAMS tbs = { 0 }; 00536 tbs.hkr = hKeyRoot; 00537 tbs.pszSubKey = lpszSubKey; 00538 tbs.pszValueName = lpszValueName; 00539 ::SendMessage(m_hwnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tbs); 00540 } 00541 00542 void Customize() 00543 { 00544 ::SendMessage(m_hwnd, TB_CUSTOMIZE, 0, 0L); 00545 } 00546 #endif // !_WIN32_WCE 00547 00548 int AddString(UINT nStringID) 00549 { 00550 return (int)::SendMessage(m_hwnd, TB_ADDSTRING, (WPARAM)GetModuleHandle(NULL), (LPARAM)nStringID); 00551 } 00552 00553 int AddStrings(LPCTSTR lpszStrings) 00554 { 00555 return (int)::SendMessage(m_hwnd, TB_ADDSTRING, 0, (LPARAM)lpszStrings); 00556 } 00557 00558 void AutoSize() 00559 { 00560 ::SendMessage(m_hwnd, TB_AUTOSIZE, 0, 0L); 00561 } 00562 /* Changes the bitmap for a button in a toolbar. */ 00563 bool ChangeBitmap(int nID, int nBitmap) 00564 { 00565 return (bool)::SendMessage(m_hwnd, TB_CHANGEBITMAP, nID, MAKELPARAM(nBitmap, 0)); 00566 } 00567 00568 // Load a bitmap from local RESOURCE file 00569 int LoadImages(int nBitmapID) 00570 { 00571 return (int)::SendMessage(m_hwnd, TB_LOADIMAGES, nBitmapID, (LPARAM)GetModuleHandle(NULL)); 00572 } 00573 00574 int LoadStdImages(int nBitmapID) 00575 { 00576 return (int)::SendMessage(m_hwnd, TB_LOADIMAGES, nBitmapID, (LPARAM)HINST_COMMCTRL); 00577 } 00578 00579 bool ReplaceBitmap(LPTBREPLACEBITMAP ptbrb) 00580 { 00581 return (bool)::SendMessage(m_hwnd, TB_REPLACEBITMAP, 0, (LPARAM)ptbrb); 00582 } 00583 00584 #if (_WIN32_IE >= 0x0400) 00585 int HitTest(LPPOINT lpPoint) const 00586 { 00587 return (int)::SendMessage(m_hwnd, TB_HITTEST, 0, (LPARAM)lpPoint); 00588 } 00589 00590 #ifndef _WIN32_WCE 00591 bool InsertMarkHitTest(LPPOINT lpPoint, LPTBINSERTMARK lptbim) const 00592 { 00593 return (bool)::SendMessage(m_hwnd, TB_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)lptbim); 00594 } 00595 00596 bool InsertMarkHitTest(int x, int y, LPTBINSERTMARK lptbim) const 00597 { 00598 POINT pt = { x, y }; 00599 return (bool)::SendMessage(m_hwnd, TB_INSERTMARKHITTEST, (WPARAM)&pt, (LPARAM)lptbim); 00600 } 00601 00602 bool MapAccelerator(TCHAR chAccel, int& nID) const 00603 { 00604 return (bool)::SendMessage(m_hwnd, TB_MAPACCELERATOR, (WPARAM)chAccel, (LPARAM)&nID); 00605 } 00606 00607 bool MarkButton(int nID, bool bHighlight = TRUE) 00608 { 00609 return (bool)::SendMessage(m_hwnd, TB_MARKBUTTON, nID, MAKELPARAM(bHighlight, 0)); 00610 } 00611 00612 bool MoveButton(int nOldPos, int nNewPos) 00613 { 00614 return (bool)::SendMessage(m_hwnd, TB_MOVEBUTTON, nOldPos, nNewPos); 00615 } 00616 00617 HRESULT GetObject(REFIID iid, LPVOID* ppvObject) 00618 { 00619 return (HRESULT)::SendMessage(m_hwnd, TB_GETOBJECT, (WPARAM)&iid, (LPARAM)ppvObject); 00620 } 00621 #endif // !_WIN32_WCE 00622 #endif // (_WIN32_IE >= 0x0400) 00623 00624 }; 00625 00626 } 00627 } 00628 00629 #endif