// TargetDialog.cpp : implementation file
//

#include "stdafx.h"
#include "gosview.h"
#include "TargetDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTargetDialog dialog


CTargetDialog::CTargetDialog( CGosViewDoc *pDoc, CWnd* pParent /*=NULL*/)
	: CDialog(CTargetDialog::IDD, pParent)
{
	m_pDoc = pDoc;
	//{{AFX_DATA_INIT(CTargetDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT


}


void CTargetDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTargetDialog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTargetDialog, CDialog)
	//{{AFX_MSG_MAP(CTargetDialog)
	ON_BN_CLICKED(IDLOCAL, OnLocal)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTargetDialog message handlers

void CTargetDialog::OnLocal() 
{
	char buffer[52];

	gethostname( buffer, 50 );

	CWnd *pEditBox = CWnd::GetDlgItem(IDC_TARGET_NAME);

	pEditBox->SetWindowText( buffer );
}

void CTargetDialog::OnOK() 
{
	CString csStr;

	CWnd *pEditBox = CWnd::GetDlgItem(IDC_TARGET_NAME);

	pEditBox->GetWindowText( csStr );

	strcpy( m_pDoc->m_ConnName, csStr.GetBuffer(50) );

	CDialog::OnOK();
}

void CTargetDialog::OnCancel() 
{

	CDialog::OnCancel();
}


BOOL CTargetDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CWnd *pEditBox = CWnd::GetDlgItem(IDC_TARGET_NAME);

	pEditBox->SetWindowText( m_pDoc->m_ConnName );
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
