home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Visual Basic.60 / COMMON / TOOLS / VCM / VCM.MDB / VcmComponentContainer / 02_Cabinet / TOOLPAGE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-18  |  3.7 KB  |  152 lines

  1. // ToolPage.cpp : implementation file
  2. //
  3.  
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1998 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14. #include "stdafx.h"
  15. #include "CmnCtrl1.h"
  16. #include "toolbar1.h"
  17. #include "toolbar2.h"
  18. #include "ToolPage.h"
  19.  
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CToolBarCtrlPage property page
  28.  
  29. IMPLEMENT_DYNCREATE(CToolBarCtrlPage, CPropertyPage)
  30.  
  31. CToolBarCtrlPage::CToolBarCtrlPage() : CPropertyPage(CToolBarCtrlPage::IDD)
  32. {
  33.     //{{AFX_DATA_INIT(CToolBarCtrlPage)
  34.     m_bAltDrag = FALSE;
  35.     //}}AFX_DATA_INIT
  36.     m_psp.dwFlags &= ~PSP_HASHELP;  // Lose the Help button
  37. }
  38.  
  39. CToolBarCtrlPage::~CToolBarCtrlPage()
  40. {
  41. }
  42.  
  43. void CToolBarCtrlPage::DoDataExchange(CDataExchange* pDX)
  44. {
  45.     CPropertyPage::DoDataExchange(pDX);
  46.     //{{AFX_DATA_MAP(CToolBarCtrlPage)
  47.     DDX_Check(pDX, IDC_ALTDRAG, m_bAltDrag);
  48.     //}}AFX_DATA_MAP
  49. }
  50.  
  51.  
  52. BEGIN_MESSAGE_MAP(CToolBarCtrlPage, CPropertyPage)
  53.     //{{AFX_MSG_MAP(CToolBarCtrlPage)
  54.     ON_BN_CLICKED(IDC_ALTDRAG, OnAltdrag)
  55.     //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59.  
  60. BOOL CToolBarCtrlPage::OnInitDialog()
  61. {
  62.  
  63.     CPropertyPage::OnInitDialog();
  64.  
  65.  
  66.     m_StandardBar.Create(WS_BORDER | WS_VISIBLE | WS_CHILD
  67.             | CCS_TOP | CCS_ADJUSTABLE | TBSTYLE_TOOLTIPS,
  68.         CRect(0,0,0,0),this, IDR_STANDARDBAR);
  69.  
  70.     m_PaletteBar.Create(WS_BORDER | WS_VISIBLE | WS_CHILD
  71.             | CCS_BOTTOM | TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS,
  72.         CRect(0,0,0,0),this, IDR_PALETTEBAR);
  73.  
  74.     m_StandardBar.AutoSize();
  75.     m_PaletteBar.AutoSize();
  76.  
  77.     m_ToolTip.Create(this);
  78.  
  79.     CString cstrToolTip;
  80.     CWnd *pWnd;
  81.     CRect rect;
  82.  
  83.     // Setup the tooltip control for tooltips with the static controls
  84.     for (int nIndex = ID_TOOLBARSTYLE; nIndex <= ID_TBSTYLETOOLTIPS2; nIndex++)
  85.     {
  86.         cstrToolTip.LoadString(nIndex);
  87.  
  88.         VERIFY(pWnd = GetDlgItem(nIndex));
  89.  
  90.         pWnd->GetWindowRect(&rect);
  91.         ScreenToClient(&rect);
  92.  
  93.         m_ToolTip.AddTool(this, (LPCTSTR)cstrToolTip, &rect, nIndex);
  94.     }
  95.  
  96.     m_ToolTip.Activate(TRUE);
  97.  
  98.     return TRUE;  // return TRUE unless you set the focus to a control
  99.                   // EXCEPTION: OCX Property Pages should return FALSE
  100. }
  101.  
  102. void CToolBarCtrlPage::ChangeCtrlStyle(long lStyle, BOOL bSetStyle)
  103. {
  104.     long    lStyleOld;
  105.     CRect   rect;
  106.  
  107.     m_StandardBar.GetWindowRect(&rect);
  108.     lStyleOld = GetWindowLong( m_StandardBar.GetSafeHwnd(), GWL_STYLE );
  109.     if ( bSetStyle )
  110.         lStyleOld |= lStyle;
  111.     else
  112.         lStyleOld &= ~lStyle;
  113.  
  114.     SetWindowLong( m_StandardBar.GetSafeHwnd(), GWL_STYLE, lStyleOld );
  115.     m_StandardBar.InvalidateRect(&rect);
  116. }
  117.  
  118. void CToolBarCtrlPage::OnAltdrag()
  119. {
  120.     UpdateData();
  121.     ChangeCtrlStyle(TBSTYLE_ALTDRAG, m_bAltDrag);
  122. }
  123.  
  124.  
  125. LRESULT CToolBarCtrlPage::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  126. {
  127.     // We need to pass these messages to the tooltip for it to determine
  128.     // the position of the mouse
  129.  
  130.     switch (message)
  131.     {
  132.     case WM_LBUTTONDOWN:
  133.     case WM_RBUTTONDOWN:
  134.     case WM_MBUTTONDOWN:
  135.     case WM_LBUTTONUP:
  136.     case WM_MBUTTONUP:
  137.     case WM_RBUTTONUP:
  138.     case WM_MOUSEMOVE:
  139.         {
  140.             MSG msg;
  141.             msg.hwnd = m_hWnd;
  142.             msg.message = message;
  143.             msg.wParam = wParam;
  144.             msg.lParam = lParam;
  145.  
  146.             m_ToolTip.RelayEvent(&msg);
  147.         }
  148.     }
  149.  
  150.     return CPropertyPage::WindowProc(message,wParam,lParam);
  151. }
  152.