Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1607 lines
43 KiB

  1. //
  2. // cuibln.cpp - ui frame object for balloon message window
  3. //
  4. #include "private.h"
  5. #include "cuiobj.h"
  6. #include "cuiwnd.h"
  7. #include "cuibln.h"
  8. #include "cuiutil.h"
  9. #include "cresstr.h"
  10. #include "cuires.h"
  11. //
  12. // constants
  13. //
  14. #define cxyTailWidth 10
  15. #define cxyTailHeight 16
  16. #define cxRoundSize 16
  17. #define cyRoundSize 16
  18. #define WM_HOOKEDKEY (WM_USER + 0x0001)
  19. //
  20. /* C U I F B A L L O O N B U T T O N */
  21. /*------------------------------------------------------------------------------
  22. ------------------------------------------------------------------------------*/
  23. CUIFBalloonButton::CUIFBalloonButton( CUIFObject *pParent, DWORD dwID, const RECT *prc, DWORD dwStyle ) : CUIFButton( pParent, dwID, prc, dwStyle )
  24. {
  25. m_iButtonID = 0;
  26. }
  27. /* ~ C U I F B A L L O O N B U T T O N */
  28. /*------------------------------------------------------------------------------
  29. ------------------------------------------------------------------------------*/
  30. CUIFBalloonButton::~CUIFBalloonButton( void )
  31. {
  32. }
  33. /* O N P A I N T */
  34. /*------------------------------------------------------------------------------
  35. ------------------------------------------------------------------------------*/
  36. void CUIFBalloonButton::OnPaint( HDC hDC )
  37. {
  38. HDC hDCMem = NULL;
  39. HBITMAP hBmMem = NULL;
  40. HBITMAP hBmMemOld = NULL;
  41. BOOL fDownFace = FALSE;
  42. COLORREF colLTFrame;
  43. COLORREF colRBFrame;
  44. HBRUSH hBrush;
  45. HBRUSH hBrushOld;
  46. HPEN hPen;
  47. HPEN hPenOld;
  48. RECT rcItem;
  49. rcItem = GetRectRef();
  50. OffsetRect( &rcItem, -rcItem.left, -rcItem.top );
  51. // create memory DC
  52. hDCMem = CreateCompatibleDC( hDC );
  53. hBmMem = CreateCompatibleBitmap( hDC, rcItem.right, rcItem.bottom );
  54. hBmMemOld = (HBITMAP)SelectObject( hDCMem, hBmMem );
  55. // determine button image
  56. switch (m_dwStatus) {
  57. default: {
  58. colLTFrame = GetSysColor( COLOR_INFOBK );
  59. colRBFrame = GetSysColor( COLOR_INFOBK );
  60. fDownFace = FALSE;
  61. break;
  62. }
  63. case UIBUTTON_DOWN: {
  64. colLTFrame = GetSysColor( COLOR_3DSHADOW );
  65. colRBFrame = GetSysColor( COLOR_3DHILIGHT );
  66. fDownFace = TRUE;
  67. break;
  68. }
  69. case UIBUTTON_HOVER: {
  70. colLTFrame = GetSysColor( COLOR_3DHILIGHT );
  71. colRBFrame = GetSysColor( COLOR_3DSHADOW );
  72. fDownFace = FALSE;
  73. break;
  74. }
  75. case UIBUTTON_DOWNOUT: {
  76. colLTFrame = GetSysColor( COLOR_3DHILIGHT );
  77. colRBFrame = GetSysColor( COLOR_3DSHADOW );
  78. fDownFace = FALSE;
  79. break;
  80. }
  81. }
  82. // paint button face
  83. hBrush = CreateSolidBrush( GetSysColor( COLOR_INFOBK ) );
  84. FillRect( hDCMem, &rcItem, hBrush );
  85. DeleteObject( hBrush );
  86. // paint image on button
  87. DrawTextProc( hDCMem, &rcItem, fDownFace );
  88. // paint button frame (hilight/shadow)
  89. hBrushOld = (HBRUSH)SelectObject( hDCMem, GetStockObject( NULL_BRUSH ) );
  90. hPen = CreatePen( PS_SOLID, 0, colLTFrame );
  91. hPenOld = (HPEN)SelectObject( hDCMem, hPen );
  92. RoundRect( hDCMem, rcItem.left, rcItem.top, rcItem.right - 1, rcItem.bottom - 1, 6, 6 );
  93. SelectObject( hDCMem, hPenOld );
  94. DeleteObject( hPen );
  95. hPen = CreatePen( PS_SOLID, 0, colRBFrame );
  96. hPenOld = (HPEN)SelectObject( hDCMem, hPen );
  97. RoundRect( hDCMem, rcItem.left + 1, rcItem.top + 1, rcItem.right, rcItem.bottom, 6, 6 );
  98. SelectObject( hDCMem, hPenOld );
  99. DeleteObject( hPen );
  100. // paint button frame (fixed)
  101. hPen = CreatePen( PS_SOLID, 0, GetSysColor( COLOR_3DFACE ) );
  102. hPenOld = (HPEN)SelectObject( hDCMem, hPen );
  103. RoundRect( hDCMem, rcItem.left + 1, rcItem.top + 1, rcItem.right - 1, rcItem.bottom - 1, 6, 6 );
  104. SelectObject( hDCMem, hPenOld );
  105. DeleteObject( hPen );
  106. SelectObject( hDCMem, hBrushOld );
  107. //
  108. BitBlt( hDC,
  109. GetRectRef().left,
  110. GetRectRef().top,
  111. GetRectRef().right - GetRectRef().left,
  112. GetRectRef().bottom - GetRectRef().top,
  113. hDCMem,
  114. rcItem.left,
  115. rcItem.top,
  116. SRCCOPY );
  117. //
  118. SelectObject( hDCMem, hBmMemOld );
  119. DeleteObject( hBmMem );
  120. DeleteDC( hDCMem );
  121. }
  122. /* G E T B U T T O N I D */
  123. /*------------------------------------------------------------------------------
  124. ------------------------------------------------------------------------------*/
  125. int CUIFBalloonButton::GetButtonID( void )
  126. {
  127. return m_iButtonID;
  128. }
  129. /* S E T B U T T O N I D */
  130. /*------------------------------------------------------------------------------
  131. ------------------------------------------------------------------------------*/
  132. void CUIFBalloonButton::SetButtonID( int iButtonID )
  133. {
  134. m_iButtonID = iButtonID;
  135. }
  136. /* D R A W T E X T P R O C */
  137. /*------------------------------------------------------------------------------
  138. Draw text on button face
  139. ------------------------------------------------------------------------------*/
  140. void CUIFBalloonButton::DrawTextProc( HDC hDC, const RECT *prc, BOOL fDown )
  141. {
  142. HFONT hFontOld;
  143. COLORREF colTextOld;
  144. int iBkModeOld;
  145. DWORD dwAlign = 0;
  146. RECT rc;
  147. //
  148. if (m_pwchText == NULL) {
  149. return;
  150. }
  151. //
  152. hFontOld = (HFONT)SelectObject( hDC, GetFont() );
  153. // calc text width
  154. switch (m_dwStyle & UIBUTTON_HALIGNMASK) {
  155. case UIBUTTON_LEFT:
  156. default: {
  157. dwAlign |= DT_LEFT;
  158. break;
  159. }
  160. case UIBUTTON_CENTER: {
  161. dwAlign |= DT_CENTER;
  162. break;
  163. }
  164. case UIBUTTON_RIGHT: {
  165. dwAlign |= DT_RIGHT;
  166. break;
  167. }
  168. }
  169. switch (m_dwStyle & UIBUTTON_VALIGNMASK) {
  170. case UIBUTTON_TOP:
  171. default: {
  172. dwAlign |= DT_TOP;
  173. break;
  174. }
  175. case UIBUTTON_VCENTER: {
  176. dwAlign |= DT_VCENTER;
  177. break;
  178. }
  179. case UIBUTTON_BOTTOM: {
  180. dwAlign |= DT_BOTTOM;
  181. break;
  182. }
  183. }
  184. //
  185. colTextOld = SetTextColor( hDC, GetSysColor( COLOR_BTNTEXT ) );
  186. iBkModeOld = SetBkMode( hDC, TRANSPARENT );
  187. rc = *prc;
  188. if (fDown) {
  189. OffsetRect( &rc, +1, +1 );
  190. }
  191. CUIDrawText( hDC, m_pwchText, -1, &rc, dwAlign | DT_SINGLELINE );
  192. SetBkMode( hDC, iBkModeOld );
  193. SetTextColor( hDC, colTextOld );
  194. SelectObject( hDC, hFontOld );
  195. }
  196. /*=============================================================================*/
  197. /* */
  198. /* C U I F B A L L O O N W I N D O W */
  199. /* */
  200. /*=============================================================================*/
  201. /* C U I F B A L L O O N W I N D O W */
  202. /*------------------------------------------------------------------------------
  203. Constructor of CUIFBalloonWindow
  204. ------------------------------------------------------------------------------*/
  205. CUIFBalloonWindow::CUIFBalloonWindow( HINSTANCE hInst, DWORD dwStyle ) : CUIFWindow( hInst, dwStyle )
  206. {
  207. m_hWindowRgn = NULL;
  208. m_pwszText = NULL;
  209. m_rcMargin.left = 8;
  210. m_rcMargin.top = 8;
  211. m_rcMargin.right = 8;
  212. m_rcMargin.bottom = 8;
  213. m_iMaxTxtWidth = -1;
  214. m_fColBack = FALSE;
  215. m_fColText = FALSE;
  216. m_colBack = RGB( 0, 0, 0 );
  217. m_colText = RGB( 0, 0, 0 );
  218. m_ptTarget.x = 0;
  219. m_ptTarget.y = 0;
  220. m_rcExclude.left = 0;
  221. m_rcExclude.right = 0;
  222. m_rcExclude.top = 0;
  223. m_rcExclude.bottom = 0;
  224. m_posDef = BALLOONPOS_ABOVE;
  225. m_pos = BALLOONPOS_ABOVE;
  226. m_dir = BALLOONDIR_LEFT;
  227. m_align = BALLOONALIGN_CENTER;
  228. m_ptTail.x = 0;
  229. m_ptTail.y = 0;
  230. m_nButton = 0;
  231. m_iCmd = -1;
  232. m_hWndNotify = 0;
  233. m_uiMsgNotify = WM_NULL;
  234. }
  235. /* ~ C U I F B A L L O O N W I N D O W */
  236. /*------------------------------------------------------------------------------
  237. Destructor of CUIFBalloonWindow
  238. ------------------------------------------------------------------------------*/
  239. CUIFBalloonWindow::~CUIFBalloonWindow( void )
  240. {
  241. if (m_pwszText != NULL) {
  242. delete m_pwszText;
  243. }
  244. }
  245. /* G E T C L A S S N A M E */
  246. /*------------------------------------------------------------------------------
  247. ------------------------------------------------------------------------------*/
  248. LPCTSTR CUIFBalloonWindow::GetClassName( void )
  249. {
  250. return TEXT(WNDCLASS_BALLOONWND);
  251. }
  252. /* G E T W N D T I T L E */
  253. /*------------------------------------------------------------------------------
  254. ------------------------------------------------------------------------------*/
  255. LPCTSTR CUIFBalloonWindow::GetWndTitle( void )
  256. {
  257. return TEXT(WNDTITLE_BALLOONWND);
  258. }
  259. /* I N I T I A L I Z E */
  260. /*------------------------------------------------------------------------------
  261. Initialize UI window object
  262. (UIFObject method)
  263. ------------------------------------------------------------------------------*/
  264. CUIFObject *CUIFBalloonWindow::Initialize( void )
  265. {
  266. CUIFObject *pUIObj = CUIFWindow::Initialize();
  267. // create buttons
  268. switch (GetStyleBits( UIBALLOON_BUTTONS )) {
  269. case UIBALLOON_OK: {
  270. AddButton( IDOK );
  271. break;
  272. }
  273. case UIBALLOON_YESNO: {
  274. AddButton( IDYES );
  275. AddButton( IDNO );
  276. break;
  277. }
  278. }
  279. return pUIObj;
  280. }
  281. /* O N C R E A T E */
  282. /*------------------------------------------------------------------------------
  283. ------------------------------------------------------------------------------*/
  284. void CUIFBalloonWindow::OnCreate( HWND hWnd )
  285. {
  286. UNREFERENCED_PARAMETER( hWnd );
  287. m_iCmd = -1;
  288. AdjustPos();
  289. }
  290. /* O N D E S T R O Y */
  291. /*------------------------------------------------------------------------------
  292. ------------------------------------------------------------------------------*/
  293. void CUIFBalloonWindow::OnDestroy( HWND hWnd )
  294. {
  295. UNREFERENCED_PARAMETER( hWnd );
  296. SendNotification( m_iCmd );
  297. DoneWindowRegion();
  298. }
  299. /* O N P A I N T */
  300. /*------------------------------------------------------------------------------
  301. Paint window object
  302. (UIFObject method)
  303. ------------------------------------------------------------------------------*/
  304. void CUIFBalloonWindow::OnPaint( HDC hDC )
  305. {
  306. RECT rcClient;
  307. RECT rcMargin;
  308. // paint balloon frame
  309. GetRect( &rcClient );
  310. PaintFrameProc( hDC, &rcClient );
  311. // paint message
  312. switch (m_pos) {
  313. default:
  314. case BALLOONPOS_ABOVE: {
  315. rcClient.bottom -= cxyTailHeight;
  316. break;
  317. }
  318. case BALLOONPOS_BELLOW: {
  319. rcClient.top += cxyTailHeight;
  320. break;
  321. }
  322. case BALLOONPOS_LEFT: {
  323. rcClient.right -= cxyTailHeight;
  324. break;
  325. }
  326. case BALLOONPOS_RIGHT: {
  327. rcClient.left += cxyTailHeight;
  328. break;
  329. }
  330. }
  331. GetMargin( &rcMargin );
  332. rcClient.left = rcClient.left + rcMargin.left;
  333. rcClient.top = rcClient.top + rcMargin.top;
  334. rcClient.right = rcClient.right - rcMargin.right;
  335. rcClient.bottom = rcClient.bottom - rcMargin.bottom;
  336. PaintMessageProc( hDC, &rcClient, m_pwszText );
  337. }
  338. /* O N K E Y D O W N */
  339. /*------------------------------------------------------------------------------
  340. ------------------------------------------------------------------------------*/
  341. void CUIFBalloonWindow::OnKeyDown( HWND hWnd, WPARAM wParam, LPARAM lParam )
  342. {
  343. UNREFERENCED_PARAMETER( hWnd );
  344. UNREFERENCED_PARAMETER( lParam );
  345. BOOL fEnd = FALSE;
  346. switch (wParam) {
  347. case VK_RETURN: {
  348. CUIFBalloonButton *pUIBtn = (CUIFBalloonButton *)FindUIObject( 0 ); /* first button */
  349. if (pUIBtn != NULL) {
  350. m_iCmd = pUIBtn->GetButtonID();
  351. fEnd = TRUE;
  352. }
  353. break;
  354. }
  355. case VK_ESCAPE: {
  356. m_iCmd = -1;
  357. fEnd = TRUE;
  358. break;
  359. }
  360. case 'Y': {
  361. CUIFBalloonButton *pUIBtn = FindButton( IDYES );
  362. if (pUIBtn != NULL) {
  363. m_iCmd = pUIBtn->GetButtonID();
  364. fEnd = TRUE;
  365. }
  366. break;
  367. }
  368. case 'N': {
  369. CUIFBalloonButton *pUIBtn = FindButton( IDNO );
  370. if (pUIBtn != NULL) {
  371. m_iCmd = pUIBtn->GetButtonID();
  372. fEnd = TRUE;
  373. }
  374. break;
  375. }
  376. }
  377. if (fEnd) {
  378. DestroyWindow( GetWnd() );
  379. }
  380. }
  381. /* O N O B J E C T N O T I F Y */
  382. /*------------------------------------------------------------------------------
  383. ------------------------------------------------------------------------------*/
  384. LRESULT CUIFBalloonWindow::OnObjectNotify( CUIFObject *pUIObj, DWORD dwCommand, LPARAM lParam )
  385. {
  386. UNREFERENCED_PARAMETER( dwCommand );
  387. UNREFERENCED_PARAMETER( lParam );
  388. m_iCmd = ((CUIFBalloonButton*)pUIObj)->GetButtonID();
  389. DestroyWindow( GetWnd() );
  390. return 0;
  391. }
  392. /* S E T T E X T */
  393. /*------------------------------------------------------------------------------
  394. ------------------------------------------------------------------------------*/
  395. LRESULT CUIFBalloonWindow::SetText( LPCWSTR pwchMessage )
  396. {
  397. if (m_pwszText != NULL) {
  398. delete m_pwszText;
  399. m_pwszText = NULL;
  400. }
  401. if (pwchMessage != NULL) {
  402. int l = lstrlenW( pwchMessage );
  403. m_pwszText = new WCHAR[ l+1 ];
  404. if (m_pwszText)
  405. StrCpyW( m_pwszText, pwchMessage );
  406. }
  407. else {
  408. m_pwszText = new WCHAR[1];
  409. if (m_pwszText)
  410. *m_pwszText = L'\0';
  411. }
  412. AdjustPos();
  413. return 0;
  414. }
  415. /* S E T N O T I F Y W I N D O W */
  416. /*------------------------------------------------------------------------------
  417. ------------------------------------------------------------------------------*/
  418. LRESULT CUIFBalloonWindow::SetNotifyWindow( HWND hWndNotify, UINT uiMsgNotify )
  419. {
  420. m_hWndNotify = hWndNotify;
  421. m_uiMsgNotify = uiMsgNotify;
  422. return 0;
  423. }
  424. /* S E T B A L L O O N P O S */
  425. /*------------------------------------------------------------------------------
  426. ------------------------------------------------------------------------------*/
  427. LRESULT CUIFBalloonWindow::SetBalloonPos( BALLOONWNDPOS pos )
  428. {
  429. m_posDef = pos;
  430. AdjustPos();
  431. return 0;
  432. }
  433. /* S E T B A L L O O N A L I G N */
  434. /*------------------------------------------------------------------------------
  435. ------------------------------------------------------------------------------*/
  436. LRESULT CUIFBalloonWindow::SetBalloonAlign( BALLOONWNDALIGN align )
  437. {
  438. m_align = align;
  439. AdjustPos();
  440. return 0;
  441. }
  442. /* G E T B K C O L O R */
  443. /*------------------------------------------------------------------------------
  444. Retrieves the background color in a tooltip window.
  445. ------------------------------------------------------------------------------*/
  446. LRESULT CUIFBalloonWindow::GetBalloonBkColor( void )
  447. {
  448. if (m_fColBack) {
  449. return (LRESULT)m_colBack;
  450. }
  451. else {
  452. return (LRESULT)GetSysColor( COLOR_INFOBK );
  453. }
  454. }
  455. /* G E T T E X T C O L O R */
  456. /*------------------------------------------------------------------------------
  457. Retrieves the text color in a tooltip window.
  458. ------------------------------------------------------------------------------*/
  459. LRESULT CUIFBalloonWindow::GetBalloonTextColor( void )
  460. {
  461. if (m_fColText) {
  462. return (LRESULT)m_colText;
  463. }
  464. else {
  465. return (LRESULT)GetSysColor( COLOR_INFOTEXT );
  466. }
  467. }
  468. /* G E T M A R G I N */
  469. /*------------------------------------------------------------------------------
  470. Retrieves the top, left, bottom, and right margins set for a tooltip window.
  471. A margin is the distance, in pixels, between the tooltip window border and
  472. the text contained within the tooltip window.
  473. ------------------------------------------------------------------------------*/
  474. LRESULT CUIFBalloonWindow::GetMargin( RECT *prc )
  475. {
  476. if (prc == NULL) {
  477. return 0;
  478. }
  479. *prc = m_rcMargin;
  480. return 0;
  481. }
  482. /* G E T M A X T I P W I D T H */
  483. /*------------------------------------------------------------------------------
  484. Retrieves the maximum width for a tooltip window.
  485. ------------------------------------------------------------------------------*/
  486. LRESULT CUIFBalloonWindow::GetMaxBalloonWidth( void )
  487. {
  488. return m_iMaxTxtWidth;
  489. }
  490. /* S E T B K C O L O R */
  491. /*------------------------------------------------------------------------------
  492. Sets the background color in a tooltip window.
  493. ------------------------------------------------------------------------------*/
  494. LRESULT CUIFBalloonWindow::SetBalloonBkColor( COLORREF col )
  495. {
  496. m_fColBack = TRUE;
  497. m_colBack = col;
  498. return 0;
  499. }
  500. /* S E T T E X T C O L O R */
  501. /*------------------------------------------------------------------------------
  502. Sets the text color in a tooltip window.
  503. ------------------------------------------------------------------------------*/
  504. LRESULT CUIFBalloonWindow::SetBalloonTextColor( COLORREF col )
  505. {
  506. m_fColText = TRUE;
  507. m_colText = col;
  508. return 0;
  509. }
  510. /* S E T M A R G I N */
  511. /*------------------------------------------------------------------------------
  512. Sets the top, left, bottom, and right margins for a tooltip window. A margin
  513. is the distance, in pixels, between the tooltip window border and the text
  514. contained within the tooltip window.
  515. ------------------------------------------------------------------------------*/
  516. LRESULT CUIFBalloonWindow::SetMargin( RECT *prc )
  517. {
  518. if (prc == NULL) {
  519. return 0;
  520. }
  521. m_rcMargin = *prc;
  522. return 0;
  523. }
  524. /* S E T M A X T I P W I D T H */
  525. /*------------------------------------------------------------------------------
  526. Sets the maximum width for a tooltip window.
  527. ------------------------------------------------------------------------------*/
  528. LRESULT CUIFBalloonWindow::SetMaxBalloonWidth( INT iWidth )
  529. {
  530. m_iMaxTxtWidth = iWidth;
  531. return 0;
  532. }
  533. /* S E T B U T T O N T E X T */
  534. /*------------------------------------------------------------------------------
  535. ------------------------------------------------------------------------------*/
  536. LRESULT CUIFBalloonWindow::SetButtonText( int idCmd, LPCWSTR pwszText )
  537. {
  538. CUIFBalloonButton *pUIBtn = FindButton( idCmd );
  539. if (pUIBtn != NULL) {
  540. pUIBtn->SetText( pwszText );
  541. }
  542. return 0;
  543. }
  544. /* S E T T A R G E T P O S */
  545. /*------------------------------------------------------------------------------
  546. ------------------------------------------------------------------------------*/
  547. LRESULT CUIFBalloonWindow::SetTargetPos( POINT pt )
  548. {
  549. m_ptTarget = pt;
  550. AdjustPos();
  551. return 0;
  552. }
  553. /* S E T E X C L U D E R E C T */
  554. /*------------------------------------------------------------------------------
  555. ------------------------------------------------------------------------------*/
  556. LRESULT CUIFBalloonWindow::SetExcludeRect( const RECT *prcExclude )
  557. {
  558. m_rcExclude = *prcExclude;
  559. AdjustPos();
  560. return 0;
  561. }
  562. /* C R E A T E R E G I O N */
  563. /*------------------------------------------------------------------------------
  564. ------------------------------------------------------------------------------*/
  565. HRGN CUIFBalloonWindow::CreateRegion( RECT *prc )
  566. {
  567. POINT rgPt[4];
  568. HRGN hRgn;
  569. HRGN hRgnTail;
  570. // create message body window
  571. switch (m_pos) {
  572. default:
  573. case BALLOONPOS_ABOVE: {
  574. #ifndef UNDER_CE // CE does not support RoundRectRgn
  575. hRgn = CreateRoundRectRgn(
  576. prc->left,
  577. prc->top,
  578. prc->right,
  579. prc->bottom - cxyTailHeight,
  580. cxRoundSize,
  581. cyRoundSize );
  582. #else // UNDER_CE
  583. hRgn = CreateRectRgn(
  584. prc->left,
  585. prc->top,
  586. prc->right,
  587. prc->bottom - cxyTailHeight );
  588. #endif // UNDER_CE
  589. rgPt[0].x = m_ptTail.x;
  590. rgPt[0].y = prc->bottom - 1 - cxyTailHeight;
  591. rgPt[1].x = m_ptTail.x;
  592. rgPt[1].y = m_ptTail.y;
  593. rgPt[2].x = m_ptTail.x + cxyTailWidth * (m_dir == BALLOONDIR_LEFT ? +1 : -1 );
  594. rgPt[2].y = prc->bottom - 1 - cxyTailHeight;
  595. rgPt[3] = rgPt[0];
  596. break;
  597. }
  598. case BALLOONPOS_BELLOW: {
  599. #ifndef UNDER_CE // CE does not support RoundRectRgn
  600. hRgn = CreateRoundRectRgn(
  601. prc->left,
  602. prc->top + cxyTailHeight,
  603. prc->right,
  604. prc->bottom,
  605. cxRoundSize,
  606. cyRoundSize );
  607. #else // UNDER_CE
  608. hRgn = CreateRectRgn(
  609. prc->left,
  610. prc->top + cxyTailHeight,
  611. prc->right,
  612. prc->bottom );
  613. #endif // UNDER_CE
  614. rgPt[0].x = m_ptTail.x;
  615. rgPt[0].y = prc->top + cxyTailHeight;
  616. rgPt[1].x = m_ptTail.x;
  617. rgPt[1].y = m_ptTail.y;
  618. rgPt[2].x = m_ptTail.x + cxyTailWidth * (m_dir == BALLOONDIR_LEFT ? +1 : -1 );
  619. rgPt[2].y = prc->top + cxyTailHeight;
  620. rgPt[3] = rgPt[0];
  621. break;
  622. }
  623. case BALLOONPOS_LEFT: {
  624. #ifndef UNDER_CE // CE does not support RoundRectRgn
  625. hRgn = CreateRoundRectRgn(
  626. prc->left,
  627. prc->top,
  628. prc->right - cxyTailHeight,
  629. prc->bottom,
  630. cxRoundSize,
  631. cyRoundSize );
  632. #else // UNDER_CE
  633. hRgn = CreateRectRgn(
  634. prc->left,
  635. prc->top,
  636. prc->right - cxyTailHeight,
  637. prc->bottom );
  638. #endif // UNDER_CE
  639. rgPt[0].x = prc->right - 1 - cxyTailHeight;
  640. rgPt[0].y = m_ptTail.y;
  641. rgPt[1].x = m_ptTail.x;
  642. rgPt[1].y = m_ptTail.y;
  643. rgPt[2].x = prc->right - 1 - cxyTailHeight;
  644. rgPt[2].y = m_ptTail.y + cxyTailWidth * (m_dir == BALLOONDIR_UP ? +1 : -1 );
  645. rgPt[3] = rgPt[0];
  646. break;
  647. }
  648. case BALLOONPOS_RIGHT: {
  649. #ifndef UNDER_CE // CE does not support RoundRectRgn
  650. hRgn = CreateRoundRectRgn(
  651. prc->left + cxyTailHeight,
  652. prc->top,
  653. prc->right,
  654. prc->bottom,
  655. cxRoundSize,
  656. cyRoundSize );
  657. #else // UNDER_CE
  658. hRgn = CreateRectRgn(
  659. prc->left + cxyTailHeight,
  660. prc->top,
  661. prc->right,
  662. prc->bottom );
  663. #endif // UNDER_CE
  664. rgPt[0].x = prc->left + cxyTailHeight;
  665. rgPt[0].y = m_ptTail.y;
  666. rgPt[1].x = m_ptTail.x;
  667. rgPt[1].y = m_ptTail.y;
  668. rgPt[2].x = prc->left + cxyTailHeight;
  669. rgPt[2].y = m_ptTail.y + cxyTailWidth * (m_dir == BALLOONDIR_UP ? +1 : -1 );
  670. rgPt[3] = rgPt[0];
  671. break;
  672. }
  673. }
  674. // add balloon tail region
  675. #ifndef UNDER_CE // tmptmp CE does not support. check later !!
  676. hRgnTail = CreatePolygonRgn( rgPt, 4, WINDING );
  677. #endif // UNDER_CE
  678. CombineRgn( hRgn, hRgn, hRgnTail, RGN_OR );
  679. DeleteRgn( hRgnTail );
  680. return hRgn;
  681. }
  682. /* P A I N T F R A M E P R O C */
  683. /*------------------------------------------------------------------------------
  684. ------------------------------------------------------------------------------*/
  685. void CUIFBalloonWindow::PaintFrameProc( HDC hDC, RECT *prc )
  686. {
  687. HRGN hRgn;
  688. HBRUSH hBrushFrm;
  689. HBRUSH hBrushWnd;
  690. Assert( hDC != NULL );
  691. hRgn = CreateRegion( prc );
  692. hBrushWnd = CreateSolidBrush( (COLORREF)GetBalloonBkColor() );
  693. hBrushFrm = CreateSolidBrush( GetSysColor( COLOR_WINDOWFRAME ) );
  694. FillRgn( hDC, hRgn, hBrushWnd );
  695. #ifndef UNDER_CE // tmptmp CE does not support. check later !!
  696. FrameRgn( hDC, hRgn, hBrushFrm, 1, 1 );
  697. #endif // UNDER_CE
  698. DeleteObject( hBrushWnd );
  699. DeleteObject( hBrushFrm );
  700. DeleteObject( hRgn );
  701. }
  702. /* P A I N T M E S S A G E P R O C */
  703. /*------------------------------------------------------------------------------
  704. ------------------------------------------------------------------------------*/
  705. void CUIFBalloonWindow::PaintMessageProc( HDC hDC, RECT *prc, WCHAR *pwszText )
  706. {
  707. HFONT hFontOld;
  708. COLORREF colTextOld;
  709. int iBkModeOld;
  710. Assert( hDC != NULL );
  711. hFontOld = (HFONT)SelectObject( hDC, m_hFont );
  712. colTextOld = SetTextColor( hDC, (COLORREF)GetBalloonTextColor() );
  713. iBkModeOld = SetBkMode( hDC, TRANSPARENT );
  714. CUIDrawText( hDC, pwszText, -1, prc, DT_LEFT | DT_WORDBREAK );
  715. SelectObject( hDC, hFontOld );
  716. SetTextColor( hDC, colTextOld );
  717. SetBkMode( hDC, iBkModeOld );
  718. }
  719. /* I N I T W I N D O W R E G I O N */
  720. /*------------------------------------------------------------------------------
  721. Set window region
  722. ------------------------------------------------------------------------------*/
  723. void CUIFBalloonWindow::InitWindowRegion( void )
  724. {
  725. RECT rcClient;
  726. GetRect( &rcClient );
  727. m_hWindowRgn = CreateRegion( &rcClient );
  728. if (m_hWindowRgn != NULL) {
  729. SetWindowRgn( GetWnd(), m_hWindowRgn, TRUE );
  730. }
  731. }
  732. /* D O N E W I N D O W R E G I O N */
  733. /*------------------------------------------------------------------------------
  734. Reset window region
  735. ------------------------------------------------------------------------------*/
  736. void CUIFBalloonWindow::DoneWindowRegion( void )
  737. {
  738. if (m_hWindowRgn != NULL) {
  739. SetWindowRgn( GetWnd(), NULL, TRUE );
  740. DeleteObject( m_hWindowRgn );
  741. m_hWindowRgn = NULL;
  742. }
  743. }
  744. /* G E T B U T T O N S I Z E */
  745. /*------------------------------------------------------------------------------
  746. ------------------------------------------------------------------------------*/
  747. void CUIFBalloonWindow::GetButtonSize( SIZE *pSize )
  748. {
  749. HDC hDC;
  750. HFONT hFontOld;
  751. TEXTMETRIC TM;
  752. // get text metrics
  753. #ifndef UNDER_CE // DCA => DCW
  754. hDC = CreateDC( "DISPLAY", NULL, NULL, NULL );
  755. #else // UNDER_CE
  756. hDC = CreateDCW( L"DISPLAY", NULL, NULL, NULL );
  757. #endif // UNDER_CE
  758. hFontOld = (HFONT)SelectObject( hDC, GetFont() );
  759. GetTextMetrics( hDC, &TM );
  760. SelectObject( hDC, hFontOld );
  761. DeleteDC( hDC );
  762. // calc button size
  763. pSize->cx = TM.tmAveCharWidth * 16;
  764. pSize->cy = TM.tmHeight + 10;
  765. }
  766. /* A D J U S T P O S */
  767. /*------------------------------------------------------------------------------
  768. ------------------------------------------------------------------------------*/
  769. void CUIFBalloonWindow::AdjustPos( void )
  770. {
  771. HDC hDC;
  772. HFONT hFontOld;
  773. TEXTMETRIC TM;
  774. RECT rcWork;
  775. RECT rcWindow = {0};
  776. SIZE WndSize;
  777. RECT rcText;
  778. SIZE BtnSize;
  779. if (!IsWindow( GetWnd() )) {
  780. return;
  781. }
  782. if (m_pwszText == NULL) {
  783. return;
  784. }
  785. //
  786. GetButtonSize( &BtnSize );
  787. // get text size
  788. #ifndef UNDER_CE // DCA => DCW
  789. hDC = GetDC( GetWnd() ); //CreateDC( "DISPLAY", NULL, NULL, NULL );
  790. #else // UNDER_CE
  791. hDC = GetDCW( GetWnd() ); //CreateDCW( L"DISPLAY", NULL, NULL, NULL );
  792. #endif // UNDER_CE
  793. hFontOld = (HFONT)SelectObject( hDC, GetFont() );
  794. GetTextMetrics( hDC, &TM );
  795. rcText.left = 0;
  796. rcText.right = TM.tmAveCharWidth * 40;
  797. rcText.top = 0;
  798. rcText.bottom = 0;
  799. if (0 < m_nButton) {
  800. rcText.right = max( rcText.right, BtnSize.cx*m_nButton + BtnSize.cx/2*(m_nButton-1) );
  801. }
  802. CUIDrawText( hDC, m_pwszText, -1, &rcText, DT_LEFT | DT_WORDBREAK | DT_CALCRECT );
  803. SelectObject( hDC, hFontOld );
  804. ReleaseDC( GetWnd(), hDC );
  805. //
  806. // determine window size
  807. //
  808. // max width
  809. if (0 < m_nButton) {
  810. rcText.right = max( rcText.right, BtnSize.cx*m_nButton + BtnSize.cx/2*(m_nButton-1) );
  811. }
  812. // client width
  813. WndSize.cx = (rcText.right - rcText.left)
  814. + m_rcMargin.left
  815. + m_rcMargin.right;
  816. WndSize.cy = (rcText.bottom - rcText.top)
  817. + m_rcMargin.top
  818. + m_rcMargin.bottom;
  819. // tail width
  820. switch (m_pos) {
  821. default:
  822. case BALLOONPOS_ABOVE:
  823. case BALLOONPOS_BELLOW: {
  824. WndSize.cy += cxyTailHeight; /* balloon tail height */
  825. break;
  826. }
  827. case BALLOONPOS_LEFT:
  828. case BALLOONPOS_RIGHT: {
  829. WndSize.cx += cxyTailHeight; /* balloon tail height */
  830. break;
  831. }
  832. }
  833. // buton height
  834. if (0 < m_nButton) {
  835. WndSize.cy += m_rcMargin.bottom + BtnSize.cy; /* margin and button height */
  836. }
  837. //
  838. // determine tip window place
  839. //
  840. SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 );
  841. if (CUIIsMonitorAPIAvail()) {
  842. HMONITOR hMonitor;
  843. MONITORINFO MonitorInfo;
  844. hMonitor = CUIMonitorFromPoint( m_ptTarget, MONITOR_DEFAULTTONEAREST );
  845. if (hMonitor != NULL) {
  846. MonitorInfo.cbSize = sizeof(MonitorInfo);
  847. if (CUIGetMonitorInfo( hMonitor, &MonitorInfo )) {
  848. rcWork = MonitorInfo.rcMonitor;
  849. }
  850. }
  851. }
  852. m_pos = m_posDef;
  853. switch (m_pos) {
  854. default:
  855. case BALLOONPOS_ABOVE: {
  856. if (m_rcExclude.top - WndSize.cy < rcWork.top) {
  857. // cannot locate the tip window at above. can put it at bellow?
  858. if (m_rcExclude.bottom + WndSize.cy < rcWork.bottom) {
  859. m_pos = BALLOONPOS_BELLOW;
  860. }
  861. }
  862. break;
  863. }
  864. case BALLOONPOS_BELLOW: {
  865. if (rcWork.bottom <= m_rcExclude.bottom + WndSize.cy) {
  866. // cannot locate the tip window at bellow. can put it at above?
  867. if (rcWork.top < m_rcExclude.top - WndSize.cy) {
  868. m_pos = BALLOONPOS_ABOVE;
  869. }
  870. }
  871. break;
  872. }
  873. case BALLOONPOS_LEFT: {
  874. if (m_rcExclude.left - WndSize.cx < rcWork.left) {
  875. // cannot locate the tip window at left. can put it at right?
  876. if (m_rcExclude.right + WndSize.cx < rcWork.right) {
  877. m_pos = BALLOONPOS_RIGHT;
  878. }
  879. }
  880. break;
  881. }
  882. case BALLOONPOS_RIGHT: {
  883. if (rcWork.right <= m_rcExclude.right + WndSize.cx) {
  884. // cannot locate the tip window at right. can put it at left?
  885. if (rcWork.left < m_rcExclude.left - WndSize.cx) {
  886. m_pos = BALLOONPOS_LEFT;
  887. }
  888. }
  889. break;
  890. }
  891. }
  892. //
  893. // calc window position
  894. //
  895. switch (m_pos) {
  896. default:
  897. case BALLOONPOS_ABOVE: {
  898. switch (m_align) {
  899. default:
  900. case BALLOONALIGN_CENTER: {
  901. rcWindow.left = m_ptTarget.x - WndSize.cx / 2;
  902. break;
  903. }
  904. case BALLOONALIGN_LEFT: {
  905. rcWindow.left = m_rcExclude.left;
  906. break;
  907. }
  908. case BALLOONALIGN_RIGHT: {
  909. rcWindow.left = m_rcExclude.right - WndSize.cx;
  910. break;
  911. }
  912. }
  913. rcWindow.top = m_rcExclude.top - WndSize.cy;
  914. break;
  915. }
  916. case BALLOONPOS_BELLOW: {
  917. switch (m_align) {
  918. default:
  919. case BALLOONALIGN_CENTER: {
  920. rcWindow.left = m_ptTarget.x - WndSize.cx / 2;
  921. break;
  922. }
  923. case BALLOONALIGN_LEFT: {
  924. rcWindow.left = m_rcExclude.left;
  925. break;
  926. }
  927. case BALLOONALIGN_RIGHT: {
  928. rcWindow.left = m_rcExclude.right - WndSize.cx;
  929. break;
  930. }
  931. }
  932. rcWindow.top = m_rcExclude.bottom;
  933. break;
  934. }
  935. case BALLOONPOS_LEFT: {
  936. rcWindow.left = m_rcExclude.left - WndSize.cx;
  937. switch (m_align) {
  938. default:
  939. case BALLOONALIGN_CENTER: {
  940. rcWindow.top = m_ptTarget.y - WndSize.cy / 2;
  941. break;
  942. }
  943. case BALLOONALIGN_TOP: {
  944. rcWindow.top = m_rcExclude.top;
  945. break;
  946. }
  947. case BALLOONALIGN_BOTTOM: {
  948. rcWindow.top = m_rcExclude.bottom - WndSize.cy;
  949. break;
  950. }
  951. }
  952. break;
  953. }
  954. case BALLOONPOS_RIGHT: {
  955. rcWindow.left = m_rcExclude.right;
  956. switch (m_align) {
  957. default:
  958. case BALLOONALIGN_CENTER: {
  959. rcWindow.top = m_ptTarget.y - WndSize.cy / 2;
  960. break;
  961. }
  962. case BALLOONALIGN_TOP: {
  963. rcWindow.top = m_rcExclude.top;
  964. break;
  965. }
  966. case BALLOONALIGN_BOTTOM: {
  967. rcWindow.top = m_rcExclude.bottom - WndSize.cy;
  968. break;
  969. }
  970. }
  971. break;
  972. }
  973. }
  974. rcWindow.right = rcWindow.left + WndSize.cx;
  975. rcWindow.bottom = rcWindow.top + WndSize.cy;
  976. if (rcWindow.left < rcWork.left) {
  977. OffsetRect( &rcWindow, rcWork.left - rcWindow.left, 0 );
  978. }
  979. else if (rcWork.right < rcWindow.right) {
  980. OffsetRect( &rcWindow, rcWork.right - rcWindow.right, 0 );
  981. }
  982. if (rcWindow.top < rcWork.top) {
  983. OffsetRect( &rcWindow, 0, rcWork.top - rcWindow.top );
  984. }
  985. else if (rcWork.bottom < rcWindow.bottom) {
  986. OffsetRect( &rcWindow, 0, rcWork.bottom - rcWindow.bottom );
  987. }
  988. //
  989. // calc target (end of balloon tail) point and direction
  990. //
  991. switch (m_pos) {
  992. default:
  993. case BALLOONPOS_ABOVE: {
  994. m_ptTail.x = m_ptTarget.x;
  995. m_ptTail.x = max( m_ptTail.x, rcWindow.left + cxRoundSize/2 );
  996. m_ptTail.x = min( m_ptTail.x, rcWindow.right - cxRoundSize/2 - 1 );
  997. m_ptTail.y = rcWindow.bottom - 1;
  998. m_dir = ((m_ptTail.x < (rcWindow.left + rcWindow.right)/2) ? BALLOONDIR_LEFT : BALLOONDIR_RIGHT);
  999. break;
  1000. }
  1001. case BALLOONPOS_BELLOW: {
  1002. m_ptTail.x = m_ptTarget.x;
  1003. m_ptTail.x = max( m_ptTail.x, rcWindow.left + cxRoundSize/2 );
  1004. m_ptTail.x = min( m_ptTail.x, rcWindow.right - cxRoundSize/2 - 1 );
  1005. m_ptTail.y = rcWindow.top;
  1006. m_dir = ((m_ptTail.x < (rcWindow.left + rcWindow.right)/2) ? BALLOONDIR_LEFT : BALLOONDIR_RIGHT);
  1007. break;
  1008. }
  1009. case BALLOONPOS_LEFT: {
  1010. m_ptTail.x = rcWindow.right - 1;
  1011. m_ptTail.y = m_ptTarget.y;
  1012. m_ptTail.y = max( m_ptTail.y, rcWindow.top + cyRoundSize/2 );
  1013. m_ptTail.y = min( m_ptTail.y, rcWindow.bottom - cyRoundSize/2 - 1 );
  1014. m_dir = ((m_ptTail.y < (rcWindow.top + rcWindow.bottom)/2) ? BALLOONDIR_UP : BALLOONDIR_DOWN);
  1015. break;
  1016. }
  1017. case BALLOONPOS_RIGHT: {
  1018. m_ptTail.x = rcWindow.left;
  1019. m_ptTail.y = m_ptTarget.y;
  1020. m_ptTail.y = max( m_ptTail.y, rcWindow.top + cyRoundSize/2 );
  1021. m_ptTail.y = min( m_ptTail.y, rcWindow.bottom - cyRoundSize/2 - 1 );
  1022. m_dir = ((m_ptTail.y < (rcWindow.top + rcWindow.bottom)/2) ? BALLOONDIR_UP : BALLOONDIR_DOWN);
  1023. break;
  1024. }
  1025. }
  1026. m_ptTail.x -= rcWindow.left; // client pos
  1027. m_ptTail.y -= rcWindow.top; // client pos
  1028. //
  1029. Show( FALSE );
  1030. DoneWindowRegion();
  1031. Move( rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top );
  1032. LayoutObject();
  1033. InitWindowRegion();
  1034. Show( TRUE );
  1035. }
  1036. /* L A Y O U T O B J E C T */
  1037. /*------------------------------------------------------------------------------
  1038. ------------------------------------------------------------------------------*/
  1039. void CUIFBalloonWindow::LayoutObject( void )
  1040. {
  1041. RECT rcClient;
  1042. RECT rcMargin;
  1043. SIZE BtnSize;
  1044. int i;
  1045. //
  1046. GetButtonSize( &BtnSize );
  1047. // layout buttons
  1048. GetRect( &rcClient );
  1049. switch (m_pos) {
  1050. default:
  1051. case BALLOONPOS_ABOVE: {
  1052. rcClient.bottom -= cxyTailHeight;
  1053. break;
  1054. }
  1055. case BALLOONPOS_BELLOW: {
  1056. rcClient.top += cxyTailHeight;
  1057. break;
  1058. }
  1059. case BALLOONPOS_LEFT: {
  1060. rcClient.right -= cxyTailHeight;
  1061. break;
  1062. }
  1063. case BALLOONPOS_RIGHT: {
  1064. rcClient.left += cxyTailHeight;
  1065. break;
  1066. }
  1067. }
  1068. GetMargin( &rcMargin );
  1069. rcClient.left = rcClient.left + rcMargin.left;
  1070. rcClient.top = rcClient.top + rcMargin.top;
  1071. rcClient.right = rcClient.right - rcMargin.right;
  1072. rcClient.bottom = rcClient.bottom - rcMargin.bottom;
  1073. //
  1074. for (i = 0; i < m_nButton; i++) {
  1075. CUIFObject *pUIBtn = FindUIObject( i );
  1076. if (pUIBtn != NULL) {
  1077. RECT rcButton;
  1078. rcButton.left = ((rcClient.left + rcClient.right) - (BtnSize.cx*m_nButton + BtnSize.cx/2*(m_nButton-1))) / 2 + BtnSize.cx*i + BtnSize.cx/2*i;
  1079. rcButton.top = rcClient.bottom - BtnSize.cy;
  1080. rcButton.right = rcButton.left + BtnSize.cx;
  1081. rcButton.bottom = rcButton.top + BtnSize.cy;
  1082. pUIBtn->SetRect( &rcButton );
  1083. pUIBtn->Show( TRUE );
  1084. }
  1085. }
  1086. }
  1087. /* A D D B U T T O N */
  1088. /*------------------------------------------------------------------------------
  1089. ------------------------------------------------------------------------------*/
  1090. void CUIFBalloonWindow::AddButton( int idCmd )
  1091. {
  1092. CUIFBalloonButton *pUIBtn = NULL;
  1093. RECT rcNull = { 0, 0, 0, 0 };
  1094. switch (idCmd) {
  1095. case IDOK:
  1096. case IDCANCEL:
  1097. case IDABORT:
  1098. case IDRETRY:
  1099. case IDIGNORE:
  1100. case IDYES:
  1101. case IDNO: {
  1102. pUIBtn = new CUIFBalloonButton( this, (DWORD)m_nButton, &rcNull, UIBUTTON_PUSH | UIBUTTON_CENTER | UIBUTTON_VCENTER );
  1103. break;
  1104. }
  1105. }
  1106. if (pUIBtn != NULL) {
  1107. //
  1108. WCHAR *pwsz;
  1109. pUIBtn->Initialize();
  1110. pUIBtn->SetButtonID( idCmd );
  1111. switch (idCmd) {
  1112. case IDOK: {
  1113. pwsz = CRStr(CUI_IDS_OK);
  1114. pUIBtn->SetText( *pwsz ? pwsz : L"OK" );
  1115. break;
  1116. }
  1117. case IDCANCEL: {
  1118. pwsz = CRStr(CUI_IDS_CANCEL);
  1119. pUIBtn->SetText( *pwsz ? pwsz : L"Cancel" );
  1120. break;
  1121. }
  1122. case IDABORT: {
  1123. pwsz = CRStr(CUI_IDS_ABORT);
  1124. pUIBtn->SetText( *pwsz ? pwsz : L"&Abort" );
  1125. break;
  1126. }
  1127. case IDRETRY: {
  1128. pwsz = CRStr(CUI_IDS_RETRY);
  1129. pUIBtn->SetText( *pwsz ? pwsz : L"&Retry" );
  1130. break;
  1131. }
  1132. case IDIGNORE: {
  1133. pwsz = CRStr(CUI_IDS_IGNORE);
  1134. pUIBtn->SetText( *pwsz ? pwsz : L"&Ignore" );
  1135. break;
  1136. }
  1137. case IDYES: {
  1138. pwsz = CRStr(CUI_IDS_YES);
  1139. pUIBtn->SetText( *pwsz ? pwsz : L"&Yes" );
  1140. break;
  1141. }
  1142. case IDNO: {
  1143. pwsz = CRStr(CUI_IDS_NO);
  1144. pUIBtn->SetText( *pwsz ? pwsz : L"&No" );
  1145. break;
  1146. }
  1147. }
  1148. AddUIObj( pUIBtn );
  1149. m_nButton++;
  1150. }
  1151. }
  1152. /* F I N D U I O B J E C T */
  1153. /*------------------------------------------------------------------------------
  1154. Find UI object which has an ID
  1155. When no UI object found, returns NULL.
  1156. ------------------------------------------------------------------------------*/
  1157. CUIFObject *CUIFBalloonWindow::FindUIObject( DWORD dwID )
  1158. {
  1159. int nChild;
  1160. int i;
  1161. nChild = m_ChildList.GetCount();
  1162. for (i = 0; i < nChild; i++) {
  1163. CUIFObject *pUIObj = m_ChildList.Get( i );
  1164. Assert(PtrToInt( pUIObj ));
  1165. if (pUIObj->GetID() == dwID) {
  1166. return pUIObj;
  1167. }
  1168. }
  1169. return NULL;
  1170. }
  1171. /* F I N D B U T T O N */
  1172. /*------------------------------------------------------------------------------
  1173. ------------------------------------------------------------------------------*/
  1174. CUIFBalloonButton *CUIFBalloonWindow::FindButton( int idCmd )
  1175. {
  1176. int i;
  1177. for (i = 0; i < m_nButton; i++) {
  1178. CUIFBalloonButton *pUIBtn = (CUIFBalloonButton*)FindUIObject( i );
  1179. if ((pUIBtn != NULL) && (pUIBtn->GetButtonID() == idCmd)) {
  1180. return pUIBtn;
  1181. }
  1182. }
  1183. return NULL;
  1184. }
  1185. /* S E N D N O T I F I C A T I O N */
  1186. /*------------------------------------------------------------------------------
  1187. ------------------------------------------------------------------------------*/
  1188. void CUIFBalloonWindow::SendNotification( int iCmd )
  1189. {
  1190. if (m_hWndNotify != NULL) {
  1191. PostMessage( m_hWndNotify, m_uiMsgNotify, (WPARAM)iCmd, 0 );
  1192. }
  1193. }