|
// PropPageFormEditor.cpp : Implementation of CPropPageFormEditor
//
// Author : David Shepherd
// Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DDForms.h"
#include "PropPageFormEditor.h"
/////////////////////////////////////////////////////////////////////////////
// CPropPageFormEditor
CPropPageFormEditor::CPropPageFormEditor()
{
// initialise everything
m_dwTitleID=IDS_TITLEPropPageFormEditor;
m_dwHelpFileID=IDS_HELPFILEPropPageFormEditor;
m_dwDocStringID=IDS_DOCSTRINGPropPageFormEditor;
m_BorderVisible=FALSE;
m_FormWidth=0;
m_FormHeight=0;
m_GridVisible=FALSE;
m_GridWidth=0;
m_GridHeight=0;
}
STDMETHODIMP CPropPageFormEditor::Apply()
{
IMP_BEGIN
// check there is only a single associated object
if(m_nObjects!=1)
{
throw std::exception();
}
// get the IFormEditor interface for the associated object
if(m_ppUnk[0]==NULL)
{
throw std::exception();
}
CComQIPtr<IFormEditor> spFormEditor(m_ppUnk[0]);
if(spFormEditor==NULL)
{
throw std::exception();
}
// set the property values
(void)DoDataExchange(TRUE);
// border
if(!SUCCEEDED(spFormEditor->
put_BorderVisible(B2VB(m_BorderVisible))))
{
throw std::exception();
}
// form dimensions
if(!SUCCEEDED(spFormEditor->put_FormWidth(m_FormWidth)))
{
throw std::exception();
}
if(!SUCCEEDED(spFormEditor->put_FormHeight(m_FormHeight)))
{
throw std::exception();
}
// grid
if(!SUCCEEDED(spFormEditor->
put_GridVisible(B2VB(m_GridVisible))))
{
throw std::exception();
}
// grid dimensions
if(!SUCCEEDED(spFormEditor->put_GridWidth(m_GridWidth)))
{
throw std::exception();
}
if(!SUCCEEDED(spFormEditor->put_GridHeight(m_GridHeight)))
{
throw std::exception();
}
// reset the modified flag
SetDirty(FALSE);
IMP_END
return RetVal;
}
LRESULT CPropPageFormEditor::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// wrap all dialog controls
m_ctrlBorderVisible.Attach(GetDlgItem(IDC_BORDER));
m_ctrlFormWidth.Attach(GetDlgItem(IDC_FORM_WIDTH));
m_ctrlFormWidthSpin.Attach(GetDlgItem(IDC_FORM_WIDTH_SPIN));
m_ctrlFormHeight.Attach(GetDlgItem(IDC_FORM_HEIGHT));
m_ctrlFormHeightSpin.Attach(GetDlgItem(IDC_FORM_HEIGHT_SPIN));
m_ctrlGridVisible.Attach(GetDlgItem(IDC_GRID));
m_ctrlGridWidth.Attach(GetDlgItem(IDC_GRID_WIDTH));
m_ctrlGridWidthSpin.Attach(GetDlgItem(IDC_GRID_WIDTH_SPIN));
m_ctrlGridHeight.Attach(GetDlgItem(IDC_GRID_HEIGHT));
m_ctrlGridHeightSpin.Attach(GetDlgItem(IDC_GRID_HEIGHT_SPIN));
// todo : add error checking here if GetDlgItem() fails
// check there is only a single associated object
if(m_nObjects!=1)
{
// disable all controls
(void)m_ctrlBorderVisible.EnableWindow(FALSE);
(void)m_ctrlFormWidth.EnableWindow(FALSE);
(void)m_ctrlFormWidthSpin.EnableWindow(FALSE);
(void)m_ctrlFormHeight.EnableWindow(FALSE);
(void)m_ctrlFormHeightSpin.EnableWindow(FALSE);
(void)m_ctrlGridVisible.EnableWindow(FALSE);
(void)m_ctrlGridWidth.EnableWindow(FALSE);
(void)m_ctrlGridWidthSpin.EnableWindow(FALSE);
(void)m_ctrlGridHeight.EnableWindow(FALSE);
(void)m_ctrlGridHeightSpin.EnableWindow(FALSE);
return 0;
}
// get the IFormEditor interface for the associated object
if(m_ppUnk[0]==NULL)
{
return 0;
}
CComQIPtr<IFormEditor> spFormEditor(m_ppUnk[0]);
if(spFormEditor==NULL)
{
return 0;
}
// get the property values
// border
VARIANT_BOOL vb=VARIANT_FALSE;
(void)spFormEditor->get_BorderVisible(&vb);
m_BorderVisible=VB2B(vb);
// form dimensions
(void)spFormEditor->get_FormWidth(&m_FormWidth);
(void)spFormEditor->get_FormHeight(&m_FormHeight);
// grid
(void)spFormEditor->get_GridVisible(&vb);
m_GridVisible=VB2B(vb);
// grid dimensions
(void)spFormEditor->get_GridWidth(&m_GridWidth);
(void)spFormEditor->get_GridHeight(&m_GridHeight);
// initialise the controls
(void)DoDataExchange(FALSE);
// set the form dimensions spin control range
m_ctrlFormWidthSpin.SetRange(0,SHRT_MAX);
m_ctrlFormHeightSpin.SetRange(0,SHRT_MAX);
// set the grid dimensions spin control range
m_ctrlGridWidthSpin.SetRange(0,SHRT_MAX);
m_ctrlGridHeightSpin.SetRange(0,SHRT_MAX);
// todo : set valid spin control ranges
// reset the modified flag
SetDirty(FALSE);
return 0;
}
LRESULT CPropPageFormEditor::OnClickedBorder(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
// set the modified flag
SetDirty(TRUE);
return 0;
}
LRESULT CPropPageFormEditor::OnChangeFormWidth(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
// set the modified flag
SetDirty(TRUE);
return 0;
}
LRESULT CPropPageFormEditor::OnChangeFormHeight(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
// set the modified flag
SetDirty(TRUE);
return 0;
}
LRESULT CPropPageFormEditor::OnClickedGrid(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
// set the modified flag
SetDirty(TRUE);
return 0;
}
LRESULT CPropPageFormEditor::OnChangeGridWidth(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
// set the modified flag
SetDirty(TRUE);
return 0;
}
LRESULT CPropPageFormEditor::OnChangeGridHeight(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
// set the modified flag
SetDirty(TRUE);
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.