1
2
3
4
-------------------------------------------------------------------------------------
BOOL CDOSDlg::ExecDosCmd()
{
#define EXECDOSCMD "dir c:" //可以换成你的命令
SECURITY_ATTRIBUTES sa;
HANDLE hRead,hWrite;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (!CreatePipe(&hRead,&hWrite,&sa,0))
{
return FALSE;
}
char command[1024]; //长达1K的命令行,够用了吧
strcpy(command,"Cmd.exe /C ");
strcat(command,EXECDOSCMD);
STARTUPINFO si;
PROCESS_INFORMATION pi;
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
si.hStdError = hWrite; //把创建进程的标准错误输出重定向到管道输入
si.hStdOutput = hWrite; //把创建进程的标准输出重定向到管道输入
si.wShowWindow = SW_HIDE;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
//关键步骤,CreateProcess函数参数意义请查阅MSDN
if (!CreateProcess(NULL, command,NULL,NULL,TRUE,NULL,NULL,NULL,&si,&pi))
{
CloseHandle(hWrite);
CloseHandle(hRead);
return FALSE;
}
CloseHandle(hWrite);
char buffer[4096] = {0}; //用4K的空间来存储输出的内容,只要不是显示文件内容,一般情况下是够用了。
DWORD bytesRead;
while (true)
{
if (ReadFile(hRead,buffer,4095,&bytesRead,NULL) == NULL)
break;
//buffer中就是执行的结果,可以保存到文本,也可以直接输出
AfxMessageBox(buffer); //这里是弹出对话框显示
}
CloseHandle(hRead);
return TRUE;
}
-------------------------------------------------------------------------------------
5 删除目录,包含删除子文件夹以及其中的内容
-------------------------------------------------
BOOL DeleteDirectory(char *DirName)//如删除 DeleteDirectory("c:\\aaa")
{
CFileFind tempFind;
char tempFileFind[MAX_PATH];
sprintf(tempFileFind,"%s\\*.*",DirName);
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())
{
char foundFileName[MAX_PATH];
strcpy(foundFileName,tempFind.GetFileName().GetBuffer(MAX_PATH));
if(tempFind.IsDirectory())
{
char tempDir[MAX_PATH];
sprintf(tempDir,"%s\\%s",DirName,foundFileName);
DeleteDirectory(tempDir);
}
else
{
char tempFileName[MAX_PATH];
sprintf(tempFileName,"%s\\%s",DirName,foundFileName);
DeleteFile(tempFileName);
}
}
}
tempFind.Close();
if(!RemoveDirectory(DirName))
{
MessageBox(0,"删除目录失败!","警告信息",MB_OK);//比如没有找到文件夹,删除失败,可把此句删除
return FALSE;
}
return TRUE;
}
-------------------------------------------------------------
6
7
8
-------------------------------------------------------
BOOL CT3Dlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN && VK_RETURN == pMsg->wParam)
{
pMsg->wParam = VK_TAB;
}
return CDialog::PreTranslateMessage(pMsg);
}
------------------------------------------
9
10 16进制转化成10进制小数的问题
方法二:浮点的储存方式和整数完全两样,你想了解的话可以去
http://www.zahui.com/html/1/3630.htm
看一看,不过通常我们都不必了解它就可以完成转换。
char a[4] = {0x8F, 0xC2, 0xF5, 0x3C};
float f;
memcpy(&f,a,sizeof(float));
11
12
13
--------------------------------------------------
HDC deskdc = ::GetDC(0);
CString stext = "我的桌面";
::TextOut(deskdc,100,200,stext,stext.GetLength());
::ReleaseDC(0,deskdc);
------------------------------------------------------
14
15
16
------------------------------------
HWND Hwd = ::FindWindow("Progman", NULL);
if (bShowed)
::ShowWindow(Hwd, SW_HIDE);
else
::ShowWindow(Hwd, SW_SHOW);
bShowed = !bShowed;
---------------------------------------
17
---------------------------------------------
char ch[256];
GetModuleFileName(NULL,ch,255);
for(int i=strlen(ch);i && ch[i]!='\\';i--);
ch[i]=0;
AfxMessageBox(ch);
----------------------------------------------
18
lParam
[in] Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. For more information about the lParam parameter, see Keystroke Message Flags. This parameter can be one or more of the following values.
0-15
Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key.
16-23
Specifies the scan code. The value depends on the OEM.
24
Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0.
25-28
Reserved.
29
Specifies the context code. The value is 1 if the ALT key is down; otherwise, it is 0.
30
Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up.
31
Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released.
19
20
21
22
23
24
25
26 ::SetFocus(::GetDesktopWindow());或::BringWindowToTop(::GetDesktopWindow());
::GetDesktopWindow()这里可获得桌面窗口的句柄
27
28
29
30
31
32 读取文本文件中的一行:
用CFile类的派生类:CStdioFile的方法:CStdioFile::ReadString
33
------------------------------------------------
SHFILEOPSTRUCT shfileop;
shfileop.hwnd = NULL;
shfileop.wFunc = FO_DELETE ;
shfileop.fFlags = FOF_SILENT|FOF_NOCONFIRMATION;
shfileop.pFrom = "c:\\temp"; //要删除的文件夹
shfileop.pTo = "";
shfileop.lpszProgressTitle = "";
shfileop.fAnyOperationsAborted = TRUE;
int nOK = SHFileOperation(&shfileop);
-------------------------------------------------
34
叫域运算符...在MFC中表示调用API...或其它全局函数...为了区分是mfc函数还是api
详见: http://search.csdn.net/Expert/topic/1183/1183492.xml?temp=.9471247
35
36
37
38
39
--------------------------------------------------
SYSTEMTIME sys;
GetSystemTime(&sys);
char str[100];
sprintf(str,"%d%d%d_%d%d%d",sys.wYear,sys.wMonth,sys.wDay,sys.wHour+8,sys.wMinute,sys.wSecond);
//这里的小时数注意它的0:00点是早上8:00,所以要加上8,因为这是格林威治时间,换成我国时区要加8
--------------------------------------------------
CString m_strTemp;
SYSTEMTIME systemtime;
GetLocalTime(&systemtime); //这个函数可获得毫秒级的当前时间
m_strTemp.Format("%d年%d月%d日%d:%d:%d:%d 星期%d",systemtime.wYear,systemtime.wMonth,systemtime.wDay,systemtime.wHour,systemtime.wMinute,systemtime.wSecond,systemtime.wMilliseconds,systemtime.wDayOfWeek);
--------------------------------------------------
40
The FlashWindow function flashes the specified window once, whereas the FlashWindowEx function flashes a specified number of times.
41
long lValue = 0xB28A43;
42
43
在OnSize中依其比例用MoveWindow同等缩放.http://www.codeproject.com/dialog/dlgresizearticle.asp
44 向CListCtrl中插入数据后,它总是先纵向再横向显示,我希望他先横向再纵向
45
46 实现象快速启动栏的"显示/隐藏桌面"一样的功能:http://fxstudio.nease.net/article/form/55.txt
47 如何设置listview某行的颜色:
CSDN上的贴子:http://community.csdn.net/Expert/topic/4386/4386904.xml?temp=2.422512E-03
Codeguru上相关链接:http://www.codeguru.com/Cpp/controls/listview/backgroundcolorandimage/article.php/c1093/
48 如何得到窗口标题栏尺寸:http://community.csdn.net/Expert/topic/4387/4387830.xml?temp=.6934168
49 如何将16进制的byte转成CString:
---------------------------------
BYTE p[3];
p[0]=0x01;
p[1]=0x02;
p[2]=0x12;
CString str;
str.Format("xxx", p[0], p[1], p[2]);
-------------------------------------
50 怎样查找到正处在鼠标下面的窗口(具体到子窗口和菜单),无论是这个窗口是否具有焦点:
-----------------------------------------------------------
POINT pt;
CWnd* hWnd; // Find out which window owns the cursor
GetCursorPos(&pt);
hWnd=CWnd::WindowFromPoint(pt);
if(hWnd==this)
{
//鼠标在窗体中空白处,即不在任何控件或子窗口当中
}
51 得到CListCtrl控件点击事件时点击的位置:
-----------------------------------------------
void CTest6Dlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if(pNMListView->iItem != -1)
{
CString strtemp;
strtemp.Format("单击的是第%d行第%d列",
pNMListView->iItem, pNMListView->iSubItem);
AfxMessageBox(strtemp);
}
*pResult = 0;
}
------------------------------------------------
52
53
-------------------------------------------------
BOOL CTest6Dlg::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN )
{
if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd) //判断当前控件是不是编辑框
{
switch( pMsg->wParam )
{
case VK_RETURN: //如果是回车键的话
Onbutton1(); //就调用Button1的响应函数
}
}
return CDialog::PreTranslateMessage(pMsg);
}
---------------------------------------------------
54
55
56
实现方法是:
1、用GetCurrentBitmap得到DC上的CBitmap指针;
2、用GetBitmapBits得到CBitmap上的图像数据流;
3、对图像数据流中每个字节进行转换,转换的公式为
57
58
--------------------------------------------------
int GetCount(CString str)
{
int total=0;
for(int i=0;i<str.GetLength();i++)
{
if (127<(unsigned int)str.GetAt(i))
{
total++;
i++;
}
else
total++;
}
return total;
}
----------------------------------------------------
59
60
刷新控件区域:
控件ID:IDC_STATIC_STATIC
------------------------------------
CRect static_rect;
CWnd *pwnd = GetDlgItem(IDC_STATIC_STATIC);
if (pwnd == NULL)
{
return;
}
pwnd->GetWindowRect(&static_rect);
ScreenToClient(&static_rect);
InvalidateRect(&static_rect); //注意这个函数,会调用OnEraseBkgnd
--------------------------------------
61
62
----------------------------------
HWND hWnd = FindWindow("Shell_TrayWnd", NULL);
RECT rc;
::GetWindowRect(hWnd, &rc);
int iHeight = rc.bottom -rc.top;
-----------------------------------
63
http://www.vckbase.com/code/downcode.asp?id=2415
http://www.vckbase.com/code/downcode.asp?id=2397
64 给ListBox控件加上水平滚动条:m_list.SetHorizontalExtent(100); //m_list为和listbox控件绑定的CListBox变量
65
66 如何让MFC基于Dialog的程序在任务栏中显示:http://community.csdn.net/Expert/topic/4413/4413492.xml?temp=.3407404
67 制作一个没有标题栏.菜单栏和工具栏的视窗,就象游戏界面一样:
http://community.csdn.net/Expert/topic/4396/4396239.xml?temp=.568783
68 为何组合框Droplist风格时响应键盘PreTranslateMessage函数,而dropdown风格时不响应:
http://community.csdn.net/Expert/topic/4412/4412791.xml?temp=.8741419
69 直接用特殊字符的编码:s=WCHAR(0x00e6);
70 在标题栏上画图:http://community.csdn.net/Expert/topic/4416/4416434.xml?temp=.8910944
71 如何精确延时:http://www.vckbase.com/document/viewdoc/?id=1301
72 怎样给TreeView控件中的结点重命名:http://community.csdn.net/Expert/topic/4409/4409069.xml?temp=.1730463
73 从内存中加载并启动一个exe :http://community.csdn.net/Expert/topic/4418/4418306.xml?temp=.7619135
74 修改一个EXE的资源:http://community.csdn.net/Expert/topic/4420/4420755.xml?temp=.5104029
75 使用并显示64bit数值的方法:
__int64 ld = 2000000000*4500000000; //64bit数的范围:-9223372036854775808~+9223372036854775807
printf("%I64d\n",ld);
76 在程序中使用console窗口显示:
http://www.codeguru.com/Cpp/W-D/console/
77 用代码画鼠标图案并限定鼠标移动区域(用ClipCursor函数):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors/usingcursors.asp
78 改变编辑框字体的大小: http://community.csdn.net/Expert/topic/4389/4389148.xml?temp=.2317163
先在对话框类的内部声明一个CFont对象,如:CFont myfont;
---------------------------------
myfont.CreatePointFont(500, "Arial");
GetDlgItem(IDC_EDIT1)->SetFont(&myfont);
---------------------------------
79 bmp图片怎么转换为jpg:
用cximage
www.codeproject.com上有
80 字符串转成UTF-8格式参考CSDN上的FAQ: http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=191432
81 将16进制字符串转换成10进制整数:
char a[3]="ab";
DWORD val = strtoul(a, NULL, 16);
82 快速从数字的字符串中提取出特定长度的数字:
-------------------------------------------------------
int a[4];
sscanf("2004115819185","dddd",&a[0],&a[1],&a[2],&a[3]); //按指定长度分隔
--------------------------------------------------------
或:
-------------------------------------------------------
CString s="aaa,bbb,ccc,ddd";
char a1[4],a2[4],a3[4],a4[4]; //这里要注意多留点空间以存放各子串的长度
sscanf(s,"%[^,],%[^,],%[^,],%[^,]",a1,a2,a3,a4); //按指定字符(这里是逗号)分隔
AfxMessageBox(a4);//显示ddd
-------------------------------------------------------
83 配置文件的配置项可不可以删除:
http://community.csdn.net/Expert/topic/4402/4402346.xml?temp=.4008448
84 如何改变CListCtrl包括Scrollbars和Column Headers的颜色和风格: http://www.codeguru.com/Cpp/controls/listview/backgroundcolorandimage/print.php/c4185/
85 根据ComboBox加入的字符串的长度自动调整ComboBox控件的宽度:
//这里假设为ComboBox加入两个字符串
CString str1="中华人民共和国中华人民共和国",str2="1234567890123中国89012345678";
m_combo.AddString(str1); //m_combo为绑定在组合框控件的变量
m_combo.AddString(str2);
int len=str1.GetLength()*6.2; //根据加入的字符串长度(以字节为单位)和组合框使用的默认字体的大小计算组合框实际需要的宽度,计算中间用到了整数->浮点数->整数的两次数值类型隐式转换,也可以用winAPI函数GetTextExtentPoint32()或GetTextExtent计算
m_combo.SetDroppedWidth(len);
86 弹出U盘:
http://community.csdn.net/Expert/topic/4432/4432968.xml?temp=.8724634
87 往另一个程序的编辑框中发送文字:句柄->SendMessage(WM_SETTEXT,strlen(buf),(LPARAM)buf);
88 如何在RichEdit中加超链接: http://community.csdn.net/Expert/topic/4434/4434686.xml?temp=9.524173E-02
89 VC控件的用法: http://www.vckbase.com/document/indexold.html
90 学习资源: http://code.ddvip.net/list/sort000081_1.html
91 在初始时候定位到LIST的指定行(如第100行)开始显示:EnsureVisible(100)
92 如何在app中SetTimer(): http://community.csdn.net/Expert/topic/4437/4437002.xml?temp=6.014651E-02
http://search.csdn.net/Expert/topic/1422/1422546.xml?temp=.5501825
93 一个基于SDK的软键盘的范例,可以学习如何发送虚拟按键或鼠标消息: http://www.codeproject.com/cpp/togglekeys.asp
94 MDI文档中的字体、及其颜色怎么设置: http://community.csdn.net/Expert/topic/4396/4396003.xml?temp=.7866938
95 自己捕捉特定的组合键: http://community.csdn.net/Expert/topic/4439/4439270.xml?temp=.7411157
--------------------------------------------------------------
BOOL CMMDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
BOOL b = GetAsyncKeyState(VK_CONTROL) >> ((sizeof(short) * 8)-1);
if(b)
{
b = GetAsyncKeyState(VK_MENU) >> ((sizeof(short) * 8)-1);
if(b)
{
b = GetAsyncKeyState(65) >> ((sizeof(short) * 8)-1); //这里不分大小写
if(b)
{
AfxMessageBox("你按下了Ctrl+Alt+A组合键。") ;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
-------------------------------------------------------------
96 快速从得到的全路径文件名中分离出盘符、路径名、文件名和后缀名:
------------------------------------------------
char path_buffer[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
GetModuleFileName(0,path_buffer,_MAX_PATH);
_splitpath( path_buffer, drive, dir,fname , ext); //用这个函数转换
------------------------------------------------
97 如何debug除零错误:
http://community.csdn.net/Expert/topic/4440/4440273.xml?temp=.2427484
98 修改VS.net“工具”栏中菜单的默认图标: http://www.codeproject.com/dotnet/vsnet_addin_icon_change.asp
99 在窗口的标题栏和菜单栏上象realplayer那样添加自己的logo: http://www.codeproject.com/menu/menuicon.asp
100 个性化的位图菜单,自己从CMenu派生子类实现: http://www.codeguru.com/Cpp/controls/menu/bitmappedmenus/article.php/c165
101 怎样取得程序自己占用的内存和CPU占用率:GetProcessMemoryInfo和GetPerformanceInfo
102 如何让你的程序运行在release模式下:build->set active configuration
103 监视文件夹是否被更新:FindFirstChangeNotificat
105 动态菜单: http://community.csdn.net/Expert/topic/4441/4441893.xml?temp=.2887384
106 如何获取客户区的中心坐标: http://community.csdn.net/Expert/topic/4449/4449444.xml?temp=8.642215E-02
107 强行操作内存虚拟地址中某个指定地方的内容:
----------------------------------------------
int *a=(int*)0x00440000; //这里以访问0x00440000地址为例
cout<<*a<<endl;
----------------------------------------------
108 如何响应条码机:
http://community.csdn.net/Expert/topic/4453/4453026.xml?temp=.1966516
条码扫描仪主要有三种接口: 1.RS232 2.共用接盘接口 3.USB外设.
当然也可不放edit框,而直接接收键盘字符(比如重写OnChar函数等,方法很多),但要考虑到这种情况:条码读不出来的情况,此时应该用手动输入条码,所以还是放一个edit框为好。
109 检查指定文件夹是否存在:PathIsDirectory()
----------------------------------------------------------
DWORD = GetFileAttributes(_T("f:\\win98"));
if(dwAttr != 0xFFFFFFFF && (dwAttr & FILE_ATTRIBUTE_DIRECTORY))
cout<<"exist"<<endl;
else
cout<<"NOT exist"<<endl;
----------------------------------------------------------
----------------------------------------------------------
if(_access("f:\\win98",0)!=-1)
cout<<"exist"<<endl;
else
cout<<"NOT exist"<<endl;
----------------------------------------------------------
110 去掉单文档标题栏上的“无标题—”: http://community.csdn.net/Expert/topic/4454/4454093.xml?temp=.2896997
111 打开显示器: ::SendMessage(GetSafeHwnd(), WM_SYSCOMMAND, SC_MONITORPOWER, -1);
关闭显示器: ::SendMessage(GetSafeHwnd(), WM_SYSCOMMAND, SC_MONITORPOWER, 1);
得到它的工作状态:
休眠状态是指用SendMessage(Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1)关闭的
--------------------------------------------------------------------------------
The GetDevicePowerState function is supposed to retrieve the current power state of the specified device. However, Apps may fail to use GetDevicePowerState on the display, as they can't get a handle on " \\.\Display#", while the # index is 1-based, or " \\.\LCD", for security reasons.
If you are trying to do this on Windows XP, then you can use SetupDiGetDeviceRegistry
The WMI Class Win32_DesktopMonitor does not report the power state. use SPI_GETPOWEROFFACTIVE or DeviceIOControl with IOCTL_VIDEO_GET_POWER_MANAGEMENT will simply reports power management is enabled or not. SPI_GETPOWEROFFACTIVE just determines whether the power-off phase of screen saving is enabled or not.
BTW, you can always use the SetThreadExecutionState or other APIs (you have used) to switch ON the monitor no matter the monitor is in the ON or OFF state.
References
http://msdn.microsoft.com/library/en-us/Display_r/hh/Display_r/VideoMiniport_Functions_b47b2224-5e0b-44af-9d04-107ff1299381.xml.asp
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_desktopmonitor.asp
112 得到系统时间、语言等的设置
113 文件是否存在(记得先包含头文件#include <io.h>)
----------------------------------
if(_access("c:\\somefile.txt",0)!=-1)
//存在
else
//不存在
---------------------------------
还有一个方法:
---------------------------------------------
if(GetFileAttributes("f:\\test.txt")!=0xFFFFFFFF)
{
//存在
}
else
{
//不存在
}
---------------------------------------------
114 得到剪贴板数据
-------------------------------------------------
if ( OpenClipboard() )
{
HANDLE hData = GetClipboardData(CF_TEXT);
char * buffer = (char*)GlobalLock(hData); //剪贴板中的文本内容保存在buffer中
GlobalUnlock(hData);
CloseClipboard();
}
----------------------------------------------
115 在CStatic上面关联图片
----------------------------------------------
CStatic* pWnd = (CStatic*)GetDlgItem(IDC_STATIC);
pWnd->ModifyStyle(0, SS_BITMAP);
pWnd->SetBitmap((HBITMAP)::LoadImage(0,
"c:\\zzzzz.bmp", //只能显示.bmp文件
IMAGE_BITMAP,
0,0,LR_CREATEDIBSECTION |LR_DEFAULTSIZE |LR_LOADFROMFILE));
----------------------------------------------
116 显示一个打开文件夹的对话框,并得到用户选择的目录:
-------------------------------------------
char szDir[MAX_PATH];
BROWSEINFO bi;
ITEMIDLIST *pidl;
bi.hwndOwner = this->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = szDir;
bi.lpszTitle = "请选择目录";//strDlgTitle;
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
pidl = SHBrowseForFolder(&bi);
if(pidl == NULL)
return;
if(!SHGetPathFromIDList(pidl, szDir))
return;
AfxMessageBox(szDir); //szDir中存放的内容为用户选定的目录
------------------------------------------------
117 去除字符串中指定的字符:
-----------------------------------------
CString strtemp;
strtemp.Format("%s","abc\n123\ndef");
strtemp.Remove('\n'); //这里以去除换行符为例,结果保存在strtemp中了
-------------------------------------------
118 有关数据结构的地址:
http://student.zjzk.cn/course_ware/data_structure/web/main.htm
119 假如当前时间2005-09-09,如何计算在该时间前12345天,是哪年哪月哪日?
---------------------------
CTime tm(2005,9,9,0,0,0);
tm-=86400*12345;
cout<<tm.Format("%Y-%m-%d")<<endl;
----------------------------
120 PeekMessage是干什么用的:
121 拖动控件时实现类似windows拖动窗口的效果:CRectTracker
122 有关UNICODE、ANSI字符集和相关字符串操作的总结: http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=199372
123 寻找系统中的打印机:EnumPrinters
124 用代码加入外部模块的方法:#pragma comment(lib,"mylib.lib")
125 判断指定点是否在一个矩形框内:CRect::PtInRect(POINT point)
126 winAPI 函数GetTextExtentPoint32()可以得出一个以像素为单位的字符串的宽度。
127 RGB转换成YV12(YUV 4:2:0)的方法: http://www.fourcc.org/fccyvrgb.php
128 获得指定进程占用内存的情况,用GetProcessMemoryInfo()函数。
129 把CONSOLE程序的输出导入到文件中,用程序控制: http://community.csdn.net/Expert/topic/4403/4403431.xml?temp=.7469599
130 把CRichEditCtrl中的文字保存到rtf文件: http://community.csdn.net/Expert/topic/4478/4478640.xml?temp=.1313135
在codeproject上还有从CRichEditCtrl类派生新类的,功能增强了很多: http://www.codeproject.com/richedit/autoricheditctrl.asp
还有一个开发类似写字板那样程序的完整范例: http://www.codeproject.com/tools/simplewordpad.asp
131 MFC中使用ATL字符转换宏:在你的函数开关加上USES_CONVERSION;语句,详见MSDN或这里: http://community.csdn.net/Expert/topic/4479/4479609.xml?temp=.6256983
132 如何建立共享目录:直接调用标准的Win32API函数NetShareAdd和NetShareDel
详见MSDN及: http://community.csdn.net/Expert/topic/4481/4481371.xml?temp=.4405023
133 位图文件读写基础: http://www.vckbase.com/document/viewdoc/?id=674
134 用VC实现支持多语言的程序: http://www.vckbase.com/document/viewdoc/?id=1102
135 Menu系列函数:
136 得到SYSTEMMENU(系统菜单)的高度:GetSystemMetrics(SM_CYMENU);
得到当前屏幕分辨率:
137 在属性页控件的标签上加图片: http://www.codeguru.com/cpp/controls/propertysheet/article.php/c611/
--------------------------------------------------
BOOL CMyPropSheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
m_imageTab.Create( IDB_TABIMAGES, 13, 1, RGB(255,255,255) );
CTabCtrl *pTab = GetTabControl();
pTab->SetImageList( &m_imageTab );
TC_ITEM tcItem;
tcItem.mask = TCIF_IMAGE;
for( int i = 0; i < 3; i++ )
{
tcItem.iImage = i;
pTab->SetItem( i, &tcItem );
}
return bResult;
}
----------------------------------------------------