OOExToolBar.cpp 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  1. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. // = oooo oooo
  3. // = oooooo oooooo
  4. // = oo oo oo oo
  5. // = oo oo oo oo
  6. // = oooooo oooooo
  7. // = oooo oooo Copyright ( c ) The Old Ones 1998
  8. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  9. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  10. // General information section.
  11. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  12. // $Author:: $ User who last changed the file
  13. // $Date:: $ Date and time of last check in
  14. // $Revision:: $ Visual SourceSafe version number
  15. // $Workfile:: $ Filename
  16. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  18. // History section.
  19. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  20. // $History:: $
  21. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  22. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  23. // @doc
  24. // @module OOExToolBar.cpp |
  25. // This module include an improved tool bar.
  26. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  27. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  28. // Include file section.
  29. // ------------------------------------------------------------------------
  30. // Precompile header file.
  31. #include "StdAfx.h"
  32. // Base class definition.
  33. #include "OOExToolBar.h"
  34. // Math include file.
  35. #include "math.h"
  36. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  37. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  38. // Macro and other definition.
  39. // ------------------------------------------------------------------------
  40. #ifdef _DEBUG
  41. #define new DEBUG_NEW
  42. #undef THIS_FILE
  43. static char THIS_FILE[] = __FILE__;
  44. #endif
  45. IMPLEMENT_DYNAMIC( COOExToolBar, CToolBar )
  46. BEGIN_MESSAGE_MAP( COOExToolBar, CToolBar )
  47. //{{AFX_MSG_MAP( COOExToolBar )
  48. ON_WM_NCCALCSIZE()
  49. ON_WM_CREATE()
  50. ON_WM_NCPAINT()
  51. ON_WM_SYSCOLORCHANGE()
  52. ON_WM_WINDOWPOSCHANGING()
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  56. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  57. // Initialization and destruction method.
  58. // ------------------------------------------------------------------------
  59. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  60. // @mfunc: (IMPLEMENTATION)
  61. // <c COOExToolBar>
  62. // This is the main constructor.
  63. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  64. COOExToolBar::COOExToolBar( void )
  65. {
  66. // Set the default flag.
  67. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  68. m_nShowIconMode = 1; // Large icon.
  69. m_bShowIconText = false; // Text.
  70. m_SmallIconSize = CSize( 16, 16 );
  71. m_LargeIconSize = CSize( 32, 32 );
  72. m_bOldFloating=false;
  73. }
  74. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  75. // @mfunc: (IMPLEMENTATION)
  76. // <c COOExToolBar>
  77. // This is the main destructor.
  78. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  79. COOExToolBar::~COOExToolBar( void )
  80. {
  81. // Free the image list associated memory.
  82. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  83. for ( int i=0; i<NB_POSSIBLE_MODE; i++ )
  84. {
  85. if ( m_ImageList[ i ].GetSafeHandle() )
  86. m_ImageList[ i ].DeleteImageList();
  87. }
  88. }
  89. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  90. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  91. // Mode related method.
  92. // ------------------------------------------------------------------------
  93. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  94. // @mfunc: (FUNCTIONAL)
  95. // <c COOExToolBar>
  96. // To view large or small icon.
  97. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  98. void COOExToolBar::SetIconMode(
  99. UINT _nShowIconMode ) // @Parm 0 Small Icon, 1 Large Icon, 2 Extra Large Icon.
  100. {
  101. // Store the new value.
  102. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  103. m_nShowIconMode = _nShowIconMode;
  104. // Load the image list.
  105. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  106. AssignImageList();
  107. // Resize the toolbar.
  108. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  109. ResizeToolBar();
  110. }
  111. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  112. // @mfunc: (FUNCTIONAL)
  113. // <c COOExToolBar>
  114. // To get the large or small icon mode.
  115. // @RDesc 0 Small Icon, 1 Large Icon, 2 Extra Large Icon.
  116. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  117. UINT COOExToolBar::GetIconMode( void ) const
  118. {
  119. return m_nShowIconMode;
  120. }
  121. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  122. // @mfunc: (FUNCTIONAL)
  123. // <c COOExToolBar>
  124. // To set the text on or off.
  125. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  126. void COOExToolBar::SetTextMode(
  127. bool _bShowIconText ) // @Parm True to view the text, false to hide it.
  128. {
  129. // Store the new value.
  130. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  131. m_bShowIconText = _bShowIconText;
  132. // Resize the toolbar.
  133. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  134. ResizeToolBar();
  135. }
  136. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  137. // @mfunc: (FUNCTIONAL)
  138. // <c COOExToolBar>
  139. // To get the text on or off.
  140. // @RDesc True if the text is on, False otherwise.
  141. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  142. bool COOExToolBar::GetTextMode( void ) const
  143. {
  144. return m_bShowIconText;
  145. }
  146. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  147. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  148. // Loading information.
  149. // ------------------------------------------------------------------------
  150. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  151. // @mfunc: (FUNCTIONAL)
  152. // <c COOExToolBar>
  153. // To load the toolbar information.
  154. // @RDesc True if the tool bar is loaded.
  155. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  156. BOOL COOExToolBar::LoadToolBar(
  157. UINT _ResourceId ) // @Parm The toolbar resource id.
  158. {
  159. // Convert the resource id into a resource name and load the toolbar
  160. // using the base class method.
  161. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  162. CString lpszResourceName;
  163. lpszResourceName.Format( "#%d", _ResourceId );
  164. BOOL bReturn = CToolBar::LoadToolBar( lpszResourceName );
  165. // Check if we loaded the toolbar.
  166. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  167. if ( bReturn == FALSE )
  168. {
  169. return bReturn;
  170. }
  171. // Retrieve the height of the toolbar before putting text.
  172. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  173. CToolBarCtrl& bar = GetToolBarCtrl();
  174. int nIndex = 0;
  175. CRect NoTextRc( 0, 0, 0, 0 );
  176. bar.GetItemRect( 0, NoTextRc );
  177. // Set the text for each button.
  178. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  179. TBBUTTON tb;
  180. for ( nIndex = bar.GetButtonCount(); nIndex >= 0; nIndex-- )
  181. {
  182. ZeroMemory(&tb, sizeof(TBBUTTON));
  183. bar.GetButton(nIndex, &tb);
  184. // Do we have a separator?
  185. if ( ( tb.fsStyle & TBSTYLE_SEP ) == TBSTYLE_SEP ) {
  186. continue;
  187. }
  188. // Have we got a valid command id?
  189. if ( tb.idCommand == 0 ) {
  190. continue;
  191. }
  192. // Get the resource string if there is one.
  193. CString strText((LPCSTR)tb.idCommand);
  194. LPCTSTR lpszButtonText = NULL;
  195. CString strButtonText(_T(""));
  196. _TCHAR seps[] = _T("\n");
  197. if ( !strText.IsEmpty() ) {
  198. lpszButtonText = _tcstok( ( LPTSTR ) ( LPCTSTR ) strText, seps );
  199. while( lpszButtonText )
  200. {
  201. strButtonText = lpszButtonText;
  202. lpszButtonText = _tcstok( NULL, seps );
  203. }
  204. }
  205. if ( !strButtonText.IsEmpty() ) {
  206. SetButtonText( nIndex, strButtonText );
  207. }
  208. }
  209. // Calculate the effect of the text on the toolbar.
  210. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  211. CRect rc( 0, 0, 0, 0 );
  212. CSize sizeMax( 0, 0 );
  213. for ( nIndex = bar.GetButtonCount(); nIndex >= 0; nIndex-- )
  214. {
  215. bar.GetItemRect( nIndex, rc );
  216. rc.NormalizeRect();
  217. sizeMax.cx = __max( rc.Size().cx, sizeMax.cx );
  218. sizeMax.cy = __max( rc.Size().cy, sizeMax.cy );
  219. }
  220. // Resize the toolbar.
  221. // The text width is the maximum width of the bitmap. All toolbar size
  222. // must at least be this width.
  223. // The text height is the height added to the button. Even in large mode
  224. // we must add this text height.
  225. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  226. m_nTextWidth = sizeMax.cx;
  227. m_nTextHeight = sizeMax.cy - ( NoTextRc.Size().cy );
  228. ResizeToolBar();
  229. // Create the needed image list.
  230. // Build the image list.
  231. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  232. CClientDC dc( this );
  233. int nNbBits = dc.GetDeviceCaps( BITSPIXEL );
  234. for ( int i=0; i<NB_POSSIBLE_MODE; i++ )
  235. {
  236. UINT nColorMode = ILC_COLOR;
  237. if ( nNbBits > 8 )
  238. {
  239. nColorMode = ILC_COLORDDB;
  240. }
  241. CSize Size = m_LargeIconSize;
  242. if ( i < 3 )
  243. {
  244. Size = m_SmallIconSize;
  245. }
  246. m_ImageList[ i ].Create( Size.cx, Size.cy, nColorMode | ILC_MASK, bar.GetButtonCount(), 10 );
  247. }
  248. return bReturn;
  249. }
  250. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  251. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  252. // Image list initialization method.
  253. // ------------------------------------------------------------------------
  254. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  255. // @mfunc: (FUNCTIONAL)
  256. // <c COOExToolBar>
  257. // To set the image list.
  258. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  259. void COOExToolBar::SetImageList(
  260. ImageMode_ _Mode, // @Parm The image mode.
  261. CImageList& _rList ) // @Parm The hoover image list.
  262. {
  263. // Store the list handle for future use.
  264. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  265. m_ImageList[ _Mode ].Attach( _rList.Detach() );
  266. }
  267. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  268. // @mfunc: (FUNCTIONAL)
  269. // <c COOExToolBar>
  270. // To set the current mode appropriate image list.
  271. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  272. void COOExToolBar::AssignImageList( void )
  273. {
  274. // Prepare the list associated with the current mode.
  275. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  276. CImageList* pTempHotList;
  277. CImageList* pTempNormalList;
  278. CImageList* pTempDisableList;
  279. if ( m_nShowIconMode == 0 )
  280. {
  281. pTempHotList = &m_ImageList[ SmallHot ];
  282. pTempNormalList = &m_ImageList[ SmallStandard ];
  283. pTempDisableList = &m_ImageList[ SmallDisable ];
  284. }
  285. if ( m_nShowIconMode == 1 )
  286. {
  287. pTempHotList = &m_ImageList[ LargeHot ];
  288. pTempNormalList = &m_ImageList[ LargeStandard ];
  289. pTempDisableList = &m_ImageList[ LargeDisable ];
  290. }
  291. // Set the list in the control.
  292. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  293. SetHotImageList( pTempHotList );
  294. SetStandardImageList( pTempNormalList );
  295. SetDisableImageList( pTempDisableList );
  296. }
  297. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  298. // @mfunc: (FUNCTIONAL)
  299. // <c COOExToolBar>
  300. // To set the image list in the control.
  301. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  302. void COOExToolBar::InitImageList( void )
  303. {
  304. // Set the image list according to the current mode.
  305. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  306. AssignImageList();
  307. }
  308. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  309. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  310. // Private Image list method.
  311. // ------------------------------------------------------------------------
  312. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  313. // @mfunc: (FUNCTIONAL)
  314. // <c COOExToolBar>
  315. // Method to calculate the current size of the button.
  316. // @rdesc The button size.
  317. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  318. CSize COOExToolBar::CalcButtonSize( void )
  319. {
  320. // Calcul the width of the drop button.
  321. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  322. CSize theButtonSize;
  323. if ( m_nShowIconMode == 0 )
  324. {
  325. theButtonSize = CSize( m_SmallIconSize.cx + 8, m_SmallIconSize.cy + 7 );
  326. }
  327. else if ( m_nShowIconMode == 1 )
  328. {
  329. theButtonSize = CSize( m_LargeIconSize.cx + 8, m_LargeIconSize.cy + 7 );
  330. }
  331. // Check the text mode and set or hide the text.
  332. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  333. if ( m_bShowIconText )
  334. {
  335. // The text width is the maximum width of the bitmap. All toolbar size
  336. // must at least be this width.
  337. if ( theButtonSize.cx < m_nTextWidth )
  338. {
  339. theButtonSize.cx = m_nTextWidth;
  340. }
  341. // The text height is the height added to the button. Even in large mode
  342. // we must add this text height.
  343. theButtonSize.cy += m_nTextHeight;
  344. }
  345. return theButtonSize;
  346. }
  347. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  348. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  349. // Image list information method.
  350. // ------------------------------------------------------------------------
  351. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  352. // @mfunc: (FUNCTIONAL)
  353. // <c COOExToolBar>
  354. // To set the hoover image list.
  355. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  356. void COOExToolBar::SetHotImageList(
  357. CImageList* pList ) // @Parm The hoover image list.
  358. {
  359. // Retrieve the tool bar control and set the list reference.
  360. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  361. CWnd* pWnd = &GetToolBarCtrl();
  362. pWnd->SendMessage( TB_SETHOTIMAGELIST, 0, ( LPARAM ) ( HIMAGELIST ) *pList );
  363. }
  364. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  365. // @mfunc: (FUNCTIONAL)
  366. // <c COOExToolBar>
  367. // To set the normal image list.
  368. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  369. void COOExToolBar::SetStandardImageList(
  370. CImageList* pList ) // @Parm The normal image list.
  371. {
  372. // Retrieve the tool bar control and set the list reference.
  373. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  374. CWnd* pWnd = &GetToolBarCtrl();
  375. pWnd->SendMessage( TB_SETIMAGELIST, 0, ( LPARAM ) ( HIMAGELIST ) *pList );
  376. }
  377. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  378. // @mfunc: (FUNCTIONAL)
  379. // <c COOExToolBar>
  380. // To set the disable image list.
  381. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  382. void COOExToolBar::SetDisableImageList(
  383. CImageList* pList ) // @Parm The normal image list.
  384. {
  385. // Retrieve the tool bar control and set the list reference.
  386. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  387. CWnd* pWnd = &GetToolBarCtrl();
  388. pWnd->SendMessage( TB_SETDISABLEDIMAGELIST, 0, ( LPARAM ) ( HIMAGELIST ) *pList );
  389. }
  390. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  391. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  392. // Usefull protected method.
  393. // ------------------------------------------------------------------------
  394. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  395. // @mfunc: (FUNCTIONAL)
  396. // <c COOExToolBar>
  397. // To display the dropdown button for the given button.
  398. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  399. void COOExToolBar::SetButtonDropDown(
  400. int nID ) // @Parm The id to show the drop down.
  401. {
  402. // Change button style to dropdown.
  403. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  404. DWORD dwStyle = GetButtonStyle( CommandToIndex( nID ) );
  405. dwStyle |= TBSTYLE_DROPDOWN;
  406. SetButtonStyle( CommandToIndex( nID ), dwStyle );
  407. // Calculate the drop button size.
  408. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  409. CToolBarCtrl& bar = GetToolBarCtrl();
  410. CSize theStdButtonSize = CalcButtonSize();
  411. CRect rc( 0, 0, 0, 0 );
  412. bar.GetItemRect( CommandToIndex( nID ), rc );
  413. m_nDropButtonSize = rc.Width() - theStdButtonSize.cx;
  414. }
  415. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  416. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  417. // Usefull protected method.
  418. // ------------------------------------------------------------------------
  419. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  420. // @mfunc: (FUNCTIONAL)
  421. // <c COOExToolBar>
  422. // To resieze the toolbar once something change.
  423. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  424. void COOExToolBar::ResizeToolBar( void )
  425. {
  426. // Set the size of the toolbar corresponding to the current mode.
  427. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  428. CSize theSize = ( m_nShowIconMode == 0 ) ? m_SmallIconSize : m_LargeIconSize;
  429. CSize theButtonSize = CalcButtonSize();
  430. // Resize the toolbar and the dock frame.
  431. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  432. SetSizes( theButtonSize, theSize );
  433. MoveWindow( 200, 200, 450, theButtonSize.cy );
  434. SendMessage( WM_SIZE, SIZE_RESTORED );
  435. CFrameWnd* pFrameWnd = GetDockingFrame();
  436. pFrameWnd->DelayRecalcLayout();
  437. }
  438. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  439. // @mfunc: (FUNCTIONAL)
  440. // <c COOExToolBar>
  441. // To draw the gripper on the toolbar.
  442. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  443. void COOExToolBar::DrawGripper(
  444. CDC& dc ) const // @Parm The device context where to draw the gripper.
  445. {
  446. // No gripper if floating
  447. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  448. if( m_dwStyle & CBRS_FLOATING )
  449. {
  450. return;
  451. }
  452. // Retrieve the window coord and calculate the gripper position.
  453. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  454. CRect gripper;
  455. GetWindowRect( gripper );
  456. ScreenToClient( gripper );
  457. gripper.OffsetRect( -gripper.left, -gripper.top );
  458. // Draw it accordingly to the orientation of the toolbar.
  459. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  460. COLORREF clrBtnHilight = ::GetSysColor(COLOR_BTNHILIGHT);
  461. COLORREF clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
  462. if( m_dwStyle & CBRS_ORIENT_HORZ ) {
  463. // gripper at left
  464. gripper.DeflateRect( 3, 3 );
  465. gripper.right = gripper.left+3;
  466. dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
  467. gripper.OffsetRect(5, 0);
  468. dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
  469. }
  470. else {
  471. // gripper at top
  472. gripper.DeflateRect( 3, 3 );
  473. gripper.bottom = gripper.top+3;
  474. dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
  475. gripper.OffsetRect(0, 5);
  476. dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
  477. }
  478. }
  479. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  480. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  481. // MFC Overloaded method.
  482. // ------------------------------------------------------------------------
  483. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  484. // @mfunc: (FUNCTIONAL)
  485. // <c COOExToolBar>
  486. // Only overloaded to use our cmdui instead of their. This is
  487. // the same code found in CToolBar::OnUpdateCmdUI, but we
  488. // replace the CCmdUI by CCoolCmdUI.
  489. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  490. void COOExToolBar::OnUpdateCmdUI(
  491. CFrameWnd* pTarget, // @Parm ??
  492. BOOL bDisableIfNoHndler ) // @Parm ??
  493. {
  494. CCoolCmdUI state; // this is the only line that's different--PD
  495. state.m_pOther = this;
  496. state.m_nIndexMax = ( UINT ) DefWindowProc( TB_BUTTONCOUNT, 0, 0 );
  497. for ( state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax; state.m_nIndex++ )
  498. {
  499. // get button state
  500. TBBUTTON button;
  501. VERIFY( DefWindowProc( TB_GETBUTTON, state.m_nIndex, ( LPARAM ) &button ) );
  502. // TBSTATE_ENABLED == TBBS_DISABLED so invert it
  503. button.fsState ^= TBSTATE_ENABLED;
  504. state.m_nID = button.idCommand;
  505. // ignore separators
  506. if ( !( button.fsStyle & TBSTYLE_SEP ) )
  507. {
  508. // allow the toolbar itself to have update handlers
  509. if ( CWnd::OnCmdMsg( state.m_nID, CN_UPDATE_COMMAND_UI, &state, NULL ) )
  510. continue;
  511. // allow the owner to process the update
  512. state.DoUpdate( pTarget, bDisableIfNoHndler );
  513. }
  514. }
  515. // update the dialog controls added to the toolbar
  516. UpdateDialogControls( pTarget, bDisableIfNoHndler );
  517. }
  518. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  519. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  520. // MFC Message method.
  521. // ------------------------------------------------------------------------
  522. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  523. // @mfunc: (FUNCTIONAL)
  524. // <c COOExToolBar>
  525. // This will draw the gripper on the toolbar then repaints
  526. // client areas.
  527. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  528. void COOExToolBar::OnNcPaint( void )
  529. {
  530. CControlBar::EraseNonClient();
  531. CWindowDC dc( this );
  532. DrawGripper( dc );
  533. CRect pRect;
  534. GetClientRect( &pRect );
  535. InvalidateRect( &pRect, TRUE );
  536. CWnd* pWnd = &GetToolBarCtrl();
  537. pWnd->GetClientRect( &pRect );
  538. pWnd->InvalidateRect( &pRect, TRUE );
  539. }
  540. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  541. // @mfunc: (FUNCTIONAL)
  542. // <c COOExToolBar>
  543. // Trap to set the flat bar style.
  544. // @RDesc Nonzero if the toolbar is correctly created.
  545. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  546. int COOExToolBar::OnCreate(
  547. LPCREATESTRUCT lpCreateStruct ) // @Parm Toolbar creation information.
  548. {
  549. // Call the base class method.
  550. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  551. if ( CToolBar::OnCreate( lpCreateStruct ) == -1 )
  552. {
  553. return -1;
  554. }
  555. // Set the style to flat.
  556. // There is a but when docking vertical. The size of the separator
  557. // is not calculate correctly by MFC. Only in style flat.
  558. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  559. ModifyStyle( 0, TBSTYLE_FLAT );
  560. SendMessage( TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS );
  561. // The window is now created.
  562. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  563. return 0;
  564. }
  565. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  566. // @mfunc: (FUNCTIONAL)
  567. // <c COOExToolBar>
  568. // Trap to size correctly the toolbar with the carret.
  569. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  570. void COOExToolBar::OnNcCalcSize(
  571. BOOL bCalcValidRects, // @Parm MFC Specific message.
  572. NCCALCSIZE_PARAMS FAR* lpncsp ) // @Parm MFC Specific message.
  573. {
  574. // No gripper if floating
  575. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  576. if( !( m_dwStyle & CBRS_FLOATING ) )
  577. {
  578. // Adjust non-client area for gripper at left or top.
  579. if( m_dwStyle & CBRS_ORIENT_HORZ ) {
  580. lpncsp->rgrc[0].left += 5;
  581. lpncsp->rgrc[0].right += 5;
  582. }
  583. else {
  584. lpncsp->rgrc[0].top += 5;
  585. lpncsp->rgrc[0].bottom += 5;
  586. }
  587. }
  588. CToolBar::OnNcCalcSize( bCalcValidRects, lpncsp );
  589. }
  590. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  591. // @mfunc: (FUNCTIONAL)
  592. // <c COOExToolBar>
  593. // Call when ever the system color are changing. Trap to rebuild
  594. // the toolbar image list with the good background color.
  595. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  596. void COOExToolBar::OnSysColorChange( void )
  597. {
  598. // Call the base class method.
  599. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  600. CToolBar::OnSysColorChange();
  601. }
  602. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  603. // @mfunc: (FUNCTIONAL)
  604. // <c COOExToolBar>
  605. // Call when the toolbar is moved. There is a bug when the tool
  606. // bar is in flat mode, and in vertical position. The separator
  607. // are not count in the height, so the last button is not completly
  608. // displayed.
  609. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  610. void COOExToolBar::OnWindowPosChanging( LPWINDOWPOS _pWindowPos )
  611. {
  612. // Default processing
  613. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  614. if( m_bOldFloating != ( IsFloating()?true:false ) )
  615. {
  616. m_bOldFloating = !m_bOldFloating;
  617. _pWindowPos->flags |= SWP_DRAWFRAME;
  618. }
  619. CToolBar::OnWindowPosChanging( _pWindowPos );
  620. }
  621. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  622. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  623. // MFC Overloaded method.
  624. // The following stuff is to make the command update UI mechanism
  625. // work properly for flat tool bars. The main idea is to convert
  626. // a "checked" button state into a "pressed" button state. Changed
  627. // lines marked with "PD"
  628. // ------------------------------------------------------------------------
  629. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  630. // @mfunc: (FUNCTIONAL)
  631. // <c CCoolCmdUI>
  632. // Came from Paul Dilascia Article.
  633. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  634. void CCoolCmdUI::Enable( BOOL bOn )
  635. {
  636. m_bEnableChanged = TRUE;
  637. CToolBar* pToolBar = ( CToolBar* ) m_pOther;
  638. ASSERT( pToolBar != NULL );
  639. ASSERT_KINDOF( CToolBar, pToolBar );
  640. ASSERT( m_nIndex < m_nIndexMax );
  641. UINT nNewStyle = pToolBar->GetButtonStyle( m_nIndex ) & ~TBBS_DISABLED;
  642. if ( !bOn )
  643. {
  644. nNewStyle |= TBBS_DISABLED;
  645. // WINBUG: If a button is currently pressed and then is disabled
  646. // COMCTL32.DLL does not unpress the button, even after the mouse
  647. // button goes up! We work around this bug by forcing TBBS_PRESSED
  648. // off when a button is disabled.
  649. nNewStyle &= ~TBBS_PRESSED;
  650. }
  651. ASSERT( !( nNewStyle & TBBS_SEPARATOR ) );
  652. pToolBar->SetButtonStyle( m_nIndex, nNewStyle );
  653. }
  654. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  655. // @mfunc: (FUNCTIONAL)
  656. // <c CCoolCmdUI>
  657. // Came from Paul Dilascia Article.
  658. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  659. void CCoolCmdUI::SetCheck( int nCheck )
  660. {
  661. ASSERT( nCheck >= 0 && nCheck <= 2 ); // 0=>off, 1=>on, 2=>indeterminate
  662. CToolBar* pToolBar = ( CToolBar* ) m_pOther;
  663. ASSERT( pToolBar != NULL );
  664. ASSERT_KINDOF( CToolBar, pToolBar );
  665. ASSERT( m_nIndex < m_nIndexMax );
  666. UINT nOldStyle = pToolBar->GetButtonStyle( m_nIndex ); // PD
  667. UINT nNewStyle = nOldStyle &
  668. ~( TBBS_PRESSED | TBBS_INDETERMINATE ); // PD
  669. if ( nCheck == 1 )
  670. nNewStyle |= TBBS_PRESSED; // PD
  671. else if ( nCheck == 2 )
  672. nNewStyle |= TBBS_INDETERMINATE;
  673. // Following is to fix display bug for TBBS_CHECKED:
  674. // If new state is unchecked, repaint--but only if style actually changing.
  675. // (Otherwise will end up with flicker)
  676. //
  677. if ( nNewStyle != nOldStyle ) {
  678. ASSERT( !( nNewStyle & TBBS_SEPARATOR ) );
  679. pToolBar->SetButtonStyle( m_nIndex, nNewStyle );
  680. pToolBar->Invalidate();
  681. }
  682. }
  683. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  684. CSize COOExToolBar::CalcDynamicLayout(int nLength, DWORD dwMode)
  685. {
  686. if ((nLength == -1) &&
  687. !(dwMode & LM_MRUWIDTH) && !(dwMode & LM_COMMIT) &&
  688. ((dwMode & LM_HORZDOCK) || (dwMode & LM_VERTDOCK)))
  689. {
  690. return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZDOCK);
  691. }
  692. return CalcLayout(dwMode, nLength);
  693. }
  694. //////////////////
  695. // 1998 Microsoft Systems Journal - Paul DiLascia
  696. // This is the all-important function that gets the true size of a button,
  697. // instead of using m_sizeButton. And it's virtual, so you can override if
  698. // my algorithm doesn't work, as will surely be the case in some circumstances.
  699. //
  700. CSize COOExToolBar::GetButtonSize(TBBUTTON* pData, int iButton)
  701. {
  702. // Get the actual size of the button, not what's in m_sizeButton.
  703. // Make sure to do SendMessage instead of calling MFC's GetItemRect,
  704. // which has all sorts of bad side-effects! (Go ahead, take a look at it.)
  705. //
  706. CRect rc;
  707. SendMessage(TB_GETITEMRECT, iButton, (LPARAM)&rc);
  708. CSize sz = rc.Size();
  709. ////////////////
  710. // Now must do special case for various versions of comctl32.dll,
  711. //
  712. DWORD dwStyle = pData[iButton].fsStyle;
  713. if ((pData[iButton].fsState & TBSTATE_WRAP)) {
  714. if (dwStyle & TBSTYLE_SEP) {
  715. // this is the last separator in the row (eg vertically docked)
  716. // fudge the height, and ignore the width. TB_GETITEMRECT will return
  717. // size = (8 x 22) even for a separator in vertical toolbar
  718. //
  719. sz.cy = sz.cx;
  720. sz.cx = 0; // separator takes no width if it's the last one
  721. } else if (dwStyle & TBSTYLE_DROPDOWN ) {//&&
  722. //!m_bShowDropdownArrowWhenVertical) {
  723. // ignore width of dropdown
  724. sz.cx = 0;
  725. }
  726. }
  727. return sz;
  728. }
  729. //////////////////
  730. // 1998 Microsoft Systems Journal - Paul DiLascia
  731. // I renamed this from _GetButton.
  732. //
  733. void COOExToolBar::GetButton(int nIndex, TBBUTTON* pButton) const
  734. {
  735. CToolBar* pBar = (CToolBar*)this;
  736. VERIFY(pBar->SendMessage(TB_GETBUTTON, nIndex, (LPARAM)pButton));
  737. // TBSTATE_ENABLED == TBBS_DISABLED so invert it
  738. pButton->fsState ^= TBSTATE_ENABLED;
  739. }
  740. //////////////////
  741. // 1998 Microsoft Systems Journal - Paul DiLascia
  742. // I renamed this from _SetButton.
  743. //
  744. void COOExToolBar::SetButton(int nIndex, TBBUTTON* pButton)
  745. {
  746. // get original button state
  747. TBBUTTON button;
  748. VERIFY(SendMessage(TB_GETBUTTON, nIndex, (LPARAM)&button));
  749. // prepare for old/new button comparsion
  750. button.bReserved[0] = 0;
  751. button.bReserved[1] = 0;
  752. // TBSTATE_ENABLED == TBBS_DISABLED so invert it
  753. pButton->fsState ^= TBSTATE_ENABLED;
  754. pButton->bReserved[0] = 0;
  755. pButton->bReserved[1] = 0;
  756. // nothing to do if they are the same
  757. if (memcmp(pButton, &button, sizeof(TBBUTTON)) != 0)
  758. {
  759. // don't redraw everything while setting the button
  760. DWORD dwStyle = GetStyle();
  761. ModifyStyle(WS_VISIBLE, 0);
  762. VERIFY(SendMessage(TB_DELETEBUTTON, nIndex, 0));
  763. VERIFY(SendMessage(TB_INSERTBUTTON, nIndex, (LPARAM)pButton));
  764. ModifyStyle(0, dwStyle & WS_VISIBLE);
  765. // invalidate appropriate parts
  766. if (((pButton->fsStyle ^ button.fsStyle) & TBSTYLE_SEP) ||
  767. ((pButton->fsStyle & TBSTYLE_SEP) && pButton->iBitmap != button.iBitmap))
  768. {
  769. // changing a separator
  770. Invalidate(FALSE);
  771. }
  772. else
  773. {
  774. // invalidate just the button
  775. CRect rect;
  776. if (SendMessage(TB_GETITEMRECT, nIndex, (LPARAM)&rect))
  777. InvalidateRect(rect, FALSE); // don't erase background
  778. }
  779. }
  780. }
  781. //////////////////
  782. // 1998 Microsoft Systems Journal - Paul DiLascia
  783. // Make the parent frame my owner. This is important for status bar
  784. // prompts to work.
  785. //
  786. ////////////////////////////////////////////////////////////////
  787. // 1998 Microsoft Systems Journal - Paul DiLascia
  788. // Stuff below is copied from MFC, my mods marked **PD**
  789. #ifdef _MAC
  790. #define CX_OVERLAP 1
  791. #else
  792. #define CX_OVERLAP 0
  793. #endif
  794. CSize COOExToolBar::CalcSize(TBBUTTON* pData, int nCount)
  795. {
  796. ASSERT(pData != NULL && nCount > 0);
  797. CPoint cur(0,0);
  798. CSize sizeResult(0,0);
  799. int cyTallestOnRow = 0;
  800. for (int i = 0; i < nCount; i++)
  801. {
  802. if (pData[i].fsState & TBSTATE_HIDDEN)
  803. continue;
  804. // **PD** Load actual size of button into local var
  805. // that obscures CToolBar::m_sizeButton.
  806. CSize m_sizeButton = GetButtonSize(pData, i);
  807. // **PD** I also changed the logic below to be more correct.
  808. cyTallestOnRow = max(cyTallestOnRow, m_sizeButton.cy);
  809. sizeResult.cx = max(cur.x + m_sizeButton.cx, sizeResult.cx);
  810. sizeResult.cy = max(cur.y + m_sizeButton.cy, sizeResult.cy);
  811. cur.x += m_sizeButton.cx - CX_OVERLAP;
  812. if (pData[i].fsState & TBSTATE_WRAP)
  813. {
  814. cur.x = 0;
  815. cur.y += cyTallestOnRow;
  816. cyTallestOnRow = 0;
  817. if (pData[i].fsStyle & TBSTYLE_SEP)
  818. cur.y += m_sizeButton.cy;
  819. }
  820. }
  821. return sizeResult;
  822. }
  823. int COOExToolBar::WrapToolBar(TBBUTTON* pData, int nCount, int nWidth)
  824. {
  825. ASSERT(pData != NULL && nCount > 0);
  826. int nResult = 0;
  827. int x = 0;
  828. for (int i = 0; i < nCount; i++)
  829. {
  830. pData[i].fsState &= ~TBSTATE_WRAP;
  831. if (pData[i].fsState & TBSTATE_HIDDEN)
  832. continue;
  833. int dx, dxNext;
  834. // **PD** Load actual size of button into local var
  835. // that obscures CToolBar::m_sizeButton.
  836. CSize m_sizeButton = GetButtonSize(pData, i);
  837. dx = m_sizeButton.cx;
  838. dxNext = dx - CX_OVERLAP;
  839. if (x + dx > nWidth)
  840. {
  841. BOOL bFound = FALSE;
  842. for (int j = i; j >= 0 && !(pData[j].fsState & TBSTATE_WRAP); j--)
  843. {
  844. // Find last separator that isn't hidden
  845. // a separator that has a command ID is not
  846. // a separator, but a custom control.
  847. if ((pData[j].fsStyle & TBSTYLE_SEP) &&
  848. (pData[j].idCommand == 0) &&
  849. !(pData[j].fsState & TBSTATE_HIDDEN))
  850. {
  851. bFound = TRUE; i = j; x = 0;
  852. pData[j].fsState |= TBSTATE_WRAP;
  853. nResult++;
  854. break;
  855. }
  856. }
  857. if (!bFound)
  858. {
  859. for (int j = i - 1; j >= 0 && !(pData[j].fsState & TBSTATE_WRAP); j--)
  860. {
  861. // Never wrap anything that is hidden,
  862. // or any custom controls
  863. if ((pData[j].fsState & TBSTATE_HIDDEN) ||
  864. ((pData[j].fsStyle & TBSTYLE_SEP) &&
  865. (pData[j].idCommand != 0)))
  866. continue;
  867. bFound = TRUE; i = j; x = 0;
  868. pData[j].fsState |= TBSTATE_WRAP;
  869. nResult++;
  870. break;
  871. }
  872. if (!bFound)
  873. x += dxNext;
  874. }
  875. }
  876. else
  877. x += dxNext;
  878. }
  879. return nResult + 1;
  880. }
  881. //////////////////////////////////////////////////////////////////////////
  882. // 1998 Microsoft Systems Journal - Paul DiLascia
  883. // Functions below are NOT modified. They're only here because they
  884. // call the modified functions above, which are NOT virtual.
  885. void COOExToolBar::SizeToolBar(TBBUTTON* pData, int nCount, int nLength, BOOL bVert)
  886. {
  887. ASSERT(pData != NULL && nCount > 0);
  888. if (!bVert)
  889. {
  890. int nMin, nMax, nTarget, nCurrent, nMid;
  891. // Wrap ToolBar as specified
  892. nMax = nLength;
  893. nTarget = WrapToolBar(pData, nCount, nMax);
  894. // Wrap ToolBar vertically
  895. nMin = 0;
  896. nCurrent = WrapToolBar(pData, nCount, nMin);
  897. if (nCurrent != nTarget)
  898. {
  899. while (nMin < nMax)
  900. {
  901. nMid = (nMin + nMax) / 2;
  902. nCurrent = WrapToolBar(pData, nCount, nMid);
  903. if (nCurrent == nTarget)
  904. nMax = nMid;
  905. else
  906. {
  907. if (nMin == nMid)
  908. {
  909. WrapToolBar(pData, nCount, nMax);
  910. break;
  911. }
  912. nMin = nMid;
  913. }
  914. }
  915. }
  916. CSize size = CalcSize(pData, nCount);
  917. WrapToolBar(pData, nCount, size.cx);
  918. }
  919. else
  920. {
  921. CSize sizeMax, sizeMin, sizeMid;
  922. // Wrap ToolBar vertically
  923. WrapToolBar(pData, nCount, 0);
  924. sizeMin = CalcSize(pData, nCount);
  925. // Wrap ToolBar horizontally
  926. WrapToolBar(pData, nCount, 32767);
  927. sizeMax = CalcSize(pData, nCount);
  928. while (sizeMin.cx < sizeMax.cx)
  929. {
  930. sizeMid.cx = (sizeMin.cx + sizeMax.cx) / 2;
  931. WrapToolBar(pData, nCount, sizeMid.cx);
  932. sizeMid = CalcSize(pData, nCount);
  933. if (nLength < sizeMid.cy)
  934. {
  935. if (sizeMin == sizeMid)
  936. {
  937. WrapToolBar(pData, nCount, sizeMax.cx);
  938. return;
  939. }
  940. sizeMin = sizeMid;
  941. }
  942. else if (nLength > sizeMid.cy)
  943. sizeMax = sizeMid;
  944. else
  945. return;
  946. }
  947. }
  948. }
  949. struct _AFX_CONTROLPOS
  950. {
  951. int nIndex, nID;
  952. CRect rectOldPos;
  953. };
  954. CSize COOExToolBar::CalcLayout(DWORD dwMode, int nLength)
  955. {
  956. ASSERT_VALID(this);
  957. ASSERT(::IsWindow(m_hWnd));
  958. if (dwMode & LM_HORZDOCK)
  959. ASSERT(dwMode & LM_HORZ);
  960. int nCount;
  961. TBBUTTON* pData;
  962. CSize sizeResult(0,0);
  963. // Load Buttons
  964. {
  965. nCount = (int)SendMessage(TB_BUTTONCOUNT, 0, 0);
  966. if (nCount != 0)
  967. {
  968. int i;
  969. pData = new TBBUTTON[nCount];
  970. for (i = 0; i < nCount; i++)
  971. GetButton(i, &pData[i]); // **PD** renamed from _GetButton
  972. }
  973. }
  974. if (nCount > 0)
  975. {
  976. if (!(m_dwStyle & CBRS_SIZE_FIXED))
  977. {
  978. BOOL bDynamic = m_dwStyle & CBRS_SIZE_DYNAMIC;
  979. if (bDynamic && (dwMode & LM_MRUWIDTH))
  980. SizeToolBar(pData, nCount, m_nMRUWidth);
  981. else if (bDynamic && (dwMode & LM_HORZDOCK))
  982. SizeToolBar(pData, nCount, 32767);
  983. else if (bDynamic && (dwMode & LM_VERTDOCK))
  984. SizeToolBar(pData, nCount, 0);
  985. else if (bDynamic && (nLength != -1))
  986. {
  987. CRect rect; rect.SetRectEmpty();
  988. CalcInsideRect(rect, (dwMode & LM_HORZ));
  989. BOOL bVert = (dwMode & LM_LENGTHY);
  990. int nLen = nLength + (bVert ? rect.Height() : rect.Width());
  991. SizeToolBar(pData, nCount, nLen, bVert);
  992. }
  993. else if (bDynamic && (m_dwStyle & CBRS_FLOATING))
  994. SizeToolBar(pData, nCount, m_nMRUWidth);
  995. else
  996. SizeToolBar(pData, nCount, (dwMode & LM_HORZ) ? 32767 : 0);
  997. }
  998. sizeResult = CalcSize(pData, nCount);
  999. if (dwMode & LM_COMMIT)
  1000. {
  1001. _AFX_CONTROLPOS* pControl = NULL;
  1002. int nControlCount = 0;
  1003. BOOL bIsDelayed = m_bDelayedButtonLayout;
  1004. m_bDelayedButtonLayout = FALSE;
  1005. for(int i = 0; i < nCount; i++)
  1006. if ((pData[i].fsStyle & TBSTYLE_SEP) && (pData[i].idCommand != 0))
  1007. nControlCount++;
  1008. if (nControlCount > 0)
  1009. {
  1010. pControl = new _AFX_CONTROLPOS[nControlCount];
  1011. nControlCount = 0;
  1012. for(int i = 0; i < nCount; i++)
  1013. {
  1014. if ((pData[i].fsStyle & TBSTYLE_SEP) && (pData[i].idCommand != 0))
  1015. {
  1016. pControl[nControlCount].nIndex = i;
  1017. pControl[nControlCount].nID = pData[i].idCommand;
  1018. CRect rect;
  1019. GetItemRect(i, &rect);
  1020. ClientToScreen(&rect);
  1021. pControl[nControlCount].rectOldPos = rect;
  1022. nControlCount++;
  1023. }
  1024. }
  1025. }
  1026. if ((m_dwStyle & CBRS_FLOATING) && (m_dwStyle & CBRS_SIZE_DYNAMIC))
  1027. m_nMRUWidth = sizeResult.cx;
  1028. for (i = 0; i < nCount; i++)
  1029. SetButton(i, &pData[i]); // **PD** renamed from _SetButton
  1030. if (nControlCount > 0)
  1031. {
  1032. for (int i = 0; i < nControlCount; i++)
  1033. {
  1034. CWnd* pWnd = GetDlgItem(pControl[i].nID);
  1035. if (pWnd != NULL)
  1036. {
  1037. CRect rect;
  1038. pWnd->GetWindowRect(&rect);
  1039. CPoint pt = rect.TopLeft() - pControl[i].rectOldPos.TopLeft();
  1040. GetItemRect(pControl[i].nIndex, &rect);
  1041. pt = rect.TopLeft() + pt;
  1042. pWnd->SetWindowPos(NULL, pt.x, pt.y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
  1043. }
  1044. }
  1045. delete[] pControl;
  1046. }
  1047. m_bDelayedButtonLayout = bIsDelayed;
  1048. }
  1049. delete[] pData;
  1050. }
  1051. //BLOCK: Adjust Margins
  1052. {
  1053. CRect rect; rect.SetRectEmpty();
  1054. CalcInsideRect(rect, (dwMode & LM_HORZ));
  1055. sizeResult.cy -= rect.Height();
  1056. sizeResult.cx -= rect.Width();
  1057. CSize size = CControlBar::CalcFixedLayout((dwMode & LM_STRETCH), (dwMode & LM_HORZ));
  1058. sizeResult.cx = max(sizeResult.cx, size.cx);
  1059. sizeResult.cy = max(sizeResult.cy, size.cy);
  1060. }
  1061. return sizeResult;
  1062. }
  1063. CSize COOExToolBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
  1064. {
  1065. DWORD dwMode = bStretch ? LM_STRETCH : 0;
  1066. dwMode |= bHorz ? LM_HORZ : 0;
  1067. return CalcLayout(dwMode);
  1068. }
  1069. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1070. // Macro and other definition.
  1071. // ------------------------------------------------------------------------
  1072. IMPLEMENT_DYNAMIC( COOBmpToolBar, COOExToolBar )
  1073. BEGIN_MESSAGE_MAP( COOBmpToolBar, COOExToolBar )
  1074. //{{AFX_MSG_MAP( COOBmpToolBar )
  1075. //}}AFX_MSG_MAP
  1076. END_MESSAGE_MAP()
  1077. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1078. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1079. // Initialization and destruction method.
  1080. // ------------------------------------------------------------------------
  1081. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1082. // @mfunc: (IMPLEMENTATION)
  1083. // <c COOBmpToolBar>
  1084. // This is the main constructor.
  1085. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1086. COOBmpToolBar::COOBmpToolBar( void )
  1087. {
  1088. }
  1089. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1090. // @mfunc: (IMPLEMENTATION)
  1091. // <c COOBmpToolBar>
  1092. // This is the main destructor.
  1093. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1094. COOBmpToolBar::~COOBmpToolBar( void )
  1095. {
  1096. }
  1097. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1098. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1099. // Image list initialization method.
  1100. // ------------------------------------------------------------------------
  1101. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1102. // @mfunc: (FUNCTIONAL)
  1103. // <c COOBmpToolBar>
  1104. // To set the image list in the control.
  1105. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1106. void COOBmpToolBar::InitImageList( void )
  1107. {
  1108. // Build the image list.
  1109. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1110. for ( int i=0; i<NB_POSSIBLE_MODE; i++ )
  1111. {
  1112. BuildImageList( m_ImageList[ i ], m_256Image[ i ] );
  1113. }
  1114. // Set the image list according to the current mode.
  1115. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1116. AssignImageList();
  1117. }
  1118. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1119. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1120. // Private Image list method.
  1121. // ------------------------------------------------------------------------
  1122. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1123. // @mfunc: (FUNCTIONAL)
  1124. // <c COOBmpToolBar>
  1125. // To build an image list based on the given bitmap and size.
  1126. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1127. void COOBmpToolBar::BuildImageList(
  1128. CImageList& _rImageList, // @Parm The image list to build.
  1129. const CExBitmap& _rBitmap ) // @Parm The bitmap to put in the image list.
  1130. {
  1131. CBitmap bmpImage;
  1132. bmpImage.LoadBitmap( _rBitmap.m_nResourceId );
  1133. _rImageList.Add( &bmpImage, _rBitmap.m_clrTransparent );
  1134. }
  1135. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1136. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1137. // Image list information method.
  1138. // ------------------------------------------------------------------------
  1139. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1140. // @mfunc: (FUNCTIONAL)
  1141. // <c COOBmpToolBar>
  1142. // To set the small hoover bitmap.
  1143. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1144. void COOBmpToolBar::SetBitmap(
  1145. UINT _nBitmap, // @Parm The bitmap id.
  1146. ImageMode_ _Mode, // @Parm The image mode.
  1147. COLORREF _clrBk, // @Parm The background color.
  1148. bool _b256 ) // @Parm The nb of color.
  1149. {
  1150. // Initialise the bitmap info.
  1151. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1152. if ( _b256 )
  1153. {
  1154. m_256Image[ _Mode ].m_nResourceId = _nBitmap;
  1155. m_256Image[ _Mode ].m_clrTransparent = _clrBk;
  1156. }
  1157. else
  1158. {
  1159. m_16Image[ _Mode ].m_nResourceId = _nBitmap;
  1160. m_16Image[ _Mode ].m_clrTransparent = _clrBk;
  1161. }
  1162. }
  1163. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1164. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1165. // Usefull protected method.
  1166. // ------------------------------------------------------------------------
  1167. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1168. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1169. // MFC Overloaded method.
  1170. // ------------------------------------------------------------------------
  1171. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1172. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1173. // MFC Message method.
  1174. // ------------------------------------------------------------------------
  1175. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=