// chgDlg.cpp : implementation file // #include "stdafx.h" #include "dimens.h" #include "dimensDc.h" #include "dimensVw.h" #include "chgDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // ChangeResDlg dialog ChangeResDlg::ChangeResDlg(CWnd* pParent , pDIMENSION pDim , L_INT nDimCount) : CDialog(ChangeResDlg::IDD, pParent) { //{{AFX_DATA_INIT(ChangeResDlg) //}}AFX_DATA_INIT m_pDim=pDim; m_nDimCount=nDimCount; } void ChangeResDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(ChangeResDlg) DDX_Control(pDX, IDC_COMBO2, m_ctrlWidthC); DDX_Control(pDX, IDC_COMBO1, m_ctrlHeightC); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(ChangeResDlg, CDialog) //{{AFX_MSG_MAP(ChangeResDlg) ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1) ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ChangeResDlg message handlers void ChangeResDlg::OnOK() { // TODO: Add extra validation here UpdateData(); m_nIndexWidth = m_ctrlWidthC.GetCurSel(); m_ulWidth = m_pDim[m_nIndexWidth].nWidth; m_ulHeight = m_pDim[m_nIndexWidth].nHeight; CDialog::OnOK(); } BOOL ChangeResDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here for(int iIdx = 0; iIdx < m_nDimCount; iIdx++) { m_ctrlWidthC.AddString(IntToText(m_pDim[iIdx].nWidth)); m_ctrlHeightC.AddString(IntToText(m_pDim[iIdx].nHeight)); } m_ctrlWidthC.SetCurSel(0) ; m_ctrlHeightC.SetCurSel(0) ; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } CString ChangeResDlg::IntToText(L_INT iInteger) { L_CHAR szbuffer[10]; memset(szbuffer, 0, sizeof(szbuffer)); _itoa(iInteger, szbuffer, 10); CString strFromInt(szbuffer); return strFromInt; } void ChangeResDlg::OnSelchangeCombo1() { // TODO: Add your control notification handler code here m_ctrlWidthC.SetCurSel(m_ctrlHeightC.GetCurSel()); } void ChangeResDlg::OnSelchangeCombo2() { // TODO: Add your control notification handler code here m_ctrlHeightC.SetCurSel(m_ctrlWidthC.GetCurSel()); }