// ConPropDlg.cpp : implementation file // #include "stdafx.h" #include "MSVC5conview.h" #include "ConPropDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CConPropDlg dialog CConPropDlg::CConPropDlg(CWnd* pParent /*=NULL*/) : CDialog(CConPropDlg::IDD, pParent) { //{{AFX_DATA_INIT(CConPropDlg) m_bShowFreeze = FALSE; m_bMaintainSize = FALSE; m_uRows = 0; m_uColumns = 0; //}}AFX_DATA_INIT } void CConPropDlg::SetConPropIcons() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_DefultCursor.SetIcon(m_pConViewerProps->GetDefaultCursor() ? pTheApp->IPictureDispTohIcon(m_pConViewerProps->GetDefaultCursor()):LoadCursor(NULL, IDC_ARROW)); m_HorzCursor.SetIcon(m_pConViewerProps->GetHorizontalResizeCursor() ? pTheApp->IPictureDispTohIcon(m_pConViewerProps->GetHorizontalResizeCursor()):LoadCursor(NULL, IDC_SIZEWE )); m_VertCursor.SetIcon(m_pConViewerProps->GetVerticalResizeCursor() ? pTheApp->IPictureDispTohIcon(m_pConViewerProps->GetVerticalResizeCursor()):LoadCursor(NULL, IDC_SIZENS )); m_AllCursor.SetIcon(m_pConViewerProps->GetBothResizeCursor() ? pTheApp->IPictureDispTohIcon(m_pConViewerProps->GetBothResizeCursor()):LoadCursor(NULL, IDC_SIZEALL)); } void CConPropDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CConPropDlg) DDX_Control(pDX, IDC_CONPROP_COLS_EDT, m_edtColumns); DDX_Control(pDX, IDC_CONPROP_ROWS_EDT, m_edtRow); DDX_Control(pDX, IDC_CONPROP_ALL_BTN, m_AllCursor); DDX_Control(pDX, IDC_CONPROP_VERT_BTN, m_VertCursor); DDX_Control(pDX, IDC_CONPROP_HORZ_BTN, m_HorzCursor); DDX_Control(pDX, IDC_CONPROP_DEF_BTN, m_DefultCursor); DDX_Control(pDX, IDC_CONPROP_BORDERSTYLE_COM, m_cmbBorderStyle); DDX_Control(pDX, IDC_CONPROP_RULERSTYLE_COM, m_cmbRulerStyle); DDX_Control(pDX, IDC_CONPROP_TEXTQUALITY_COM, m_cmbTextQulity); DDX_Check(pDX, IDC_CONPROP_FRZ_CHK, m_bShowFreeze); DDX_Check(pDX, IDC_CONPROP_MNTNSIZE_CHK, m_bMaintainSize); DDX_Text(pDX, IDC_CONPROP_ROWS_EDT, m_uRows); DDX_Text(pDX, IDC_CONPROP_COLS_EDT, m_uColumns); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CConPropDlg, CDialog) //{{AFX_MSG_MAP(CConPropDlg) ON_BN_CLICKED(IDC_CONPROP_EMPTY_BTN, OnConpropEmptyBtn) ON_BN_CLICKED(IDC_CONPROP_TEXT_BTN, OnConpropTextBtn) ON_BN_CLICKED(IDC_CONPROP_SHADOW_BTN, OnConpropShadowBtn) ON_BN_CLICKED(IDC_CONPROP_ACTIVEBORDER_BTN, OnConpropActiveborderBtn) ON_BN_CLICKED(IDC_CONPROP_ACTIVESUBCELLBORDER_BTN, OnConpropActivesubcellborderBtn) ON_BN_CLICKED(IDC_CONPROP_BACKGROUND_BTN, OnConpropBackgroundBtn) ON_BN_CLICKED(IDC_CONPROP_RULERIN_BTN, OnConpropRulerinBtn) ON_BN_CLICKED(IDC_CONPROP_RULEROUT_BTN, OnConpropRuleroutBtn) ON_BN_CLICKED(IDC_CONPROP_NONACTIVE_BTN, OnConpropNonactiveBtn) ON_WM_PAINT() ON_WM_DRAWITEM() ON_BN_CLICKED(IDC_CONPROP_DEF_BTN, OnConpropDefBtn) ON_BN_CLICKED(IDC_CONPROP_VERT_BTN, OnConpropVertBtn) ON_BN_CLICKED(IDC_CONPROP_HORZ_BTN, OnConpropHorzBtn) ON_BN_CLICKED(IDC_CONPROP_ALL_BTN, OnConpropAllBtn) ON_BN_CLICKED(IDAPPLY, OnApply) ON_BN_CLICKED(IDREST, OnRest) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CConPropDlg message handlers BOOL CConPropDlg::OnInitDialog() { CDialog::OnInitDialog(); m_pConViewerProps =NULL; HRESULT hr = CoCreateInstance( CLSID_LEADContainerViewerProperties, NULL, CLSCTX_ALL, IID_ILEADContainerViewerProperties, (void**)&m_pConViewerProps ); m_pConViewerProps->IncludedParameters = CONVIEW_CIP_ALL; m_pView->m_ConView.GetContainerProperties(m_pConViewerProps, 0); m_uRows = m_pConViewerProps->RowCount; m_uColumns = m_pConViewerProps->ColumnCount; m_cmbTextQulity.AddString(TEXT("Default quality")); m_cmbTextQulity.AddString(TEXT("Draft quality")); m_cmbTextQulity.AddString(TEXT("Proof quality")); m_cmbTextQulity.AddString(TEXT("Force draft")); m_cmbTextQulity.AddString(TEXT("Force Anti-aliasing")); m_cmbTextQulity.SetCurSel(m_pConViewerProps->TextQuality); m_cmbBorderStyle.AddString(TEXT("Solid")); m_cmbBorderStyle.AddString(TEXT("Dashed")); m_cmbBorderStyle.AddString(TEXT("Dotted")); m_cmbBorderStyle.AddString(TEXT("Dash-Dot")); m_cmbBorderStyle.AddString(TEXT("Dash-Dot-Dot")); m_cmbBorderStyle.SetCurSel(m_pConViewerProps->CellBorderStyle); m_cmbRulerStyle.AddString(TEXT("Inverted")); m_cmbRulerStyle.AddString(TEXT("Bordered")); m_cmbRulerStyle.SetCurSel(m_pConViewerProps->RulerStyle); m_bShowFreeze = m_pConViewerProps->ShowFreezeText ? TRUE : FALSE; m_bMaintainSize = m_pConViewerProps->CellMaintenance ? FALSE : TRUE ; m_edtRow.SetNumericEditBox(1, 4, 1, 0, 0); m_edtColumns.SetNumericEditBox(1, 8, 1, 0, 0); SetConPropIcons(); UpdateData(FALSE); RedrawWindow(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CConPropDlg::OnConpropEmptyBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->EmptyCellBackGroundColor = pTheApp->ShowColorDlg (m_pConViewerProps->EmptyCellBackGroundColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropTextBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->TextColor = pTheApp->ShowColorDlg (m_pConViewerProps->TextColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropShadowBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->ShadowColor = pTheApp->ShowColorDlg (m_pConViewerProps->ShadowColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropActiveborderBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->ActiveCellBorderColor = pTheApp->ShowColorDlg (m_pConViewerProps->ActiveCellBorderColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropActivesubcellborderBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->ActiveSubCellBorderColor = pTheApp->ShowColorDlg (m_pConViewerProps->ActiveSubCellBorderColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropBackgroundBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->BackGroundColor = pTheApp->ShowColorDlg (m_pConViewerProps->BackGroundColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropRulerinBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->RulerInColor = pTheApp->ShowColorDlg (m_pConViewerProps->RulerInColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropRuleroutBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->RulerOutColor = pTheApp->ShowColorDlg (m_pConViewerProps->RulerOutColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnConpropNonactiveBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->NonActiveCellBorderColor = pTheApp->ShowColorDlg (m_pConViewerProps->NonActiveCellBorderColor, (this->GetSafeHwnd())); RedrawWindow(); } void CConPropDlg::OnPaint() { CPaintDC dc(this); // device context for painting CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); pTheApp->RepaintButton(this, IDC_CONPROP_EMPTY_TXT, m_pConViewerProps->EmptyCellBackGroundColor); pTheApp->RepaintButton(this, IDC_CONPROP_TEXT_TXT, m_pConViewerProps->TextColor); pTheApp->RepaintButton(this, IDC_CONPROP_SHADOW_TXT, m_pConViewerProps->ShadowColor); pTheApp->RepaintButton(this, IDC_CONPROP_ACTIVEBORDER_TXT, m_pConViewerProps->ActiveCellBorderColor); pTheApp->RepaintButton(this, IDC_CONPROP_ACTIVESUBCELLBORDER_TXT, m_pConViewerProps->ActiveSubCellBorderColor); pTheApp->RepaintButton(this, IDC_CONPROP_BACKGROUND_TXT, m_pConViewerProps->BackGroundColor); pTheApp->RepaintButton(this, IDC_CONPROP_RULERIN_TXT, m_pConViewerProps->RulerInColor); pTheApp->RepaintButton(this, IDC_CONPROP_RULEROUT_TXT, m_pConViewerProps->RulerOutColor); pTheApp->RepaintButton(this, IDC_CONPROP_NONACTIVE_TXT, m_pConViewerProps->NonActiveCellBorderColor); // Do not call CDialog::OnPaint() for painting messages } void CConPropDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); pTheApp->RepaintButton(this, IDC_CONPROP_EMPTY_TXT, m_pConViewerProps->EmptyCellBackGroundColor); pTheApp->RepaintButton(this, IDC_CONPROP_TEXT_TXT, m_pConViewerProps->TextColor); pTheApp->RepaintButton(this, IDC_CONPROP_SHADOW_TXT, m_pConViewerProps->ShadowColor); pTheApp->RepaintButton(this, IDC_CONPROP_ACTIVEBORDER_TXT, m_pConViewerProps->ActiveCellBorderColor); pTheApp->RepaintButton(this, IDC_CONPROP_ACTIVESUBCELLBORDER_TXT, m_pConViewerProps->ActiveSubCellBorderColor); pTheApp->RepaintButton(this, IDC_CONPROP_BACKGROUND_TXT, m_pConViewerProps->BackGroundColor); pTheApp->RepaintButton(this, IDC_CONPROP_RULERIN_TXT, m_pConViewerProps->RulerInColor); pTheApp->RepaintButton(this, IDC_CONPROP_RULEROUT_TXT, m_pConViewerProps->RulerOutColor); pTheApp->RepaintButton(this, IDC_CONPROP_NONACTIVE_TXT, m_pConViewerProps->NonActiveCellBorderColor); CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); } void CConPropDlg::OnConpropDefBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); if(pTheApp->GetIconFileName(m_FileName, (this->GetActiveWindow())->m_hWnd)) { m_pConViewerProps->PutDefaultCursor(pTheApp->hIconToIPictureDisp(LoadCursorFromFile(m_FileName))); SetConPropIcons(); } } void CConPropDlg::OnConpropHorzBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); if(pTheApp->GetIconFileName(m_FileName, (this->GetActiveWindow())->m_hWnd)) { m_pConViewerProps->PutHorizontalResizeCursor(pTheApp->hIconToIPictureDisp(LoadCursorFromFile(m_FileName))); SetConPropIcons(); } } void CConPropDlg::OnConpropVertBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); if(pTheApp->GetIconFileName(m_FileName, (this->GetActiveWindow())->m_hWnd)) { m_pConViewerProps->PutVerticalResizeCursor(pTheApp->hIconToIPictureDisp(LoadCursorFromFile(m_FileName))); SetConPropIcons(); } } void CConPropDlg::OnConpropAllBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); if(pTheApp->GetIconFileName(m_FileName, (this->GetActiveWindow())->m_hWnd)) { m_pConViewerProps->PutBothResizeCursor(pTheApp->hIconToIPictureDisp(LoadCursorFromFile(m_FileName))); SetConPropIcons(); } } void CConPropDlg::ApplyAll() { UpdateData(TRUE); m_pConViewerProps->PutRowCount(m_uRows); m_pConViewerProps->PutColumnCount(m_uColumns); m_pConViewerProps->PutCellMaintenance((CellsMaintenanceConstants)!m_bMaintainSize); m_pConViewerProps->PutShowFreezeText(m_bShowFreeze); m_pConViewerProps->PutCellBorderStyle((BorderStyleConstants)m_cmbBorderStyle.GetCurSel()); m_pConViewerProps->PutTextQuality((CellsTextQualityConstants)m_cmbTextQulity.GetCurSel()); m_pConViewerProps->PutRulerStyle((RulerStyleConstants)m_cmbRulerStyle.GetCurSel()); m_pView->m_ConView.SetContainerProperties(m_pConViewerProps, 0); } void CConPropDlg::OnApply() { ApplyAll(); } void CConPropDlg::OnOK() { ApplyAll(); CDialog::OnOK(); } void CConPropDlg::OnRest() { m_pConViewerProps->IncludedParameters = CONVIEW_CIP_ALL; CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); m_pConViewerProps->PutDefaultCursor(pTheApp->hIconToIPictureDisp(LoadCursor(NULL, IDC_ARROW))); m_pConViewerProps->PutHorizontalResizeCursor(pTheApp->hIconToIPictureDisp(LoadCursor(NULL, IDC_SIZEWE))); m_pConViewerProps->PutVerticalResizeCursor (pTheApp->hIconToIPictureDisp(LoadCursor(NULL, IDC_SIZENS))); m_pConViewerProps->PutBothResizeCursor (pTheApp->hIconToIPictureDisp(LoadCursor(NULL, IDC_SIZEALL))); m_cmbTextQulity.SetCurSel (0); m_cmbBorderStyle.SetCurSel(2); m_cmbRulerStyle.SetCurSel (0); m_pConViewerProps->ActiveCellBorderColor = RGB(255, 192, 0); m_pConViewerProps->ActiveSubCellBorderColor = RGB(255, 255, 0); m_pConViewerProps->BackGroundColor = RGB(0, 0, 0); m_pConViewerProps->EmptyCellBackGroundColor = RGB(0, 0, 0); m_pConViewerProps->NonActiveCellBorderColor = RGB(255, 255, 255); m_pConViewerProps->RulerInColor = RGB(255, 255, 255); m_pConViewerProps->RulerOutColor = RGB(0, 0, 255); m_pConViewerProps->TextColor = RGB(255, 255, 255); m_pConViewerProps->ShadowColor = RGB(0, 0, 0); m_uRows = 1; m_uColumns = 2; m_bMaintainSize = CONVIEW_CELLSMAINTENANCE_POS; m_bShowFreeze = TRUE; SetConPropIcons(); UpdateData(FALSE); RedrawWindow(); ApplyAll(); }