// FormEditorItemDetails.cpp : Implementation of CFormEditorItemDetails
//
// Author : David Shepherd
// Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FormEditorItemDetails.h"
/////////////////////////////////////////////////////////////////////////////
// CFormEditorItemDetails
CFormEditorItemDetails::CFormEditorItemDetails()
{
// initialise everything
}
CFormEditorItemDetails::~CFormEditorItemDetails()
{
// clean up
}
HRESULT CFormEditorItemDetails::FinalConstruct()
{
return S_OK;
}
void CFormEditorItemDetails::FinalRelease()
{
}
// gets the item position
#define GET_ITEM_POSITION \
long Left=0, Top=0, Width=0, Height=0, TabNumber=0; \
if(!SUCCEEDED(m_spFormEditor2->GetItemPosition( \
m_spItem,&Left,&Top,&Width,&Height,&TabNumber))) \
{ \
throw CHResult(E_FAIL); \
}
// sets the item position
#define SET_ITEM_POSITION(left,top,width,height,tabnumber) \
if(!SUCCEEDED(m_spFormEditor2->SetItemPosition( \
m_spItem,left,top,width,height,tabnumber))) \
{ \
throw CHResult(E_FAIL); \
}
STDMETHODIMP CFormEditorItemDetails::get_Item(IDispatch **ppDispatch)
{
IMP_BEGIN
// check parameters
if(ppDispatch==NULL)
{
throw CHResult(E_POINTER);
}
// get the item
*ppDispatch=CComPtr<IDispatch>(m_spItem).Detach();
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_ClassId(BSTR *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item class id
if(!SUCCEEDED(m_spFormEditor2->GetItemClassId(m_spItem,pVal)))
{
throw CHResult(E_FAIL);
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Name(BSTR *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item name
if(!SUCCEEDED(m_spFormEditor2->GetItemName(m_spItem,pVal)))
{
throw CHResult(E_FAIL);
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_Name(BSTR newVal)
{
IMP_BEGIN
// set the item name
if(!SUCCEEDED(m_spFormEditor2->SetItemName(m_spItem,newVal)))
{
throw CHResult(E_FAIL);
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Tag(BSTR *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item tag
if(!SUCCEEDED(m_spFormEditor2->GetItemTag(m_spItem,pVal)))
{
throw CHResult(E_FAIL);
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_Tag(BSTR newVal)
{
IMP_BEGIN
// set the item tag
if(!SUCCEEDED(m_spFormEditor2->SetItemTag(m_spItem,newVal)))
{
throw CHResult(E_FAIL);
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Left(long *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item left position
GET_ITEM_POSITION;
*pVal=Left;
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_Left(long newVal)
{
IMP_BEGIN
// set the item left position
GET_ITEM_POSITION;
SET_ITEM_POSITION(newVal,Top,Width,Height,TabNumber);
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Top(long *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item top position
GET_ITEM_POSITION;
*pVal=Top;
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_Top(long newVal)
{
IMP_BEGIN
// set the item top position
GET_ITEM_POSITION;
SET_ITEM_POSITION(Left,newVal,Width,Height,TabNumber);
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Width(long *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item width
GET_ITEM_POSITION;
*pVal=Width;
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_Width(long newVal)
{
IMP_BEGIN
// set the item width
GET_ITEM_POSITION;
SET_ITEM_POSITION(Left,Top,newVal,Height,TabNumber);
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Height(long *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item height
GET_ITEM_POSITION;
*pVal=Height;
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_Height(long newVal)
{
IMP_BEGIN
// set the item height
GET_ITEM_POSITION;
SET_ITEM_POSITION(Left,Top,Width,newVal,TabNumber);
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Selected(VARIANT_BOOL *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// determine if the item is selected
if(!SUCCEEDED(m_spFormEditor2->IsItemSelected(m_spItem,pVal)))
{
throw CHResult(E_FAIL);
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_Selected(VARIANT_BOOL newVal)
{
IMP_BEGIN
// if the item should be selected
if(newVal)
{
// select the item
if(!SUCCEEDED(m_spFormEditor2->SelectItem(m_spItem,VARIANT_TRUE)))
{
throw CHResult(E_FAIL);
}
}
else // the item should not be selected
{
// unselect the item
if(!SUCCEEDED(m_spFormEditor2->UnselectItem(m_spItem)))
{
throw CHResult(E_FAIL);
}
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_Deleted(VARIANT_BOOL *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// determine if the item is deleted
if(!SUCCEEDED(m_spFormEditor2->IsItemDeleted(m_spItem,pVal)))
{
throw CHResult(E_FAIL);
}
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::get_TabNumber(long *pVal)
{
IMP_BEGIN
// check parameters
if(pVal==NULL)
{
throw CHResult(E_POINTER);
}
// get the item tab number
GET_ITEM_POSITION;
*pVal=TabNumber;
IMP_END
return RetVal;
}
STDMETHODIMP CFormEditorItemDetails::put_TabNumber(long newVal)
{
IMP_BEGIN
// set the item tab number
GET_ITEM_POSITION;
SET_ITEM_POSITION(Left,Top,Width,Height,newVal);
IMP_END
return RetVal;
}