コード例 #1
0
BOOL CDlgConServer::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CBpRegKey rk;
	CString strPath = APABI_USERINFO_KEYROOT;
	strPath += REGISTRY_KEY_OPTION;
	if (rk.Open(HKEY_CURRENT_USER, strPath) == ERROR_SUCCESS)
	{
		rk.Read(REGISTRY_KEY_CONSERVER, m_bAutoConServer);
		rk.Close();
	}

	// 载入上次连接的服务器信息
	LoadServerData(m_clientInfo);

	m_nServerPort = (htons)(m_clientInfo.serverport);
	m_nClientPort = (htons)(m_clientInfo.clientport);
	m_nServerIp = (htonl)(m_clientInfo.serverip);
	m_nServerIp2 = (htonl)(m_clientInfo.serverip2);

	m_ipaServer.SetAddress(m_nServerIp);
	m_ipaServer2.SetAddress(m_nServerIp2);

	UpdateData(FALSE);

	return TRUE;  	              
}
コード例 #2
0
void CDlgCheckRuleMdlMatSystem::OnBnClickedMatFolder()
{
	CString strMatResPath;
	CBpRegKey rk;
	CString strPath = DOCTOR_PRODUCT_KEYROOT;
	strPath += REGISTRY_KEY_OPTION;
	if (rk.Open(HKEY_CURRENT_USER, strPath) == ERROR_SUCCESS)
	{
		// 材料库的路径
		CString strValue;
		if (rk.Read(REGISTRY_KEY_MATERIALLIB_PATH, strValue) == ERROR_SUCCESS)
			strMatResPath = strValue;
	}

	if (strMatResPath.IsEmpty())
	{
		GetMainModulePath(AfxGetInstanceHandle(), strMatResPath);
		strMatResPath = strMatResPath + L"Resource\\MaterialLib\\";
	}
	if (strMatResPath[strMatResPath.GetLength()-1] != L'\\')
		strMatResPath = strMatResPath + L"\\";

	// 允许多选
	CFileDialog dlgFile(TRUE, _T("*.mtl"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, _T("材料文件(*.mtl)|*.mtl"));
	if (GetVersion() < 0x80000000) 
		// 运行的操作系统是Windows NT/2000 
		dlgFile.m_ofn.lStructSize = 88;	// 显示新的文件对话框 
	else
		// 运行的操作系统Windows 95/98 
		dlgFile.m_ofn.lStructSize = 76;	// 显示老的文件对话框 
	dlgFile.m_ofn.lpstrInitialDir = strMatResPath;
	
	if (dlgFile.DoModal() == IDOK)
	{
		POSITION pos_file;
		pos_file = dlgFile.GetStartPosition();

		CString strFilePath;
		CStringArray arrMatNames;
		while(pos_file != NULL)
		{
			strFilePath = dlgFile.GetNextPathName(pos_file);
			int nLength = strFilePath.GetLength();
			int nPos = strFilePath.ReverseFind(_T('\\'));
			strFilePath = strFilePath.Mid(nPos+1, nLength-nPos-5);
			arrMatNames.Add(strFilePath);
		}
		int nListCount = (int)m_listMats.GetItemCount();
		for (int i=0; i<arrMatNames.GetCount(); i++)
		{
			BOOL bExist = FALSE;
			for (int j=0; j<nListCount; j++)
			{
				if (arrMatNames[i].CompareNoCase(m_listMats.GetItemText(j, 0)) == 0)
				{
					bExist = TRUE;
				}
			}
			if (!bExist)
				m_listMats.InsertItem(nListCount, arrMatNames[i]);
		}
		UpdateCheckRuleByControl();
		::SendMessage(GetParent()->m_hWnd, WM_MODIFY_CHECK_RULE, 0, (LPARAM)&m_checkRule);
	}
}