TA的每日心情 | 慵懒 2016-4-21 12:07 |
|---|
签到天数: 3 天 连续签到: 1 天 [LV.2]偶尔看看I 累计签到:3 天 连续签到:1 天
|
|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
1、得到系统时间日期(使用GetLocalTime) CString sTime,sYear,sMonth,sDay; SYSTEMTIME CurTime; GetLocalTime(&CurTime); sYear.Format(%d 年,CurTime.wYear); sMonth.Format(%d月,CurTime.wMonth); sDay.Format(%d日,CurTime.wDay); sTime = sYear+ sMonth + sDay; // CurTime.wHour // CurTime.wMinute // CurTime.wSecond IBM的 AfxMessageBox(sTime); . F* |8 R. i" Z0 b! A/ X8 {4 p
2、分离字串 CString str = 4d3f0a2278; unsigned char a12; long x; for(int i = 0;i< (str.GetLength()/2);i++) { sscanf(str.Mid(2*i,2),%x,&x); a[i] = x; }
6 E5 R+ e' ~( {3 x5 P3 L! T3、得到当前目录(GetCurrentDirectory) char CurPath[MAX_PATH]; DWORD size=MAX_PATH; GetCurrentDirectory(size,CurPath); AfxMessageBox(CurPath); CString number; int len = LineLength(LineIndex(0)); LPTSTR p=number.GetBuffer(len); this->GetLine(0,p,len); AfxMessageBox(number); 得到系统目录 (GetSystemDirectory)
* `$ x- `( ]+ h& K4、从字符串中提取数字 CString strNum; CString str(测试125各国87kk); strNum = GetStr(str); AfxMessageBox(strNum);
) L6 n( i6 J, z% V5、创建无模对话框 CDlg_Test *aa = new CDlg_Test; aa->Create(IDD_DIALOG1,NULL); aa->ShowWindow(SW_SHOW);1 ' b; t1 U+ `3 }; H4 O6 w
6、得到窗口绝对坐标 CString strNum,strNum1; CRect rect; GetClientRect(&rect); ClientToScreen(&rect); strNum.Format(X、%d,rect.top); strNum1.Format( Y、%d,rect.center); strNum = strNum + strNum1; AfxMessageBox(strNum); + h: C8 A4 R& e9 t& O; c6 U1 t" D
7、复制文件夹 SHFILEOPSTRUCT Op; char FromBuf[]=E:temp; char ToBuf[]=SINTEKSERVER个人文档陈 伟;; Op.hwnd = NULL; Op.wFunc = FO_COPY; Op.pFrom = FromBuf; Op.pTo = ToBuf; Op.fFlags = FOF_NOCONFIRMATION | FOF_RENAMEONCOLLISION ; Op.fAnyOperationsAborted = FALSE; Op.hNameMappings = NULL; Op.lpszProgressTitle = NULL; MessageBox(复制完毕,提示,MB_OK|MB_ICONINFORMATION);
' |2 h7 V0 }- l2 y3 F7 t8、捕获 Ctrl+鼠标左键组合 case WM_LBUTTONDOWN://鼠标消息wParam == if (wParam & MK_CONTROL) MessageBox(hwnd,aaa,bbb,MB_OK); break; 或 case WM_LBUTTONDOWN: MessageBox(hwnd,aaa,bbb,MB_OK); break; 2 g) _# x3 k; Z
9、判断文件是否存在 CFileFind filefind; if(!filefind.FindFile(strFileName)) { MessageBox("DCM图象文件未找到!","友情提示",MB_OK|MB_ICONINFORMATION); return; }
1 M, t! w# a& D" E10、求平方和平方根函数 CString s; s.Format("%f",pow(3,2));//结果为9.000000,平方根为sqrt(double),不必include math.h AfxMessageBox(s); w- f$ ~1 F% F1 ]; u3 V
11、设置画线颜色 CPen pen; pen.CreatePen(PS_DASH,iWeight,RGB(255,0,0));// 虚线,实线等多种风格 pDC->SelectObject(&pen); pDC->MoveTo(start.x,start.y); pDC->LineTo(end.x,end.y); pen.DeleteObject();
4 ]& D$ }$ V( ]& d5 z12、设置对话框窗口标题 void SetwindowText(LPCTSTR lpszString); |
|