Example #1
0
//客户端连接断开消息函数
LONG CTCPServerDlg::OnClientConnect(WPARAM wParam,LPARAM lParam)
{
	int iIndex;
	TCHAR *szAddress = (TCHAR*)lParam;
	CString strAddrss = szAddress;
	
	CListBox * pLstConn = (CListBox*)GetDlgItem(IDC_LST_CONN);
	ASSERT(pLstConn != NULL);

	if (wParam == 0)
	{
		pLstConn->AddString(strAddrss + _T("建立连接"));
	}
	else
	{
		iIndex = pLstConn->FindString(iIndex,strAddrss + _T("建立连接"));
		if (iIndex != LB_ERR)
		{
			pLstConn->DeleteString(iIndex); 
		}
	}

	//释放内存
	delete[] szAddress;
	szAddress = NULL;
	return 0;
}
Example #2
0
void CPortraitsDlg::GetPortraitList(CListBox &lb, char chSize, int nWidth, int nHeight)
{
	char szSearch[MAX_PATH+1];
	char szPath[MAX_PATH+1];
	char szFilename[MAX_PATH+1];
	sprintf(szPath,"%s%s",(const char *)_strInstallPath,DIR_PORTRAITS);
	sprintf(szSearch,"%s*%c.bmp",szPath,chSize);

	WIN32_FIND_DATA fd;
	HANDLE hFile = ::FindFirstFile(szSearch,&fd);
	if (hFile == INVALID_HANDLE_VALUE)
		return;

	char szFile[MAX_PATH+1];
	CFile file;

	BMPTOP top;
	int nIndex;
	BOOL bFoundAnother = TRUE;
	while(bFoundAnother)
	{
		strcpy(szFile,fd.cFileName);
		bFoundAnother = ::FindNextFile(hFile,&fd);

		if (strlen(szFile)-4 > 8)
			continue;

		sprintf(szFilename,"%s%s",szPath,szFile);
		if (!file.Open(szFilename,CFile::modeRead|CFile::shareDenyNone|CFile::typeBinary))
			continue;

		if (file.Read(&top,sizeof(BMPTOP)) != sizeof(BMPTOP))
			continue;
		file.Close();

		if (top.bih.biWidth != nWidth || top.bih.biHeight != nHeight)
			continue;

		szFile[strlen(szFile)-4] = '\x0';
		
		// Make sure it isn't alreadyin the list. If it is, then there is a BMP called
		// the same thing as one of hte internal resources.
		if (lb.FindString(-1,szFile) != LB_ERR)
			continue;

		nIndex = lb.AddString(szFile);
		lb.SetItemData(nIndex,0);
	}
}
Example #3
0
void CPreferences::OnBnClickedOk()
{
	// Call the funtion
	/// check which check box is sleated
	// Load/Save
	if (IsDlgButtonChecked(IDC_RADIO_SAVE)) { // Save
		CString prefName;
		GetDlgItemText(IDC_EDIT_PREFERENCE_NAME, prefName);
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int indexInListBox = listBox->FindString(-1, prefName);
		if (indexInListBox >= 0) { // Already has this preference name
			if (MessageBox(prefName + _T(" already exists.\nDo you want to overwrite."),
				0, MB_YESNO) == IDNO) {
					CEdit *pEdit((CEdit*)GetDlgItem(IDC_EDIT_PREFERENCE_NAME));
					pEdit->SetFocus();
					pEdit->SetSel(0, -1);
					return;
			}
		}
		SavePreference(prefName);
		listBox->AddString(prefName);
		((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF))->AddString(prefName);
	}
	else if (IsDlgButtonChecked(IDC_RADIO_LOAD)) { // Load
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			LoadPreference(prefName);
		}
	}
	else if (IsDlgButtonChecked(IDC_RADIO_DELETE)) { // Delete
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			if (DeletePreference(prefName)) {
				listBox->DeleteString(curSel);
				CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
				pComboBox->DeleteString(pComboBox->FindString(1, prefName));
			}
		}
	}
}
Example #4
0
void CCreatePatchGroupDlg::OnBnClickedButtonAddgroup()
{
	// TODO: Add your control notification handler code here
	CString strGroupID;
	GetDlgItemText(IDC_EDIT_GROUP_ID, strGroupID);
	if (strGroupID.IsEmpty())
		return;

	SetDlgItemText(IDC_EDIT_GROUP_ID, _T(""));

	CListBox* pList = (CListBox*)GetDlgItem(IDC_LIST_GROUPLIST);

	if (LB_ERR != pList->FindString(-1, strGroupID))
	{
		return;
	}

	pList->AddString(strGroupID);
}