|
// PropPageExtended.cpp : Implementation of CPropPageExtended
//
// Author : David Shepherd
// Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DDForms.h"
#include "PropPageExtended.h"
#include "FormEditor.h"
/////////////////////////////////////////////////////////////////////////////
// CPropPageExtended
CPropPageExtended::CPropPageExtended()
{
// initialise everything
m_dwTitleID=IDS_TITLEPropPageExtended;
m_dwHelpFileID=IDS_HELPFILEPropPageExtended;
m_dwDocStringID=IDS_DOCSTRINGPropPageExtended;
}
CWindow CPropPageExtended::GetFormEditor()
{
// get the associated object IOleObject interface
if(m_nObjects==0)
{
return NULL;
}
if(m_ppUnk[0]==NULL)
{
return NULL;
}
CComQIPtr<IOleObject> spOleObject(m_ppUnk[0]);
if(spOleObject==NULL)
{
return NULL;
}
// get the container IOleInPlaceSite interface
CComPtr<IOleClientSite> spOleClientSite;
if(!SUCCEEDED(spOleObject->GetClientSite(&spOleClientSite)))
{
return NULL;
}
CComQIPtr<IOleInPlaceSite> spOleInPlaceSite(spOleClientSite);
if(spOleInPlaceSite==NULL)
{
return NULL;
}
// get the container window
CWindow Wnd;
if(!SUCCEEDED(spOleInPlaceSite->GetWindow(&Wnd.m_hWnd)))
{
return NULL;
}
ATLASSERT(Wnd.IsWindow());
// get the form editor window
Wnd=Wnd.GetParent(); // editable form
ATLASSERT(Wnd.IsWindow());
Wnd=Wnd.GetParent(); // form editor
ATLASSERT(Wnd.IsWindow());
// todo : add checks to ensure the form editor has been found correctly
return Wnd;
}
STDMETHODIMP CPropPageExtended::Apply()
{
IMP_BEGIN
// check there is only a single associated object
if(m_nObjects!=1)
{
throw std::exception();
}
// get the form editor window
CWindow Wnd=GetFormEditor();
if(Wnd==NULL)
{
throw std::exception();
}
// create the extended property page data
AxFormEditor::CExtendedPropPageData Data;
// name
CComBSTR Name;
(void)m_ctrlName.GetWindowText(&Name);
Data.m_Name=BSTR2W(Name);
// set the extended property page data
if(Wnd.SendMessage(
WM_SET_EXTENDED_PROPPAGE_DATA,0,(LPARAM)&Data)==FALSE)
{
throw std::exception();
}
// reset the modified flag
SetDirty(FALSE);
IMP_END
return RetVal;
}
LRESULT CPropPageExtended::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
USES_CONVERSION;
// wrap all dialog controls
m_ctrlName.Attach(GetDlgItem(IDC_NAME));
// 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_ctrlName.EnableWindow(FALSE);
return 0;
}
// get the form editor window
CWindow Wnd=GetFormEditor();
if(Wnd==NULL)
{
return 0;
}
// get the extended property page data
AxFormEditor::CExtendedPropPageData Data;
if(Wnd.SendMessage(
WM_GET_EXTENDED_PROPPAGE_DATA,0,(LPARAM)&Data)==FALSE)
{
return 0;
}
// initialise the controls
(void)m_ctrlName.SetWindowText(W2CT(Data.m_Name.c_str()));
// reset the modified flag
SetDirty(FALSE);
return 0;
}
LRESULT CPropPageExtended::OnChangeName(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.