CArray 参数传递方法
摘要:以实现形式void testarray(CString cstr[],int index);void Cyanl::OnBnClickedButton4(){ // TODO: 在此添加控件通知处理程序代码 CString cstr[12]; cstr[0]=_T("aaa"); cstr[1]=_T("bbb"); cstr[2]=_T("ccc"); cstr[3]=_T("ddd"); testarray(cstr,sizeof(cstr)/sizeof(cstr[0]));}以引用的方式void CmyTe
阅读全文
posted @
2012-04-20 15:49
markygis
阅读(1167)
推荐(0) 编辑
MFC 历遍一个目录下所有文件
摘要:HANDLE hFile; WIN32_FIND_DATA fileinfo; DWORD errorcode = 0; CString filename; hFile=FindFirstFile(_T("Storage Card\\*.*"),&fileinfo); while(hFile!=INVALID_HANDLE_VALUE&&errorcode!=ERROR_NO_MORE_FILES) { filename=fileinfo.cFileName; if(filename.Right(4)==_T(".d...
阅读全文
posted @
2012-04-19 15:37
markygis
阅读(332)
推荐(0) 编辑
CStudioFile 读取 txt 文件数据
摘要:CStudioFile 是CFile 的派生类,可逐行读写 CStudioFile f2; CString str; CString mstr; CString path; int n=0; path=_T("Storage Card\\shuipwy1.dat"); if( f2.Open(path,CFile::modeNoTruncate|CFile::modeRead) == false) { AfxMessageBox(_T("文件不存在")); } else { //f2.Se...
阅读全文
posted @
2012-04-19 14:57
markygis
阅读(1835)
推荐(0) 编辑
C++ 取整 取余
摘要:向下取整 floor向上取整 ceil CString streangle=_T("4.6259");double dangle= wcstod(streangle, NULL); int idu=(int)floor(dangle); int ifen= (int)floor((dangle-floor(dangle))*60); double fen=(dangle-floor(dangle))*60; double imiao=(fen-floor(fen))*60; TRACE(_T("%d ° %d \" %.3f '&quo
阅读全文
posted @
2012-04-17 15:18
markygis
阅读(7875)
推荐(0) 编辑
MFC 字符串截取成数组 wcstok
摘要:CString stext=_T("我,爱,你"); wchar_t str[100]; wcscpy(str,CT2CW(stext)); //非 unicode编码下 wcscpy(wszWideString, CA2CW(sText)); wchar_t *SEPS=L","; wchar_t *token; token=wcstok( str,SEPS); while(token!=NULL) { TRACE(token); token=wcstok(NULL,SEPS); }输出: 我 爱 你实现 MF...
阅读全文
posted @
2012-04-13 17:37
markygis
阅读(2850)
推荐(0) 编辑
MFC dialog 间 交互[2]
摘要:CMainFrame * pFrame = (CMainFrame *)AfxGetMainWnd(); CShuiPWY * pView = (CShuiPWY *)pFrame->GetActiveWindow(); pView->m_SPWYEdit_Status.SetWindowTextW(_T("状态:连接成功"))如何通过父级Dialog 向子级Dialog 传递参数,该段代码写在MainFrm.cpp 中,CShuiPWY 为目标dialog, GetActiveWindow() 获得目标窗体
阅读全文
posted @
2012-04-11 17:22
markygis
阅读(209)
推荐(0) 编辑
MFC 单文档应用程序 dialog 变量传递
摘要:如果一个程序,包含两个dialog,一个是父级,一个子级;父级传递子级:全局变量子级如何传递父级? 答案:父窗口的指针GetParent()实例void CContactsDlg::OnCancel(){ // TODO: 在此添加专用代码和/或调用基类 ((CPIMS02Dlg*)GetParent())->ShowButton(TRUE); CDialog::OnCancel();}ShowButton(TRUE) 为父级dialog 定义的 公共函数
阅读全文
posted @
2012-04-10 17:06
markygis
阅读(344)
推荐(0) 编辑
MFC Radio button 的使用
摘要:1.建立一个基于对话框的用用程序,在其中加入三个Radio Button,ID分别为: IDC_RADIO1,IDC_RADIO2,IDC_RADIO3 2.控件的初始化: 在对话框类的OnInitDialog中加入代码: CheckRadioButton(IDC_RADIO1, //第一个参数为该组的第一个单选按钮的ID IDC_RADIO3, //第二个参数为该组的最后一个单选按钮的ID IDC_RADIO3); //第三个参数为该组中被选中的单选按钮的ID 3.在加入一个Button控件,并为其写入Click事件代码: ...
阅读全文
posted @
2012-04-09 18:03
markygis
阅读(4680)
推荐(0) 编辑
MFC listbox array 使用
摘要:int ncount=lb.GetCount(); CArray<CString,CString&> listname; for(int i=0;i<ncount;i++) { CString s; lb.GetText(i,s); listname.Add(s); s.ReleaseBuffer(); } int arraynumb=listname.GetCount(); for(int j=0;j<arraynumb;j++) { TRACE(listname[j]); }将li...
阅读全文
posted @
2012-04-05 21:17
markygis
阅读(410)
推荐(0) 编辑
MFC 创建文件
摘要:CString strFolderPath="c:\\test" // 判断路径是否存在 if (!PathIsDirectory(m_strFolderPath) ) { CString strMsg; strMsg.Format ("指定路径\"%s\"不存在,是否创建?", m_strFolderPath); if (AfxMessageBox(strMsg, MB_YESNO) == IDYES) { if (!CreateDirectory(m_strFolderPath, NULL ) ) { strMsg.Format
阅读全文
posted @
2012-04-05 16:21
markygis
阅读(2968)
推荐(0) 编辑
写入文件
摘要:char* pszFileName="F:\\myfile.txt"; CStdioFile myFile; CFileException fileException; if(myFile.Open(pszFileName,CFile::typeText|CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate),&fileException) { myFile.SeekToEnd(); myFile.WriteString(stime); myFile.WriteString("\n&quo
阅读全文
posted @
2012-04-05 16:19
markygis
阅读(311)
推荐(0) 编辑
MFC CString 字符串截取
摘要:CString str=_T("aaa;vvv"); int index=str.Find(_T(";")); str=str.Left(str.GetLength()-index-1); AfxMessageBox((LPCTSTR)str);
阅读全文
posted @
2012-04-03 15:54
markygis
阅读(7489)
推荐(0) 编辑