一 属性设置
Edit Labels属性设置为True,可以就地编辑项文本,仅仅设置个属性是不够的。
View属性设置为Report或者是List
当View的属性为Report的时候只能编辑第一列
二 List Control的初始化
m_List_ctlDemo.InsertColumn(0, L"编号", LVCFMT_LEFT, 100);
m_List_ctlDemo.InsertColumn(1, L"水果", LVCFMT_LEFT, 100);
m_List_ctlDemo.InsertColumn(2, L"产地", LVCFMT_LEFT, 100);
m_List_ctl...
UI界面阅读全文
用Sleep函数延时,如何时间太长,程序就像无响应一样,采用消息泵可以解决这个问题
5秒延时
COleDateTime odtStart = COleDateTime::GetCurrentTime();
COleDateTimeSpan odtsEnd = COleDateTime::GetCurrentTime()-odtStart;
while(5>=odtsEnd.GetTotalSeconds())
{
MSG msg;
GetMessage(&msg,NULL,0,0);
TranslateMessage(&msg);
DispatchMessage(&msg);
odtsEnd = COleDateTime::GetCurrentTime()-odtStart;
}
A...
windows_API阅读全文
一 获取指定目录下当前文件夹和文件的路径
以获取D://test目录下的文件夹和文件为例
Void 类名::BrowseCurrentDir(CString strDir)
{
CFileFind finder;
CString strPath;
BOOL bWorking = finder.FindFile(strDir);
while (bWorking)
{
bWorking = finder.FindNextFile();
strPath=finder.GetFilePath();
//strPath就是所要获取Test目录下的文件夹和文件(包括路径)
}
stdFile.Close();
}
调用方式:
BrowseCurrentDir(...
MFC阅读全文
一 使用Shell函数
1 获取应用程序的安装路径
TCHAR buf[_MAX_PATH]; SHGetSpecialFolderPath(NULL,buf,CSIDL_PROGRAM_FILES,NULL); AfxMessageBox(buf);
2 获取应用程序数据路径的文件夹
TCHAR bufApplicateData[_MAX_PATH]; SHGetSpecialFolderPath(NULL,bufApplicateData,CSIDL_APPDATA,NULL); AfxMessageBox(bufApplicateData);
3 获取系统文件夹
TCHAR buf[_MAX_PATH]; SHGetSpecialFolderPath(NULL,buf,CSIDL_...
windows_API阅读全文
1添加数据 声明控件变量的类别为Control,变量类型为CListBox,变量名为m_ListBox_Content. m_ListBox_Content.AddString(_T("123")); m_ListBox_Content.AddString(_T("汉字")); m_ListBox_Content.AddString(_T("English")); m_ListBox_Content.AddString(_T("!@#$%^&*()")); 2获取数据 CString s; m_ListBox_Content.GetText(1,s); MessageBox(s,_T(&...
MFC阅读全文
有时候需要获得窗口矩形的大小和客户区矩形的大小二者的值,故需要分别调用GetWindowRect和GetClientRect。如果只需要获得客户区矩形的大小,调用GetClientRect就行了。
GetWindowRect函数
函数功能:该函数返回指定窗口的边框矩形的尺寸。该尺寸以相对于屏幕坐标左上角的屏幕坐标给出。 函数原型:BOOL GetWindowRect(HWND hWnd,LPRECTlpRect); 在Visual Studio 2005中,函数原型为void GetWi...
windows_API阅读全文
char与TCHAR之间的转化主要用到函数MultiByteToWideChar和WideCharToMultiByte.
char转TCHAR
如果不是Unicode字符集,就不需要转换,直接复制即可,如果不确定是否使用Unicode字符集,可以这样写:
char strUsr[10] = "Hello"; TCHAR Name[100]; #ifdef UNICODE MultiByteToWideChar(CP_ACP, 0, strUsr, -1, Name, 100); #else strcpy(Name, strUsr); #endif
...
windows_API阅读全文