Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / WTL

Form Designer

26 Jul 2021CPOL24 min read 351.2K   82.5K   230  
Component for adding scriptable forms capabilities to an application.
// FormViewerItemDetails.cpp : Implementation of CFormViewerItemDetails
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FormViewerItemDetails.h"

/////////////////////////////////////////////////////////////////////////////
// CFormViewerItemDetails

CFormViewerItemDetails::CFormViewerItemDetails()
{
	// initialise everything
}

CFormViewerItemDetails::~CFormViewerItemDetails()
{
	// clean up
}

HRESULT CFormViewerItemDetails::FinalConstruct()
{
	return S_OK;
}

void CFormViewerItemDetails::FinalRelease()
{
}

// gets the item position
#define GET_ITEM_POSITION									\
	long Left=0, Top=0, Width=0, Height=0, TabNumber=0;		\
	if(!SUCCEEDED(m_spFormViewer2->GetItemPosition(			\
		m_spItem,&Left,&Top,&Width,&Height,&TabNumber)))	\
	{														\
		throw CHResult(E_FAIL);								\
	}

STDMETHODIMP CFormViewerItemDetails::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 CFormViewerItemDetails::get_ClassId(BSTR *pVal)
{
IMP_BEGIN
	// check parameters
	if(pVal==NULL)
	{
		throw CHResult(E_POINTER);
	}
	// get the item class id
	if(!SUCCEEDED(m_spFormViewer2->GetItemClassId(m_spItem,pVal)))
	{
		throw CHResult(E_FAIL);
	}
IMP_END
	return RetVal;
}

STDMETHODIMP CFormViewerItemDetails::get_Name(BSTR *pVal)
{
IMP_BEGIN
	// check parameters
	if(pVal==NULL)
	{
		throw CHResult(E_POINTER);
	}
	// get the item name
	if(!SUCCEEDED(m_spFormViewer2->GetItemName(m_spItem,pVal)))
	{
		throw CHResult(E_FAIL);
	}
IMP_END
	return RetVal;
}

STDMETHODIMP CFormViewerItemDetails::get_Tag(BSTR *pVal)
{
IMP_BEGIN
	// check parameters
	if(pVal==NULL)
	{
		throw CHResult(E_POINTER);
	}
	// get the item tag
	if(!SUCCEEDED(m_spFormViewer2->GetItemTag(m_spItem,pVal)))
	{
		throw CHResult(E_FAIL);
	}
IMP_END
	return RetVal;
}

STDMETHODIMP CFormViewerItemDetails::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 CFormViewerItemDetails::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 CFormViewerItemDetails::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 CFormViewerItemDetails::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 CFormViewerItemDetails::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;
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions