home *** CD-ROM | disk | FTP | other *** search
- // Dialogs.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "modal.h"
-
- #include "Dialogs.h"
- #include "ModalDoc.h"
-
- #include "XtraFunc.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CColorListDlg dialog
-
- CColorListDlg::CColorListDlg(COLORREF clr, CWnd* pParent /*=NULL*/)
- : CDialog(CColorListDlg::IDD, pParent),
- m_colorref(clr)
- {
- //{{AFX_DATA_INIT(CColorListDlg)
- m_phrase = _T("");
- m_color = -1;
- //}}AFX_DATA_INIT
- }
-
- void CColorListDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CColorListDlg)
- DDX_Control(pDX, IDC_COLOR_LIST, m_colorListBox);
- DDX_Text(pDX, IDC_PHRASE, m_phrase);
- DDX_LBIndex(pDX, IDC_COLOR_LIST, m_color);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CColorListDlg, CDialog)
- //{{AFX_MSG_MAP(CColorListDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CColorListDlg message handlers
- BOOL CColorListDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- m_colorListBox.AddString("Black");
- m_colorListBox.AddString("Red");
- m_colorListBox.AddString("Green");
- m_colorListBox.AddString("Blue");
-
- // In order to set the current selection in the list box, this
- // dialog box needs to know the current color. The easiest way
- // to communicate this information to the dialog box is to pass
- // in it via the constructor, and store it in the member variable
- // m_colorref. An alternative would be to obtain a pointer to the
- // active document and then call the GetColor function from here.
- // The method chosen is simpler.
- m_colorListBox.SetCurSel(RgbToInt(m_colorref));
-
- // These are the steps needed to precisely set the height
- // of the list box.
- CRect rect;
- int itemHeight;
- m_colorListBox.GetClientRect(&rect);
- m_colorListBox.MapWindowPoints(this, & rect);
- itemHeight = m_colorListBox.GetItemHeight(0) + 1;
- rect.bottom = rect.top + 4 * itemHeight;
- m_colorListBox.MoveWindow(&rect);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CColorPhraseDlg dialog
- CColorPhraseDlg::CColorPhraseDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CColorPhraseDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CColorPhraseDlg)
- m_color = -1;
- m_phrase = _T("");
- //}}AFX_DATA_INIT
- }
-
- void CColorPhraseDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CColorPhraseDlg)
- DDX_Radio(pDX, IDC_BLACK, m_color);
- DDX_Text(pDX, IDC_PHRASE, m_phrase);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CColorPhraseDlg, CDialog)
- //{{AFX_MSG_MAP(CColorPhraseDlg)
- // NOTE: the ClassWizard will add message map macros here
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CColorPhraseDlg message handlers
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CListWithItemDataDlg dialog
- CListWithItemDataDlg::CListWithItemDataDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CListWithItemDataDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CListWithItemDataDlg)
- m_phrase = _T("");
- //}}AFX_DATA_INIT
- }
-
- void CListWithItemDataDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CListWithItemDataDlg)
- DDX_Text(pDX, IDC_PHRASE, m_phrase);
- //}}AFX_DATA_MAP
-
- // If you want the list box's ItemData field available
- // in the dialog class, you've got to do the transfer
- // yourself
- if (pDX->m_bSaveAndValidate)
- {
- CListBox * clb = (CListBox *)GetDlgItem(IDC_COLOR_LIST);
- m_color = clb->GetItemData(clb->GetCurSel());
- }
- }
-
- BEGIN_MESSAGE_MAP(CListWithItemDataDlg, CDialog)
- //{{AFX_MSG_MAP(CListWithItemDataDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CListWithItemDataDlg message handlers
-
- BOOL CListWithItemDataDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // Since no Listbox member exists in the dialog class
- // we'll access the list box via a pointer obtained
- // from GetDlgItem.
- CListBox * clb = (CListBox *)GetDlgItem(IDC_COLOR_LIST);
-
- // In this dialog box, the string is for appearance
- // only. The real value of the user's selection will be
- // the 32-bit value that is stored via SetItemData.
- // If there were move than 4 entries in the list box,
- // this section of code coudl be improved with some
- // arrays and a for loop.
- clb->AddString("Black");
- clb->SetItemData(0, BLACK);
- clb->AddString("Red");
- clb->SetItemData(1, RED);
- clb->AddString("Green");
- clb->SetItemData(2, GREEN);
- clb->AddString("Blue");
- clb->SetItemData(3, BLUE);
-
- // Set the initial selection in the list box.
- clb->SetCurSel(RgbToInt(m_color));
-
- // Size the list box.
- CRect rect;
- int itemHeight;
- clb->GetClientRect(&rect);
- clb->MapWindowPoints(this, & rect);
- itemHeight = clb->GetItemHeight(0) + 1;
- rect.bottom = rect.top + 4 * itemHeight;
- clb->MoveWindow(&rect);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-