⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 targetmachinedlg.cpp

📁 c++系统开发实例精粹内附的80例源代码 环境:windows2000,c++6.0
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
//       http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////

// TargetMachineDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Oscar.h"
#include "TargetMachineDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTargetMachineDlg dialog


CTargetMachineDlg::CTargetMachineDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTargetMachineDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTargetMachineDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	// Get the settings archive.
	COscarApp *pApp = (COscarApp *)AfxGetApp();
	ASSERT(pApp);
	m_pArchive = pApp->GetArchive();
	ASSERT(m_pArchive);

	m_bHasText = FALSE;
	m_nSel = -1;
}


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


BEGIN_MESSAGE_MAP(CTargetMachineDlg, CDialog)
	//{{AFX_MSG_MAP(CTargetMachineDlg)
	ON_EN_CHANGE(IDC_REMOTENAME, OnChangeRemotename)
	ON_BN_CLICKED(IDC_MYCOMPUTER, OnMycomputer)
	ON_BN_CLICKED(IDC_REMOTECOMPUTER, OnRemotecomputer)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTargetMachineDlg message handlers

BOOL CTargetMachineDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	if(m_pArchive->m_arch1.nTMLastSel == 0)
	{
		CheckRadioButton( IDC_MYCOMPUTER, IDC_REMOTECOMPUTER, IDC_MYCOMPUTER );

		CWnd *pWnd = GetDlgItem(IDC_REMOTENAME);
		ASSERT(pWnd);
		pWnd->EnableWindow(FALSE);
	}
	else
	{
		CheckRadioButton( IDC_MYCOMPUTER, IDC_REMOTECOMPUTER, IDC_REMOTECOMPUTER );

		CWnd *pWnd = GetDlgItem(IDC_REMOTENAME);
		ASSERT(pWnd);
		pWnd->EnableWindow(TRUE);
	}

	SetDlgItemText(IDC_REMOTENAME, m_pArchive->m_arch1.czTMLastTarget);
	CWnd *pWnd = GetDlgItem(IDOK);
	ASSERT(pWnd);
	pWnd->EnableWindow(m_pArchive->m_arch1.czTMLastTarget[0] != '\0' ||
		m_pArchive->m_arch1.nTMLastSel == 0);
	m_bHasText = (m_pArchive->m_arch1.czTMLastTarget[0] != '\0');

	// Display the logo.
	CStatic *pGuider;
	CRect crGuider;

	pGuider = (CStatic *)GetDlgItem(IDC_LOGOGUIDER);
	pGuider->GetWindowRect(&crGuider);
	ScreenToClient(&crGuider);

	m_cLogoBox.Create(WS_VISIBLE | WS_CHILD | WS_DISABLED,
		crGuider, this, IDC_LOGOBOX, IDB_OPEN,
		CSize(52, 40), RGB(191, 191, 191));

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CTargetMachineDlg::OnOK()
{
	CString cszTarget;

	if(IsDlgButtonChecked(IDC_MYCOMPUTER))
		m_pArchive->m_arch1.nTMLastSel = 0;
	else
		m_pArchive->m_arch1.nTMLastSel = 1;

	// Store the last machine name if it fits in our buffer.
	GetDlgItemText(IDC_REMOTENAME, cszTarget);
	if(cszTarget.GetLength() * sizeof(TCHAR) < 
		sizeof(m_pArchive->m_arch1.czTMLastTarget) - (2 * sizeof(TCHAR)))
	{
		memcpy((void *)m_pArchive->m_arch1.czTMLastTarget,
			(void *)cszTarget.GetBuffer(0),
			sizeof(TCHAR) * (cszTarget.GetLength() + 1));
	}
	else
		m_pArchive->m_arch1.czTMLastTarget[0] = '\0';

	m_nSel = m_pArchive->m_arch1.nTMLastSel;
	m_cszTarget = cszTarget;

	CDialog::OnOK();
}

void CTargetMachineDlg::OnChangeRemotename() 
{
	CString cszLen;

	GetDlgItemText(IDC_REMOTENAME, cszLen);

	m_bHasText = (cszLen.GetLength() > 0);

	CWnd *pWnd = GetDlgItem(IDOK);
	ASSERT(pWnd);
	pWnd->EnableWindow(m_bHasText);

	return;
}

void CTargetMachineDlg::OnMycomputer() 
{
	CWnd *pWnd = GetDlgItem(IDC_REMOTENAME);
	ASSERT(pWnd);
	pWnd->EnableWindow(FALSE);

	pWnd = GetDlgItem(IDOK);
	ASSERT(pWnd);
	pWnd->EnableWindow(TRUE);
	
	return;
}

void CTargetMachineDlg::OnRemotecomputer() 
{
	CWnd *pWnd = GetDlgItem(IDC_REMOTENAME);
	ASSERT(pWnd);
	pWnd->EnableWindow(TRUE);

	OnChangeRemotename();

	return;
}

int CTargetMachineDlg::GetSysType()
{
	return m_nSel;
}

CString CTargetMachineDlg::GetTargetName()
{
	// Override when we're viewing the local machine.
	if(m_nSel == 0)
		return _T("(Local)");

	return m_cszTarget;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -