2012年4月19日
摘要: 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 阅读(1826) 评论(0) 推荐(0) 编辑
  2012年4月17日
摘要: 向下取整 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 阅读(7835) 评论(0) 推荐(0) 编辑
  2012年4月13日
摘要: 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 阅读(2834) 评论(1) 推荐(0) 编辑
  2012年4月11日
摘要: 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 阅读(206) 评论(0) 推荐(0) 编辑
  2012年4月10日
摘要: 如果一个程序,包含两个dialog,一个是父级,一个子级;父级传递子级:全局变量子级如何传递父级? 答案:父窗口的指针GetParent()实例void CContactsDlg::OnCancel(){ // TODO: 在此添加专用代码和/或调用基类 ((CPIMS02Dlg*)GetParent())->ShowButton(TRUE); CDialog::OnCancel();}ShowButton(TRUE) 为父级dialog 定义的 公共函数 阅读全文
posted @ 2012-04-10 17:06 markygis 阅读(342) 评论(0) 推荐(0) 编辑
  2012年4月9日
摘要: 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 阅读(4659) 评论(0) 推荐(0) 编辑
  2012年4月5日
摘要: 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 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(2964) 评论(0) 推荐(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 阅读(310) 评论(0) 推荐(0) 编辑
  2012年4月3日
摘要: 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 阅读(7464) 评论(0) 推荐(0) 编辑