// CreateControlDlg.cpp : implementation file
//

#include "stdafx.h"
#include "client.h"
#include "CreateControlDlg.h"
#include "winnls.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

typedef struct tagCtrlInfo {
	char clsidstr [256] ;
	char url [256] ;
	char name [256] ;
} CTRLNAMES;

CTRLNAMES pci [] = 
{
	{"{69999373-BD40-11CF-8A6C-00AA00A58097}", "http://world.std.com/~dsp/timer.ocx", "plain timer control"},
	{"", "", ""}
} ;





/////////////////////////////////////////////////////////////////////////////
// CCreateControlDlg dialog


CCreateControlDlg::CCreateControlDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCreateControlDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCreateControlDlg)
	m_VersionMajor = 0;
	m_VersionMinor = 0;
	m_UrlString = _T("");
	m_PropName = _T("BackColor");
	m_PropVal = _T("65535");
	//}}AFX_DATA_INIT
}


void CCreateControlDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCreateControlDlg)
	DDX_Control(pDX, IDC_CLSIDCOMBO, m_ClsidCombo);
	DDX_Text(pDX, IDC_VERMAJOR, m_VersionMajor);
	DDX_Text(pDX, IDC_VERMINOR, m_VersionMinor);
	DDX_Text(pDX, IDC_CODEBASE, m_UrlString);
	DDX_Text(pDX, IDC_PROPNAME, m_PropName);
	DDX_Text(pDX, IDC_PROPVALUE, m_PropVal);
	//}}AFX_DATA_MAP

	if (!pDX->m_bSaveAndValidate)
	{
		int i = 0 ;

		while (pci [i].clsidstr[0] != 0x00)
		{
			m_ClsidCombo.AddString (pci[i].clsidstr) ;
			i++ ;
		}

		SetDlgItemInt (IDC_VERMAJOR, 1) ;
		SetDlgItemInt (IDC_VERMINOR, 0) ;
		m_ClsidCombo.SetCurSel (0) ;
		SetDlgItemText (IDC_CODEBASE, pci[0].url) ;
		SetDlgItemText (IDC_DESCRIPTION, pci[0].name) ;
	}
	else
	{
		m_ClsidCombo.GetWindowText (m_ClsidString) ;
		WCHAR wClsidString [256] ;

		MultiByteToWideChar (CP_ACP, 0, (LPCTSTR) m_ClsidString, -1,
			wClsidString, sizeof (wClsidString)/sizeof(WCHAR)) ;

		CLSIDFromString (wClsidString, &m_clsid) ;
		
		MultiByteToWideChar (CP_ACP, 0, (LPCTSTR)m_UrlString, -1,
			m_wUrlString, sizeof (m_wUrlString)/sizeof(WCHAR)) ;

	}
}


BEGIN_MESSAGE_MAP(CCreateControlDlg, CDialog)
	//{{AFX_MSG_MAP(CCreateControlDlg)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCreateControlDlg message handlers
