刘华世的官方博客

文章分类 -  vc++

Some article about vc++ Some vc++ knowledge by my study
摘要:最近有人问我关于这个的问题,就此写一篇blogAnsi字符串我们最熟悉,英文占一个字节,汉字2个字节,以一个\0结尾,常用于txt文本文件Unicode字符串,每个字符(汉字、英文字母)都占2个字节,以2个连续的\0结尾,NT操作系统内核用的是这种字符串,常被定义为typedef unsigned short wchar_t;所以我们有时常会见到什么char*无法转换为unsigned short*之类的错误,其实就是unicodeUTF8是Unicode一种压缩形式,英文A在unicode中表示为0x0041,老外觉得这种存储方式太浪费,因为浪费了50%的空间,于是就把英文压缩成1个字节,成 阅读全文
posted @ 2013-01-28 11:30 pythonschool 阅读(4251) 评论(1) 推荐(0) 编辑
摘要:void CAutoZipDlg::OnButton6() { // TODO: Add your control notification handler code here int iArg; //命令行参数个数 CString psz; //文件表 CString relative; //360zip相对路径 CString relative_zip; //存储zip的相对目录 CString exec_str; //命令行要执行的命令字符串 //要压缩的文件表 for( iArg = 1; iArg < __argc; iArg++ )... 阅读全文
posted @ 2013-01-28 11:30 pythonschool 阅读(754) 评论(0) 推荐(0) 编辑
摘要:假设在一个对话框程序中,有两个文本框(IDC_EDIT_FILE1和IDC_EDIT_FILE2)和两个按钮(IDC_BTN_1和IDC_BTN_2),这两个文本框中要输入两个不同的文件名称,从而完成相应的操作(如比较两个文件的差异),我们不得不通过两个按钮来实现两次“打开文件”的过程(相信我,这个功能经常会使用到的)。此时,我们可以使用OnDropFiles功能。以下从不同角度(对话框、文本框)来完成这个工作。不管从何种角度,让我们先来了解一下OnDropFiles到底是何物。OnDropFiles是WINDOWS窗口的WM_DROPFILES消息的消息响应函数,值得注间的是,对于基于... 阅读全文
posted @ 2012-12-14 17:31 pythonschool 阅读(1084) 评论(0) 推荐(0) 编辑
摘要:// Change.cpp: implementation of the CChange class.////////////////////////////////////////////////////////////////////////#include "stdafx.h"#include "CodeChange.h"#include "Change.h"#ifdef _DEBUG#undef THIS_FILEstatic char THIS_FILE[]=__FILE__;#define new DEBUG_NEW#en 阅读全文
posted @ 2012-12-14 13:32 pythonschool 阅读(611) 评论(0) 推荐(0) 编辑
摘要:CString转int:非Unicode环境CString str("1234");char *ch = str.GetBuffer(str.GetLength());int num = atoi(ch);str.ReleaseBuffer();int转CString:非Unicode环境CString str;int num = 1234;str.Format("%d",num);不建议使用(LPSTR)(LPCTSTR)这样的转换,不安全,错误率高。 阅读全文
posted @ 2012-12-11 21:11 pythonschool 阅读(336) 评论(0) 推荐(0) 编辑
摘要:最近在写code时,需要频繁使用到stat函数,为了更好的容错和log,就需要利用好st_mode。ok, 先看一下struct stat的结构。struct stat {dev_t st_dev; /* device */ino_t st_ino; /* inode */mode_t st_mode; /* protection */nlink_t st_nlink; /* number of hard links */uid_t st_uid; /* user ID of ... 阅读全文
posted @ 2012-11-28 16:40 pythonschool 阅读(6379) 评论(0) 推荐(0) 编辑
摘要:MFC中的argc和argv参数在consloe程序中,通常用main(int argc,char*const*argv),自动就得到这两个参数,在MFC多文档程序中,需要用到这两个参数,直接使用__argc,__argv即可。 阅读全文
posted @ 2012-11-27 16:51 pythonschool 阅读(566) 评论(0) 推荐(0) 编辑
摘要:BOOL CCreateStatusBarDlg::OnInitDialog(){ CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE). 阅读全文
posted @ 2012-11-27 13:51 pythonschool 阅读(494) 评论(0) 推荐(0) 编辑
摘要:BOOL CToolTipDlg::OnInitDialog(){ CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if ... 阅读全文
posted @ 2012-11-27 13:50 pythonschool 阅读(341) 评论(0) 推荐(0) 编辑
摘要:BOOL CSizeStatusbarDlg::OnInitDialog(){ CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); . 阅读全文
posted @ 2012-11-27 13:50 pythonschool 阅读(265) 评论(0) 推荐(0) 编辑
摘要:BOOL CProgressStatusBarDlg::OnInitDialog(){ CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALS. 阅读全文
posted @ 2012-11-27 13:50 pythonschool 阅读(995) 评论(0) 推荐(0) 编辑
摘要:void CSelRectDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemM... 阅读全文
posted @ 2012-11-23 10:55 pythonschool 阅读(409) 评论(0) 推荐(0) 编辑
摘要:void CSelRectDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemM... 阅读全文
posted @ 2012-11-21 17:09 pythonschool 阅读(461) 评论(0) 推荐(0) 编辑
摘要:WM_CTLCOLOR事件HBRUSH CFontDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(nCtlColor == CTLCOLOR_EDIT) //判断是否为编辑框控件 pDC->SetBkColor(m_Color); //设置文本背景颜色 //pDC->Se... 阅读全文
posted @ 2012-11-21 17:09 pythonschool 阅读(310) 评论(0) 推荐(0) 编辑
摘要:CString estr1 = "有志者,事竟成,破釜沉舟,百二秦关终属楚\r\n"; estr1 += "苦心人,天不负,卧薪尝胆,三千越甲可吞吴\r\n"; SetDlgItemText(IDC_EDIT1, estr1); SetDlgItemText(IDC_BUTTON1, "字体");void CFontDlg::OnFont() { // TODO: Add your control notification handler code here CFont * TempFont = m_Text.GetFont(); / 阅读全文
posted @ 2012-11-21 17:09 pythonschool 阅读(484) 评论(0) 推荐(0) 编辑
摘要:void CTestDlg::OnOpen() { // TODO: Add your control notification handler code here //bOpenFileDialog(TRUE):'打开'对话框 //lpszDefExt:扩展名 //lpszFileName:文件名称 //dwFlags:自定义文件对话框 //lpszFilte:用于指定对话框过滤的文件类型(文件类型说明和扩展名间用"|"分隔,每种文件类型间用"|"分隔,末尾用"||"结束.) //pParentWnd:标识文件对话框 阅读全文
posted @ 2012-11-21 17:09 pythonschool 阅读(1045) 评论(0) 推荐(0) 编辑
摘要:void CWelcomeDlg::OnClose() { // TODO: Add your message handler code here and/or call default if(MessageBox("Are you sure close this windows?", "closing", MB_OKCANCEL|MB_ICONQUESTION) == IDOK) { CDialog::OnClose(); } //创建一个基于对话框的应用程序. //通过类向导选择WM_CLOSE消息事件 //在对话框的消息事件... 阅读全文
posted @ 2012-11-15 10:41 pythonschool 阅读(2975) 评论(0) 推荐(0) 编辑
摘要:Login dlg; if(dlg.DoModal()!=IDOK) { OnOK(); }void Login::OnOK() { // TODO: Add extra validation here //CEdit *pEdit1 = (CEdit *)GetDlgItem(IDC_EDIT1); //CEdit *pEdit2 = (CEdit *)GetDlgItem(IDC_EDIT2); //CString e1, e2; //pEdit1->GetWindowText(e1); //pEdit2->Get... 阅读全文
posted @ 2012-11-15 10:41 pythonschool 阅读(1279) 评论(0) 推荐(0) 编辑
摘要:BOOL CBeginDlg::OnInitDialog(){ SetTimer(1, 100, NULL); //触发定时器}void CBeginDlg::OnTimer(UINT_PTR nIDEvent){ // TODO: 在此添加消息处理程序代码和/或调用默认值 //MessageBox(L"hello"); CRect rc; CRect rect; GetWindowRect(&rect); rc.CopyRect(&rect); CPoint pOint; GetCursorPos(&pOint); CString ... 阅读全文
posted @ 2012-11-15 10:41 pythonschool 阅读(281) 评论(0) 推荐(0) 编辑
摘要:BOOL CWelcomeDlg::PreTranslateMessage(MSG* pMsg) //Called to filter messages before they are dispatched{ // TODO: Add your specialized code here and/or call the base class if(pMsg->message == WM_KEYDOWN && pMsg->wParam == 27) { CString s; s.Format("The wParam= %d The message =... 阅读全文
posted @ 2012-11-15 10:41 pythonschool 阅读(358) 评论(0) 推荐(0) 编辑

刘华世的官方博客
点击右上角即可分享
微信分享提示