Click here to Skip to main content
12,625,912 members (28,734 online)
Click here to Skip to main content

Stats

133.4K views
2.2K downloads
56 bookmarked
Posted

ATL Splitter ActiveX control

, 16 Nov 1999 CPOL
A port of my splitter ActiveX control with MFC to ATL.
ReleaseMinDependency
SplitterATLControl.dll
splitter.bmp
Splitter.rgs
SplitterATLControl.def
SplitterATLControl.dsp
SplitterATLControl.dsw
SplitterATLControl.plg
SplitterATLControl.tlb
SplitterATLControlps.def
SplitterATLControlps.mk
SplitterPropPage.rgs
// SplitterPropPage.cpp : Implementation of CSplitterPropPage
#include "stdafx.h"
#include "SplitterATLControl.h"
#include "Splitter.h"
#include "SplitterPropPage.h"

/////////////////////////////////////////////////////////////////////////////
// CSplitterPropPage
STDMETHODIMP CSplitterPropPage::Apply()
{
	ATLTRACE(_T("CSplitterPropPage::Apply\n"));

	CComBSTR strFirstName,strSecondName,strPosition;
	GetDlgItemText(IDC_COMBO_FIRST,strFirstName.m_str);
	GetDlgItemText(IDC_COMBO_SECOND,strSecondName.m_str);
	GetDlgItemText(IDC_EDIT_POSITION,strPosition.m_str);

	float fltPosition;
	swscanf(strPosition.m_str,L"%f",&fltPosition);

	BOOL bVertical=IsDlgButtonChecked(IDC_CHECK_SYTLE);
	
	for (UINT i = 0; i < m_nObjects; i++)
	{
		CComQIPtr<ISplitter, &IID_ISplitter> pSplitter(m_ppUnk[i]);
		pSplitter->put_FirstControlName(strFirstName);
		pSplitter->put_SecondControlName(strSecondName);
		pSplitter->put_SplitterIsVertical(bVertical);
		if(FAILED(pSplitter->put_SplitterPercentPosition(fltPosition)))
			return E_FAIL;
	}
	
	m_bDirty = FALSE;

	return S_OK;
}

LRESULT CSplitterPropPage::OnClickedCheck_sytle(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	SetDirty(TRUE);
	return 0;
}

LRESULT CSplitterPropPage::OnEditchangeCombo_first(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	SetDirty(TRUE);
	return 0;
}

LRESULT CSplitterPropPage::OnSelchangeCombo_first(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	SetDirty(TRUE);
	return 0;
}

LRESULT CSplitterPropPage::OnEditchangeCombo_second(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	SetDirty(TRUE);
	return 0;
}

LRESULT CSplitterPropPage::OnSelchangeCombo_second(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	SetDirty(TRUE);
	return 0;
}

LRESULT CSplitterPropPage::OnChangeEdit_position(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	SetDirty(TRUE);
	return 0;
}


LRESULT CSplitterPropPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	USES_CONVERSION;

	//Filling comboboxes
	if(m_nObjects>0)
	{
		CComQIPtr<IPerPropertyBrowsing, &IID_IPerPropertyBrowsing> pPPB(m_ppUnk[0]);
		CALPOLESTR* pCALPOLESTR;
		CADWORD*	pCADWORD;
		pCALPOLESTR=(CALPOLESTR*)CoTaskMemAlloc(sizeof(CALPOLESTR));
		pCADWORD=(CADWORD*)CoTaskMemAlloc(sizeof(CADWORD));

		if(SUCCEEDED(pPPB->GetPredefinedStrings(DISPID_FIRST_CONTROL_NAME,pCALPOLESTR,pCADWORD)))
		{
			for(int i=0; i<pCALPOLESTR->cElems; i++)
			{
				TCHAR* lpstrElem=OLE2T(pCALPOLESTR->pElems[i]);
				CoTaskMemFree(pCALPOLESTR->pElems[i]);
				SendDlgItemMessage(IDC_COMBO_FIRST,CB_ADDSTRING,0,LPARAM(lpstrElem));
				SendDlgItemMessage(IDC_COMBO_SECOND,CB_ADDSTRING,0,LPARAM(lpstrElem));
			}

			CoTaskMemFree(pCALPOLESTR->pElems);
			CoTaskMemFree(pCADWORD->pElems);
		}

		if(pCADWORD)
			CoTaskMemFree(pCADWORD);

		if(pCALPOLESTR)
			CoTaskMemFree(pCALPOLESTR);
	}

	
	for (UINT i = 0; i < m_nObjects; i++)
	{
		CComQIPtr<ISplitter, &IID_ISplitter> pSplitter(m_ppUnk[i]);
		
		CComBSTR strFirstName,strSecondName,strPosition;
		float fltPosition;
		BOOL bVertical;

		pSplitter->get_FirstControlName(&strFirstName.m_str);
		pSplitter->get_SecondControlName(&strSecondName.m_str);
		pSplitter->get_SplitterIsVertical(&bVertical);
		pSplitter->get_SplitterPercentPosition(&fltPosition);

		TCHAR lpstrPosition[20];
		_stprintf(lpstrPosition,_T("%g"),double(fltPosition));

		SetDlgItemText(IDC_COMBO_FIRST,OLE2T(BSTR(strFirstName)));
		SetDlgItemText(IDC_COMBO_SECOND,OLE2T(BSTR(strSecondName)));
		SetDlgItemText(IDC_EDIT_POSITION,lpstrPosition);

		CheckDlgButton(IDC_CHECK_SYTLE,bVertical);
	}

	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.

License

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

Share

About the Author

Andrew Garbuzov
United States United States
No Biography provided

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161205.3 | Last Updated 17 Nov 1999
Article Copyright 1999 by Andrew Garbuzov
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid