侠盗猎车手gta4打开出现VCCANNOTRUNONWINDOWS95的英...

VC一些小细节
我的图书馆
VC一些小细节
1& ++中 WM_QUERYENDSESSION WM_ENDSESSION 为系统[xi tong]关机消息[xiao xi]。2&在VC下执行[zhi hang]DOS命令[ming ling]&& a.&& system("md c:\\12");&& b.&& WinExec("Cmd.exe /C md c:\\12", SW_HIDE);&& c.&& ShellExecute&ShellExecute(NULL,"open","d:\\WINDOWS\\system32\\cmd.exe","/c md d:\\zzz","",SW_SHOW);&& d.&& CreateProcess&下面这个示例的函数[han shu]可以把给定的DOS命令[ming ling]执行[zhi hang]一遍,并把DOS下的输出[shu chu]内容记录在 buffer中。同时示范了匿名管道重定向[zhong ding xiang]输出[shu chu]的用法:&-------------------------------------------------------------------------------------&&&&&&& BOOL CDOSDlg::ExecDosCmd()&&&&&&& {&&& &&&&&&& #define EXECDOSCMD "dir c:" //可以换成你的命令[ming ling]
&SECURITY_ATTRIBUTES&HANDLE hRead,hW
&sa.nLength = sizeof(SECURITY_ATTRIBUTES);&sa.lpSecurityDescriptor = NULL;&sa.bInheritHandle = TRUE;&if (!CreatePipe(&hRead,&hWrite,&sa,0)) &{&&return FALSE;&} &char command[1024];&&& //长达1K的命令[ming ling]行[ming ling hang],够用了吧&strcpy(command,"Cmd.exe /C ");&strcat(command,EXECDOSCMD);&STARTUPINFO&PROCESS_INFORMATION &si.cb = sizeof(STARTUPINFO);&GetStartupInfo(&si); &si.hStdError = hW&&&&&&&&&&& //把创建进程[jin cheng]的标准错误[cuo wu]输出[shu chu]重定向[zhong ding xiang]到管道输入[shu ru]&si.hStdOutput = hW&&&&&&&&&& //把创建进程[jin cheng]的标准输出[shu chu][biao zhun shu chu]重定向[zhong ding xiang]到管道输入[shu ru]&si.wShowWindow = SW_HIDE;&si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;&//关键步骤,CreateProcess函数[han shu]参数[can shu]意义请查阅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的空间[kong jian]来存储输出[shu chu]的内容,只要不是显示[xian shi]文件[wen jian][xian shi wen jian]内容,一般情况[qing kuang]下是够用了。&DWORD bytesR &while (true) &{&&if (ReadFile(hRead,buffer,4095,&bytesRead,NULL) == NULL)&&&&&//buffer中就是执行[zhi hang]的结果,可以保存到文本[wen ben],也可以直接输出[shu chu]&&AfxMessageBox(buffer);&& //这里是弹出对话框[dui hua kuang]显示[xian shi]&}&CloseHandle(hRead); &return TRUE;&&&&&&& }&-------------------------------------------------------------------------------------3删除[shan chu]目录,包含删除[shan chu]子文件[wen jian]夹以及其中的内容&-------------------------------------------------&BOOL DeleteDirectory(char *DirName)//如删除[shan chu] DeleteDirectory("c:\\aaa")&{&&CFileFind tempF&&&&&&&& 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,"删除[shan chu]目录失败!","警告信息[xin xi]",MB_OK);//比如没有找到文件[wen jian]夹,删除[shan chu]失败,可把此句删除[shan chu]&&&&&&&&&&&&&&&& return FALSE;&&&&&&&& }&&&&&&&& return TRUE;&}&-------------------------------------------------------------4让程序暂停[zan ting][cheng xu zan ting]:system("PAUSE");5& 在PreTranslateMessage中捕捉键盘[jian pan]事件[shi jian]
&&&& if (pMsg-&message==WM_KEYDOWN && pMsg-&wParam==VK_RETURN)return TRUE; //注意return的值6& 更改按键消息[xiao xi](下面的代码[dai ma]可把回车键消息[xiao xi]改为TAB键消息[xiao xi])&-------------------------------------------------------  & BOOL CT3Dlg::PreTranslateMessage(MSG* pMsg) &   {
& &&    if(pMsg-&message == WM_KEYDOWN && VK_RETURN == pMsg-&wParam)&&& &&  &  {&&&&&&& &   pMsg-&wParam = VK_TAB;&&&  &  }&&&   & return CDialog::PreTranslateMessage(pMsg);  & }&------------------------------------------7&MoveWindow:& 一个可以移动、改变窗口[chuang kou]位置[wei zhi]和大小的函数[han shu]8&16进制转化成10进制小数的问题[wen ti]&&&&     用一个读二进制[er jin zhi]文件[wen jian][er jin zhi wen jian]的软件[ruan jian]读文件[wen jian]&&&&     二进制[er jin zhi]文件[wen jian][er jin zhi wen jian]中的一段 8F C2 F5 3C 最后变成了 0.03&&&&     请问这是怎么转换[zhuan huan]过来的??&&&&&   方法[fang fa]一:浮点技术法,如&   DWORD dw=0x3CF5C28F; &   float d=*(float*)&//0.03;     方法[fang fa]二:浮点的储存方式和整数完全两样,你想了解的话可以去        &http://www.zahui.com/html/1/3630.htm&        看一看,不过通常我们都不必了解它就可以完成转换[zhuan huan]。        char a[4] = {0x8F, 0xC2, 0xF5, 0x3C};                memcpy(&f,a,sizeof(float));&&&&&&&&&&&&&&& TRACE("%d",0x3CF5C28F);9& EDIT控件的 EM_SETSEL,EM_REPLACESEL消息[xiao xi]10& 在其它进程[jin cheng]中监视键盘[jian pan]消息[xiao xi]:用SetWindowsHookEx(WH_KEYBOARD_LL,...);13& 在桌面[zhuo mian]上任意位置[wei zhi]写字&--------------------------------------------------&HDC deskdc = ::GetDC(0);&CString stext = "我的桌面[zhuo mian]";&::TextOut(deskdc,100,200,stext,stext.GetLength());&::ReleaseDC(0,deskdc);&------------------------------------------------------14& HWND thread_hwnd=Findwindow(NULL,"你要监控的进程[jin cheng]窗体[chuang ti](用SPY++看)"),&&&& if (thread_hwnd==NULL) 。。。。。。。。。。&&&& else DWORD thread_id=GetWindowThreadProcessId(thread_hwnd,NULL)15& waveOutGetVolume()可以得到波形[bo xing]音量大小16& 隐藏桌面[zhuo mian]图标[tu biao]并禁用右键[you jian]功能菜单[cai dan]:&------------------------------------&HWND Hwd = ::FindWindow("Progman", NULL);&&if (bShowed)&&&::ShowWindow(Hwd, SW_HIDE);&&else&&&::ShowWindow(Hwd, SW_SHOW);&&bShowed = !bS&---------------------------------------17& 获得程序当前路径[lu jing]:&---------------------------------------------&char ch[256];&GetModuleFileName(NULL,ch,255);&for(int i=strlen(ch);i && ch[i]!='\\';i--);&ch[i]=0;&AfxMessageBox(ch);&----------------------------------------------18& KeyboardProc的lParam中包含着许多按键信息[xin xi],其中第31位(从0开始)为0表示是按下按键,为1表示松开按键。&&& (lParam & 0x)进行二进制[er jin zhi]'与'计算,效果是取第31位的值。&&& (lParam & 0x)是取第30位,30位表示按键的上一个状态[zhuang tai],为1表示之前键已经是按下的,0表示松开。   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 ke otherwise, it is 0.  25-28  Reserved.  29  Specifies the context code. The value is 1 if the ALT otherwise, it is 0.  30  Specifies the previous key state. The value is 1 if the key is down before 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& 复制文件[wen jian]应该用到CopyFile或是CopyFileEx这两个API20& 移动窗口[chuang kou]的位置[wei zhi]或改变大小:MoveWindow/SetWindowPos21& 我的程序是当前运行[yun hang]的程序时,可以用setcursor()来设置[she zhi]光标[guang biao]的图标[tu biao]。&&&&& 而且可以用setcapture()是鼠标[shu biao]移动到我得程序窗口[chuang kou]之外时也是我设置[she zhi]的图标[tu biao]&&&&& 但是如果我得程序不是当前的运行[yun hang]程序的,鼠标[shu biao]就会变会默认[mo ren]的。&&&&& 怎样能够,使得不变回默认[mo ren]的,还是用我设置[she zhi]的光标[guang biao]?&&&&& SetSystemCursor22& SendMessage函数[han shu]的几个用法:&&& 控制[kong zhi]按钮按下的,是这么用的&&& SendMessage(n1, WM_COMMAND, MAKELPARAM(ID,BN_CLICKED),(LPARAM )n2); (n1,n2是句柄[ju bing])&&& 而得到文本[wen ben]内容,是这样用的,&&& SendMessage(hWnd,WM_GETTEXT,10,(LPARAM)buf),23& 处理一个单行EDIT的WM_CTLCOLOR要同时响应[xiang ying]nCtlColor = CTLCOLOR_EDIT和CTLCOLOR_MSGBOX的两个情况[qing kuang],参考[can kao]&http://msdn.microsoft.com/library/default.?url=/library/en-us/vclib/html/_mfc_cwnd.3a3a.onctlcolor.asp&24& 设备发生改变处理函数[han shu]可在CWnd::OnDeviceChange中,捕获[bu huo]WMDEVICECHANGE事件[shi jian]不能区分诸如设备插入、拔下消息[xiao xi]。25& 把字符[zi fu]"abc\n123"存入文本[wen ben]文件[wen jian]中时,文件[wen jian]内容没看见换行[huan hang],其实用word打开该文件[wen jian]是有换行[huan hang]的。另外用"abc\r\n123"代替也可看见换行[huan hang]。26 ::SetFocus(::GetDesktopWindow()); 或::BringWindowToTop(::GetDesktopWindow());  ::GetDesktopWindow()这里可获得桌面[zhuo mian]窗口[chuang kou]的句柄[ju bing]27& 数组[shu zu]初始化[chu shi hua]:&&&&&&& int a[24][34];&&&&&&&&&&&&& //声明[sheng ming]数组[shu zu]&memset(a,-1,24*34);&&&&&&&& //全部元素初始化[chu shi hua]成-1,但初始化[chu shi hua]成除0和-1以外的数值是不行的28& SHGetFileInfo函数[han shu]可获得文件[wen jian]信息[xin xi]。29& 创建一个控件:&&&&&& HWND hEdit=CreateWindow("EDIT",NULL,WS_CHILD|WS_VISIBLE |ES_LEFT,50,20,50,20,hwnd,NULL,hInst,NULL);&& //hwnd参数[can shu]为父窗口[chuang kou]句柄[ju bing]30& VC中对声音文件[wen jian]的操作:&http://www.pujiwang.com/twice/Article_Print.asp?ArticleID=550&31& 调用[tiao yong]其它程序又要隐藏窗口[chuang kou]:用CreateProcess函数[han shu]调用[tiao yong][han shu tiao yong],再拿到窗口[chuang kou]句柄[ju bing],然后::ShowWindow(hWnd,SW_HIDE);32  读取[du qu]文本[wen ben]文件[wen jian]中的一行:   用CFile类的派生[pai sheng]类[pai sheng lei]:CStdioFile的方法[fang fa]:CStdioFile::ReadString33& 删除[shan chu]非空文件[wen jian]夹:&------------------------------------------------&SHFILEOPSTRUCT&& &shfileop.hwnd& =& NULL;& &shfileop.wFunc& =& FO_DELETE& ;& &shfileop.fFlags& =& FOF_SILENT|FOF_NOCONFIRMATION;& &shfileop.pFrom& =& "c:\\temp";&&&&&&& //要删除[shan chu]的文件[wen jian]夹&shfileop.pTo& =& "";& &shfileop.lpszProgressTitle& =& "";& &shfileop.fAnyOperationsAborted& =& TRUE;& &int& nOK& =& SHFileOperation(&shfileop); &-------------------------------------------------34& 函数[han shu]前面加上::是什么意思?   叫域运算[yun suan]符...在MFC中表示调用[tiao yong]API...或其它全局函数[han shu]...为了区分是 mfc函数[han shu]还是api   详见:&http://search.csdn.net/Expert/topic/.xml?temp=.9471247&35& CImageList的用法:&http://www.study888.com/computer/pro/vc/desktop/27.html&36& 有关控件的一些常见问答:&&&&&&&&& &http://fxstudio.nease.net/article/ocx/&&&&&&&&&&&& &==========================很不错的地方哦37& 在多文档[wen dang]客户[ke hu]区中增加位图[wei tu]底图演示程序[yan shi cheng xu]: &&&&&&&&& &http://www.study888.com/computer/pro/vc/desktop/28.html&&&& 我的对应工程:AddBackgroundBitmap38& 用VC++6.0实现PC机与单片机[dan pian ji]之间串行通信[tong xin]&&&&& &http://www.zahui.com/html/1/1710.htm&39& 日期到字符[zi fu]串[zi fu chuan]:&--------------------------------------------------&SYSTEMTIME&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_strT&SYSTEMTIME&&GetLocalTime(&systemtime);&&&& //这个函数[han shu]可获得毫秒级的当前时间[dang qian shi jian]&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& 任务[ren wu]栏上的图标[tu biao]闪烁[shan shuo]:   The FlashWindow function flashes the specified window once, whereas the FlashWindowEx function flashes a specified number of times.
&BOOL FlashWindow(&&HWND hWnd,&&&& // handle to window to flash&&BOOL bInvert&& // flash status& &&&);//闪烁[shan shuo]一次&FlashWindowEx()//闪烁[shan shuo]多次41& 十六进制[shi liu jin zhi]字符[zi fu]转浮点数[fu dian shu]:&http://community.csdn.net/Expert/topic/.xml?temp=.7092096&   long lValue = 0xB28A43;&&&&& float fV&&&&& memcpy(&fValue,&lValue,sizeof(float));42& 在一个由汉字组成的字符[zi fu]串[zi fu chuan]里,由于一个汉字由两个字节组成,怎样判断其中一个字节是汉字的第一个字节,还是第二个字节,使用IsDBCSLeadByte 函数[han shu]能够判断一个字符[zi fu]是否是双字的第一个字节,试试看:)& &_ismbslead& &_ismbstrail43& 如何实现对话框[dui hua kuang]面板[mian ban]上的控件随着对话框[dui hua kuang]大小变化自动调整[tiao zheng]   在OnSize中依其比例用MoveWindow同等缩放.http://www.codeproject.com/dialog/dlgresizearticle.asp44 向 CListCtrl中插入数据[shu ju]后,它总是先纵向再横向[heng xiang]显示[xian shi],我希望[xi wang]他先横向[heng xiang]再纵向&&&&& 在CListCtrl的ReDraw()中处理(见&http://community.csdn.net/Expert/topic/.xml?temp=.3442041&)&&&& 如:&&&&& m_list.ReDraw(FALSE);&&&&& m_list.ReDraw(TRUE);45& 给你的程序加上splash:&http://www.vckbase.com/document/finddoc.asp?keyword=splash&&&& 如何添加闪屏:Project-&Add to Project-&Components and Controls-&Gallery\\Visual C++ Components-&Splash screen46 实现象快速启动[qi dong]栏的"显示[xian shi]/隐藏桌面[zhuo mian]"一样的功能:&http://fxstudio.nease.net/article/form/55.txt&47  如何设置[she zhi]listview某行的颜色:   CSDN上的贴子:&http://community.csdn.net/Expert/topic/.xml?temp=2.&   Codeguru上相关链接[lian jie]:&http://www.codeguru.com/Cpp/controls/listview/backgroundcolorandimage/article./c1093/&48  如何得到窗口[chuang kou]标题栏尺寸:&http://community.csdn.net/Expert/topic/.xml?temp=.6934168&&GetSystemMetrics(SM_CYCAPTION 或者SM_CYSMCAPTION);
&SM_CYCAPTION Height of a caption area, in pixels. &SM_CYSMCAPTION Height of a small caption, in pixels.&--------------------------------------------------------&GetWindowRect(&rect);&rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) + 3;&--------------------------------------------------------49  如何将16进制的byte转成CString:&---------------------------------&BYTE p[3];&p[0]=0x01;&p[1]=0x02;&p[2]=0x12;&CS&str.Format("%02x%02x%02x", p[0], p[1], p[2]);&-------------------------------------50 怎样查找[cha zhao]到正处在鼠标[shu biao]下面的窗口[chuang kou](具体到子窗口[chuang kou][zi chuang kou]和菜单[cai dan]),无论是这个窗口[chuang kou]是否具有焦点:&-----------------------------------------------------------&POINT&CWnd* hW&&&&&& // Find out which window owns the cursor&GetCursorPos(&pt);&hWnd=CWnd::WindowFromPoint(pt);&if(hWnd==this)&{&&// 鼠标[shu biao]在窗体[chuang ti]中空白处,即不在任何控件或子窗口[chuang kou][zi chuang kou]当中&}
51 得到CListCtrl控件点击事件[shi jian]时点击的位置[wei zhi]:&-----------------------------------------------&void CTest6Dlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) &{NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;&&if(pNMListView-&iItem != -1)&&{&&&CS&&&strtemp.Format("单击[dan ji]的是第%d行第%d列", &&&pNMListView-&iItem, pNMListView-&iSubItem);&&&AfxMessageBox(strtemp);&&}&&*pResult = 0;&}&------------------------------------------------52& 如何在clistctrl的单元[dan yuan]格里添加图片?&http://community.csdn.net/Expert/topic/.xml?temp=.2233393&
53& 自己处理按键响应[xiang ying]函数[han shu]:&-------------------------------------------------&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();&&&&&&&&&&&&&&& //就调用[tiao yong]Button1的响应[xiang ying]函数[han shu]&&}&&}&return CDialog::PreTranslateMessage(pMsg);&}&---------------------------------------------------54& 如何在VC中操纵word:&http://www.vckbase.com/document/viewdoc/?id=1174&55& 两个像素[xiang su](用RGB表示)如何确定亮度[liang du]等级: &&&& 加权[jia quan]算出灰度[hui du]值:R*0.21+Green*0.70+Blue*0.09,或:&&&& ((红色[hong se]值 X 299) + (绿色值 X 587) + (蓝色值 X 114)) / 100056& 对已画在CDC上的图片进行处理,实现任意比例的透明[tou ming]度[tou ming du]。&MSDN:&http://msdn.microsoft.com/msdnmag/issues/05/12/CatWork/&实现方法[fang fa]是:1、用GetCurrentBitmap得到DC上的CBitmap指针[zhi zhen];2、用GetBitmapBits得到 CBitmap上的图像[tu xiang]数据[shu ju]流[shu ju liu];3、对图像[tu xiang]数据[shu ju]流[shu ju liu]中每个字节进行转换[zhuan huan],转换[zhuan huan]的公式为&&& pBits[i] += (255 - pBits[i]) * nTransparent / 100;//nTransparent为透明[tou ming]度[tou ming du]的百分率
57& MFC很多API函数[han shu]的源代码[dai ma][yuan dai ma]都在:VC安装[an zhuang]目录\VC98\MFC\SCR\WINCORE.cpp文件[wen jian]中。58& 自己写了个函数[han shu],用来获得ANSI字符[zi fu]串[zi fu chuan]中真实字符[zi fu]的个数,如“I服了U”的长度返回4:&--------------------------------------------------&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++;&&}&&&}&----------------------------------------------------59& 消息[xiao xi]传递[xiao xi chuan di]中pMSG中一些参数[can shu]的意义:&hwnd-------接收消息[xiao xi]的窗口[chuang kou]句柄[ju bing];&message---- 发送的消息[xiao xi]号;&wParam-----消息[xiao xi]参数[can shu],具体意义同发送的消息[xiao xi]有关;&lParam-----同上;&time------- 发送消息[xiao xi]时的时间,数值大小为自系统[xi tong]启动[qi dong][xi tong qi dong]以来经历的时间,单位[dan wei]是毫秒;&pt---------发送消息[xiao xi]时鼠标[shu biao]在屏幕[ping mu]上的绝对坐标,单位[dan wei]是像素[xiang su]。60& 刷新[shua xin]屏幕[ping mu]局部:刷新[shua xin]控件区域[qu yu]:控件ID:IDC_STATIC_STATIC&------------------------------------&CRect static_&CWnd *pwnd = GetDlgItem(IDC_STATIC_STATIC);&if (pwnd == NULL)&{&&&}&pwnd-&GetWindowRect(&static_rect);&ScreenToClient(&static_rect);&InvalidateRect(&static_rect);&&& //注意这个函数[han shu],会调用[tiao yong]OnEraseBkgnd&--------------------------------------61& VC实现录音,放音,保存,打开功能: &http://www.pconline.com.cn/pcedu/empolder/gj/vc/.html&62& 获得任务[ren wu]栏高度:&----------------------------------&HWND hWnd = FindWindow("Shell_TrayWnd", NULL);&RECT&::GetWindowRect(hWnd, &rc);&int iHeight = rc.bottom -rc.&-----------------------------------63& vc控制[kong zhi]word、excel的问题[wen ti]:&http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/vsofficedev.asp&&&& 下面还有范例[fan li]两个:         &http://www.vckbase.com/code/downcode.asp?id=2415&         &http://www.vckbase.com/code/downcode.asp?id=2397&
64 给ListBox控件加上水平滚动条[gun dong tiao]:m_list.SetHorizontalExtent(100); //m_list为和listbox控件绑定[bang ding]的CListBox变量[bian liang]65& 下拉式的工具条按钮:&http://community.csdn.net/Expert/topic/.xml?temp=.2334864&66  如何让MFC基于Dialog的程序在任务[ren wu]栏中显示[xian shi]:&http://community.csdn.net/Expert/topic/.xml?temp=.3407404&67  制作一个没有标题栏.菜单[cai dan]栏和工具栏的视窗,就象游戏界面[jie mian]一样:   &http://community.csdn.net/Expert/topic/.xml?temp=.568783&68  为何组合[zu he]框Droplist风格时响应[xiang ying]键盘[jian pan]PreTranslateMessage函数[han shu],而dropdown风格时不响应[xiang ying]:   &http://community.csdn.net/Expert/topic/.xml?temp=.8741419&69  直接用特殊字符[zi fu][te shu zi fu]的编码[bian ma]:s=WCHAR(0x00e6);&&&& //还没试过70 在标题栏上画图:&http://community.csdn.net/Expert/topic/.xml?temp=.8910944&71  如何精确延时:&http://www.vckbase.com/document/viewdoc/?id=1301&72  怎样给TreeView控件中的结点[jie dian]重命名:&http://community.csdn.net/Expert/topic/.xml?temp=.1730463&73  从内存[nei cun]中加载并启动[qi dong]一个exe :&http://community.csdn.net/Expert/topic/.xml?temp=.7619135&74  修改[xiu gai]一个EXE的资源[zi yuan]:&http://community.csdn.net/Expert/topic/.xml?temp=.5104029&75  使用并显示[xian shi]64bit数值的方法[fang fa]:    __int64 ld = *;&& //64bit数的范围[fan wei]:-75807&printf("%I64d\n",ld);76  在程序中使用console窗口[chuang kou]显示[xian shi]:&http://www.codeguru.com/Cpp/W-D/console/&&在里面找一下:Redirection77 用代码[dai ma]画鼠标[shu biao]图案并限定鼠标[shu biao]移动区域[qu yu](用ClipCursor函数[han shu]):    &http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors/usingcursors.asp&78  改变编辑框字体[zi ti]的大小:&http://community.csdn.net/Expert/topic/.xml?temp=.2317163&  先在对话框[dui hua kuang]类的内部声明[sheng ming]一个CFont对象[dui xiang],如:CF&---------------------------------&myfont.CreatePointFont(500, "Arial");&GetDlgItem(IDC_EDIT1)-&SetFont(&myfont);&---------------------------------79  bmp图片怎么转换[zhuan huan]为jpg:  用cximage  &http://www.codeproject.com/&上有80 字符[zi fu]串[zi fu chuan]转成UTF-8格式参考[can kao]CSDN上的FAQ:&http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=191432&81  将16进制字符[zi fu]串[zi fu chuan]转换[zhuan huan]成10进制整数:   char a[3]="ab";   DWORD val = strtoul(a, NULL, 16);82 快速从数字[shu zi]的字符[zi fu]串[zi fu chuan]中提取[ti qu]出特定长度的数字[shu zi]:&-------------------------------------------------------&int a[4];&sscanf("5","%07d%02d%02d%02d",&a[0],&a[1],&a[2],&a[3]);&& //按指定长度分隔&--------------------------------------------------------  或:&-------------------------------------------------------&CString s="aaa,bbb,ccc,ddd";&char a1[4],a2[4],a3[4],a4[4];&&&&&&&&&&&&&&&&&&&&&& //这里要注意多留点空间[kong jian]以存放各子串[zi chuan]的长度&sscanf(s,"%[^,],%[^,],%[^,],%[^,]",a1,a2,a3,a4);&&& //按指定字符[zi fu](这里是逗号)分隔&AfxMessageBox(a4);//显示[xian shi]ddd&-------------------------------------------------------83  配置[pei zhi]文件[wen jian][pei zhi wen jian]的配置[pei zhi]项[pei zhi xiang]可不可以删除[shan chu]:&http://community.csdn.net/Expert/topic/.xml?temp=.4008448&84  如何改变CListCtrl包括Scrollbars和Column Headers的颜色和风格:&http://www.codeguru.com/Cpp/controls/listview/backgroundcolorandimage/print.php/c4185/&85  根据ComboBox加入的字符[zi fu]串[zi fu chuan]的长度自动调整[tiao zheng]ComboBox控件的宽度:  //这里假设为ComboBox加入两个字符[zi fu]串[zi fu chuan]   CString str1="中华人民共和国中华人民共和国",str2="3中国";  m_combo.AddString(str1);&&& //m_combo为绑定[bang ding]在组合[zu he]框控件的变量[bian liang]  m_combo.AddString(str2);  int len=str1.GetLength()*6.2;&& //根据加入的字符[zi fu]串[zi fu chuan]长度(以字节为单位[dan wei])和组合[zu he]框使用的默认[mo ren]字体[zi ti]的大小计算组合[zu he]框实际需要的宽度,计算中间用到了整数-&浮点数[fu dian shu]-&整数的两次数值类型[lei xing][zhi lei xing]隐式[yin shi]转换[zhuan huan],也可以用winAPI函数[han shu]GetTextExtentPoint32()或GetTextExtent计算   m_combo.SetDroppedWidth(len);86 弹出U盘:&http://community.csdn.net/Expert/topic/.xml?temp=.8724634&87  往另一个程序的编辑框中发送文字[wen zi]:句柄[ju bing]-&SendMessage(WM_SETTEXT,strlen(buf), (LPARAM)buf);&&& //buf为你要加入的char*88 如何在RichEdit中加超链接[lian jie][chao lian jie]:&http://community.csdn.net/Expert/topic/.xml?temp=9.&89  VC控件的用法:&http://www.vckbase.com/document/indexold.html&90  学习[xue xi]资源[zi yuan]:&http://code.ddvip.net/list/sort.html&91  在初始时候定位[ding wei]到LIST的指定行(如第100行)开始显示[xian shi]:EnsureVisible(100)&&&&& //未验证[yan zheng]92 如何在app中SetTimer():&http://community.csdn.net/Expert/topic/.xml?temp=6.&             &http://search.csdn.net/Expert/topic/.xml?temp=.5501825&93  一个基于SDK的软键盘[jian pan]的范例[fan li],可以学习[xue xi]如何发送虚拟[xu ni]按键或鼠标[shu biao]消息[xiao xi]:&http://www.codeproject.com/cpp/togglekeys.asp&94  MDI文档[wen dang]中的字体[zi ti]、及其颜色怎么设置[she zhi]:&http://community.csdn.net/Expert/topic/.xml?temp=.7866938&95  自己捕捉特定的组合[zu he]键:&http://community.csdn.net/Expert/topic/.xml?temp=.7411157&&&&&&&&&&&&&&&&&&&&&&&&&& &http://community.csdn.net/Expert/topic/.xml?temp=.3993799&&--------------------------------------------------------------&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组合[zu he]键。") ;&&&&&&}&&&&}&&&}&&&&&&&& &&return CDialog::PreTranslateMessage(pMsg);&}&-------------------------------------------------------------&另外,GetAsyncKeyState和::GetKeyState这两个函数[han shu]也可以帮你检测Shift、Ctrl和Alt这些键的状态[zhuang tai]。96 快速从得到的全路径[lu jing]文件[wen jian]名[wen jian ming]中分离出盘符、路径[lu jing]名[lu jing ming]、文件[wen jian]名[wen jian ming]和后缀[hou zhui]名:&------------------------------------------------&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);&&&& //用这个函数[han shu]转换[zhuan huan]&------------------------------------------------97  如何debug除零错误[cuo wu]:&http://community.csdn.net/Expert/topic/.xml?temp=.2427484&98  修改[xiu gai]VS.net“工具”栏中菜单[cai dan]的默认[mo ren]图标[tu biao]:&http://www.codeproject.com/dotnet/vsnet_addin_icon_change.asp&99  在窗口[chuang kou]的标题栏和菜单[cai dan]栏上象realplayer那样添加自己的logo:&http://www.codeproject.com/menu/menuicon.asp&100  个性化的位图[wei tu]菜单[cai dan],自己从CMenu派生[pai sheng]子类[zi lei]实现:&http://www.codeguru.com/Cpp/controls/menu/bitmappedmenus/article.php/c165&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &http://www.codeguru.com/Cpp/controls/menu/bitmappedmenus/article.php/c163&101  怎样取得程序自己占用的内存[nei cun]和CPU占用率:GetProcessMemoryInfo和GetPerformanceInfo102 如何让你的程序运行[yun hang]在release模式[mo shi]下:build-&set active configuration103 监视文件[wen jian]夹是否被更新:FindFirstChangeNotification、 FindNextChangeNotification、FindCloseChangeNotification这三个函数[han shu]&&&&&&&&&&&& 范例[fan li]见:&http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/obtaining_directory_change_notifications.asp&105  动态[dong tai]菜单[cai dan]:&http://community.csdn.net/Expert/topic/.xml?temp=.2887384&&&&http://community.csdn.net/Expert/topic/.xml?temp=.2409326&106  如何获取客户[ke hu]区的中心坐标:&http://community.csdn.net/Expert/topic/.xml?temp=8.&107  强行操作内存[nei cun]虚拟[xu ni]地址[di zhi][xu ni di zhi]中某个指定地方的内容:&----------------------------------------------    int *a=(int*)0x;&&&& //这里以访问0x地址[di zhi]为例&cout&&*a&&&----------------------------------------------108  如何响应[xiang ying]条码[tiao ma]机:&http://community.csdn.net/Expert/topic/.xml?temp=.1966516&     条码[tiao ma]扫描[sao miao]仪[sao miao yi]主要有三种接口[jie kou]: 1.RS232 2.共用接盘接口[jie kou] 3.USB外设[wai she].& 对于RS232,需要编程[bian cheng]来监视和读取[du qu]条码[tiao ma]; 对于共用接盘接口[jie kou],条码[tiao ma]信息[xin xi]被转换[zhuan huan]成相应的键盘[jian pan]消息[xiao xi],具有输入[shu ru]焦点的应用[ying yong]程序[ying yong cheng xu]会收到键盘[jian pan]输入[shu ru]消息[xiao xi],我们以前的做法是做一个全局keyboard Hook或应用[ying yong]程序[ying yong cheng xu]级别上 keyboard hook, 监视键盘[jian pan]消息[xiao xi],当有连续[lian xu]的键盘[jian pan]消息[xiao xi](在很短的时间内),并且这些键盘[jian pan]字符[zi fu]能构成完成的条码[tiao ma]信息[xin xi],就产生一条自定义消息[xiao xi][zi ding yi xiao xi],通知[tong zhi]窗口[chuang kou](向监视程序注册[zhu ce]的窗口[chuang kou]) 条码[tiao ma]信息[xin xi]到达,条码[tiao ma]机只是相当于一个键盘[jian pan],所以你也可以在界面[jie mian]上放一个edit框,条码[tiao ma]机读出条码[tiao ma]后还会在字符[zi fu]串[zi fu chuan]后面加一个回车(这个一般是可设置[she zhi]的,可加可不加),如果条码[tiao ma]机自动加回车,则你重写[zhong xie]OnOK函数[han shu],将edit框的内容取出放入list即可。
当然也可不放edit框,而直接接收键盘[jian pan]字符[zi fu](比如重写[zhong xie]OnChar函数[han shu]等,方法[fang fa]很多),但要考虑到这种情况[qing kuang]:条码[tiao ma]读不出来的情况[qing kuang],此时应该用手动输入[shu ru][shou dong shu ru]条码[tiao ma],所以还是放一个edit框为好。
109 检查指定文件[wen jian]夹是否存在:PathIsDirectory()&方法[fang fa]一:&&检查给定路径[lu jing]是否根目录[gen mu lu]:BOOL PathIsRoot(LPCTSTR pPath);&&说明[shuo ming]:Returns TRUE for paths such as “\”, “ X:\”, “\\ server\ share”, or “\\ server\”。Paths such as “..\path2” will return FALSE.    &用这两个函数[han shu]要先:#include &shlwapi.h&;&&&&&&& &再把这个文件[wen jian]加入工程:shlwapi.lib&方法[fang fa]二:&&GetFileAttributes检查文件[wen jian]是否存在,并且检查是否文件[wen jian]夹属性[shu xing]FILE_ATTRIBUTE_DIRECTORY&----------------------------------------------------------&DWORD = GetFileAttributes(_T("f:\\win98"));&if(dwAttr != 0xFFFFFFFF && (dwAttr & FILE_ATTRIBUTE_DIRECTORY))&&cout&&"exist"&&&else&&cout&&"NOT exist"&&&----------------------------------------------------------&方法[fang fa]三:&&用下面第113条的_access函数[han shu]同样可以&----------------------------------------------------------&if(_access("f:\\win98",0)!=-1)&&cout&&"exist"&&&else&&cout&&"NOT exist"&&&----------------------------------------------------------&方法[fang fa]四:&&用PathFileExists函数[han shu],见MSDN介绍,需要的条件[tiao jian]同方法[fang fa]一。&还有一个:BOOL SHGetPathFromIDList(LPCITEMIDLIST pidl,LPTSTR pszPath);&  Converts an item identifier list to a file system path.110 去掉单文档[wen dang]标题栏上的“无标题—”:&http://community.csdn.net/Expert/topic/.xml?temp=.2896997&111  打开显示[xian shi]器[xian shi qi]: ::SendMessage(GetSafeHwnd(), WM_SYSCOMMAND, SC_MONITORPOWER, -1);& //从bobob的blog上抄来的^_^   关闭显示[xian shi]器[xian shi qi]:  ::SendMessage(GetSafeHwnd(), WM_SYSCOMMAND, SC_MONITORPOWER, 1);& //从bobob的blog上抄来的^_^   得到它的工作状态[zhuang tai]:休眠[xiu mian]状态[zhuang tai][xiu mian zhuang tai]是指用 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 "&file://./Display&#", while the # index is 1-based, or "&file://./LCD&", for security reasons. If you are trying to do this on Windows XP, then you can use SetupDiGetDeviceRegistryProperty and Property: SPDRP_DEVICE_POWER_DATA to get the power management information. This is documented in the Windows XP DDK. 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_b47bb-44af-9d04-107ff1299381.xml.asp&&http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_desktopmonitor.asp&112  得到系统[xi tong]时间、语言[yu yan]等的设置[she zhi]&GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ITIME, lpLCData, cchData);& //从bobob的blog上抄来的^_^113 文件[wen jian]是否存在(记得先包含头文件[wen jian]#include &io.h&)&----------------------------------&if(_access("c:\\somefile.txt",0)!=-1)&&// 存在&else&&//不存在&---------------------------------&还有一个方法[fang fa]:&---------------------------------------------&if(GetFileAttributes("f:\\test.txt")!=0xFFFFFFFF)&{&&// 存在&}&else&{&&//不存在&}&---------------------------------------------114  得到剪贴板[jian tie ban]数据[shu ju]&-------------------------------------------------&if ( OpenClipboard() )&&&&&&&&&&&&&&&&&&&&&& &{&&HANDLE hData = GetClipboardData(CF_TEXT);&&char * buffer = (char*)GlobalLock(hData);&&&& //剪贴板[jian tie ban]中的文本[wen ben]内容保存在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",&&&&&&&&&&&&&&&&&&&&&&& //只能显示[xian shi].bmp文件[wen jian]&&IMAGE_BITMAP,&&0,0,LR_CREATEDIBSECTION |LR_DEFAULTSIZE |LR_LOADFROMFILE));&----------------------------------------------116  显示[xian shi]一个打开文件[wen jian]夹的对话框[dui hua kuang],并得到用户[yong hu]选择[xuan ze]的目录:&-------------------------------------------&char szDir[MAX_PATH];&BROWSEINFO&ITEMIDLIST *&bi.hwndOwner = this-&m_hW&bi.pidlRoot = NULL;&bi.pszDisplayName = szD&bi.lpszTitle = "请选择[xuan ze]目录";//strDlgT&bi.ulFlags = BIF_RETURNONLYFSDIRS;&bi.lpfn = NULL;&bi.lParam = 0;&bi.iImage = 0;
&pidl = SHBrowseForFolder(&bi);&if(pidl == NULL) &&if(!SHGetPathFromIDList(pidl, szDir)) &&AfxMessageBox(szDir);&&& //szDir中存放的内容为用户[yong hu]选定的目录&------------------------------------------------117  去除字符[zi fu]串[zi fu chuan]中指定的字符[zi fu]:&-----------------------------------------&CS&strtemp.Format("%s","abc\n123\ndef");&strtemp.Remove('\n');&&&& //这里以去除换行[huan hang]符为例,结果保存在strtemp中了&-------------------------------------------118  有关数据[shu ju]结构[jie gou][shu ju jie gou]的地址[di zhi]:&http://student.zjzk.cn/course_ware/data_structure/web/main.htm&119  假如当前时间[dang qian shi jian],如何计算在该时间前12345天,是哪年哪月哪日?&---------------------------&CTime tm(,0,0,0);&tm-=;&cout&&tm.Format("%Y-%m-%d")&&&----------------------------120  PeekMessage是干什么用的: &http://community.csdn.net/Expert/topic/.xml?temp=.8852045&121  拖动[tuo dong]控件时实现类似windows拖动[tuo dong]窗口[chuang kou]的效果:CRectTracker&&& Mackz朋友的blog中有它的范例[fan li]:&http://blog.csdn.net/Mackz/archive//517747.aspx&122  有关UNICODE、ANSI字符[zi fu]集[zi fu ji]和相关字符[zi fu]串[zi fu chuan]操作的总结:&http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=199372&123  寻找系统[xi tong]中的打印机[da yin ji]:EnumPrinters&&&&&&&&&&&&&& 124 用代码[dai ma]加入外部模块[mo kuai]的方法[fang fa]:#pragma comment(lib,"mylib.lib")125 判断指定点是否在一个矩形框内:CRect::PtInRect(POINT point)126 winAPI 函数[han shu]GetTextExtentPoint32()可以得出一个以像素[xiang su]为单位[dan wei]的字符[zi fu]串[zi fu chuan]的宽度。127 RGB转换[zhuan huan]成 YV12(YUV 4:2:0)的方法[fang fa]:&http://www.fourcc.org/fccyvrgb.php&128  获得指定进程[jin cheng]占用内存[nei cun]的情况[qing kuang],用GetProcessMemoryInfo()函数[han shu]。129 把CONSOLE程序的输出[shu chu]导入到文件[wen jian]中,用程序控制[kong zhi][cheng xu kong zhi]:&http://community.csdn.net/Expert/topic/.xml?temp=.7469599&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &http://www.codeproject.com/dialog/quickwin.asp&130  把CRichEditCtrl中的文字[wen zi]保存到rtf文件[wen jian]:&http://community.csdn.net/Expert/topic/.xml?temp=.1313135&&&&&    在codeproject上还有从CRichEditCtrl类派生[pai sheng]新类的,功能增强[zeng qiang]了很多:&http://www.codeproject.com/richedit/autoricheditctrl.asp&   还有一个开发类似写字板那样程序的完整范例[fan li]:&http://www.codeproject.com/tools/simplewordpad.asp&131  MFC中使用ATL字符[zi fu]转换[zhuan huan]宏:在你的函数[han shu]开关加上USES_CONVERSION;语句[yu ju],详见MSDN或这里:&http://community.csdn.net/Expert/topic/.xml?temp=.6256983&132  如何建立共享目录:直接调用[tiao yong]标准的Win32API函数[han shu]NetShareAdd和NetShareDel   详见MSDN及:&http://community.csdn.net/Expert/topic/.xml?temp=.4405023&133  位图[wei tu]文件[wen jian]读写[du xie]基础:&http://www.vckbase.com/document/viewdoc/?id=674&134  用VC实现支持[zhi chi]多语言[yu yan]的程序:&http://www.vckbase.com/document/viewdoc/?id=1102&&&&&&&&&&&&&&&&&& //还没试过,以后用到了再仔细研究吧135 Menu系列函数[han shu]:&&&& GetMenu&&&& GetMenuInfo&&&& GetMenuItemCount&&&& GetMenuItemID&&&& GetMenuString&&&& EnableMenuItem &&&& CheckMenuItem&&&& ModifyMenu&&&& RemoveMenu&&&& InsertMenu&&&& GetSystemMenu&&&& ::LoadMenu&&&& ::SetMenu136 得到SYSTEMMENU(系统[xi tong]菜单[cai dan])的高度:GetSystemMetrics(SM_CYMENU);   得到当前屏幕[ping mu]分辨率[fen bian lv]:&GetSystemMetrics(SM_CXFULLSCREEN);&&&&& //得x值(如1024)&GetSystemMetrics(SM_CYFULLSCREEN);&&&&& //得y值( 如768-任务[ren wu]栏高度)&&&& 此外这个函数[han shu]还可以得到很多别的系统[xi tong]设置[she zhi]值,详见MSDN:&http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp&137  在属性[shu xing]页控件的标签上加图片:&http://www.codeguru.com/cpp/controls/propertysheet/article.php/c611/&&&&&&http://community.csdn.net/Expert/topic/.xml?temp=.9977991&&--------------------------------------------------&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 tcI&tcItem.mask = TCIF_IMAGE;&for( int i = 0; i & 3; i++ )&{&&tcItem.iImage =&&pTab-&SetItem( i, &tcItem );&}&return bR&}&----------------------------------------------------138  这里有很多CRichEditCtrl控件的高级用法:&http://www.codeguru.com/Cpp/controls/richedit/&139  CGridCtrl控件的一些应用[ying yong]:&http://www.vckbase.com/code/listcode.asp?mclsid=3&sclsid=327&140  一个不错的地方:&http://www.vckbase.com/document/listdoc.asp?mclsid=3&sclsid=323&141  怎样使右键[you jian]菜单[cai dan]也能变灰、打勾:&http://community.csdn.net/Expert/topic/.xml?temp=.4074823&142  MD5加密[jia mi]解密[jie mi]的API:&http://community.csdn.net/Expert/topic/.xml?temp=.6894647&&MD5Init&MD5Final&MD5Update143  用CBrush::CreateStockObject(HOLLOW_BRUSH);或 CBrush::CreateStockObject(NULL_BRUSH);这两个可以创建镂空的画刷。144 创建不规则窗体[chuang ti]:&http://www.vckbase.com/document/viewdoc/?id=1345&145  拖动[tuo dong]一个没有标题栏的窗体[chuang ti]:&http://community.csdn.net/Expert/topic/.xml?temp=6.&146  屏蔽[ping bi]浏览[liu lan]器[liu lan qi]中的弹出广告,下面地址[di zhi]中是在ATL中采用BHO服务的方法[fang fa]:&http://www.codeproject.com/atl/popupblocker2.asp&&CSDN 上有个讨论贴:&http://community.csdn.net/Expert/topic/.xml?temp=.157284&147  远程线程[xian cheng]注入:&&http://www.codeproject.com/threads/RmThread.asp&&&http://www.codeproject.com/library/InjLib.asp&&&http://www.codeproject.com/win32/Remote.asp&148  CEditView中两个函数[han shu]的用法:&GetEditCtrl().ModifyStyle (0& , WS_VSCROLL |ES_AUTOHSCROLL&& |ES_AUTOVSCROLL& |WS_HSCROLL |ES_WANTRETURN | ES_MULTILINE);&GetEditCtrl().GetSel(m_nStartChar, m_nEndChar ) ;149 给对话框[dui hua kuang]窗体[chuang ti]底部加上状态[zhuang tai]条,把下面代码[dai ma]加进对话框[dui hua kuang]的OnInitDialog()函数[han shu]中:&-----------------------------------------------------------&static UINT indicators[] =&{&&ID_SEPARATOR,&&&&&&&&&& // status line indicator&&ID_INDICATOR_CAPS,&&ID_INDICATOR_NUM,&&ID_INDICATOR_SCRL,&}; &//下面m_wndStatusBar必须先在对话框[dui hua kuang]类中声明[sheng ming]:CStatusBar m_wndStatusB&if (!m_wndStatusBar.Create(this,WS_CHILD|WS_VISIBLE|WS_BORDER)||&&!m_wndStatusBar.SetIndicators(indicators,&&& sizeof(indicators)/sizeof(UINT)))&{&&&&&&&& AfxMessageBox("Status Bar not created!", NULL, MB_OK );&& &}&CR&this-&GetWindowRect(&rect);&m_wndStatusBar.MoveWindow(2,rect.bottom-GetSystemMetrics(SM_CYSIZE)-27,rect.Width()-4,20);&m_wndStatusBar.ShowWindow(SW_SHOW);&m_wndStatusBar.SetWindowText("Ready");&-----------------------------------------------------------&把上面代码[dai ma]加在OnInitDialog里,注意:m_wndStatusBar变量[bian liang]的声明[sheng ming]语句[yu ju]CStatusBar m_wndStatusB要放在你的对话框[dui hua kuang]类C****Dlg中才行。150 从注册[zhu ce]表中读取[du qu]cpu的频率[pin lv]:&读取[du qu] ~MHz 这个键值 ,记住那键前有个~别忘了,在注册[zhu ce]表的HKEY_LOCAL_MACHINE\\Hardware\\Description\\System \\CentralProcessor\\0& //0 为第一个cpu&&&&&&&&&&& Hardware\\Description\\System\\CentralProcessor\\1& //1 为第二个cpu  得到cpu的数量,摘自:&http://community.csdn.net/Expert/topic/.xml?temp=.7182123&&-----------------------------------------------------------------------&SYSTEM_INFO siSysI&GetSystemInfo(&siSysInfo); &printf("& Number of processors: %u\n", siSysInfo.dwNumberOfProcessors);&-----------------------------------------------------------------------151  改变CStatic控件的前景、背景色[bei jing se]:&http://community.csdn.net/Expert/topic/.xml?temp=.1524164&&处理WM_CTLCOLOR消息[xiao xi]:&---------------------------------------------------------------------&HBRUSH CQQDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) &{&&HBRUSH&&&// TODO: Change any attributes of the DC here&&if(CTLCOLOR_STATIC == nCtlColor)&&//if(CTLCOLOR_STATIC == nCtlColor && pWnd-&GetDlgCtrlID()==IDC_TOOL)& //改成这样就只对IDC_TOOL这一个静态文本[wen ben]控件起作用[zuo yong]了&&{&&&pDC-&SetBkColor(RGB(255,255,255));&&&&&&&& //背景色[bei jing se]为白&&&pDC-&SetTextColor(RGB(0,0,0));&&&&&&&&&&&& //前景色[qian jing se]为黑&&&hbr = CreateSolidBrush(RGB(255,255,255));& //其它区域[qu yu]也为白&&&//上面三行代码[dai ma]改成下面这三行就创建空心刷子,就可以实现在背景上写字的效果了&&&//pDC-&SetBkMode(TRANSPARENT);&&&//pDC-&SetTextColor(RGB(0,0,0));&&&//hbr = CreateStockObject(NULL_BRUSH);&&&& &&}&&else&&&hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);&&// TODO: Return a different brush if the default is not desired&&&}&----------------------------------------------------------------------&再加一个判断if (pWnd-&GetDlgCtrlID()==IDC_....)就可以指定是改变哪个的颜色了,其它控件的颜色的改变方法[fang fa]和这个大同小异。152  怎样获得字体[zi ti]得宽度,高度,间距等信息[xin xi]:GetTextMetrics153 为了让你对i++有个更清楚的认识,先看如下代码[dai ma]:&-------------------&int i=2;&i=(i++) % 3;&printf("i=%d",i);&&&&&&&&&&&&& //这里输出[shu chu]i=?呢&-------------------&下面是前两行代码[dai ma]的汇编[hui bian]代码[dai ma]:&------------------------------------------------------------------------------------------------------------------&&& mov&&&&&&&& dword ptr [ebp-4],2&&&&&&& 把值2写入内存[nei cun]中[ebp-4]指向[zhi xiang]的位置[wei zhi](后面称变量[bian liang]i)& //相当于i=2&0040177F&& mov&&&&&&&& eax,dword ptr [ebp-4]&&&&& 把i的当前值2赋于eax中&&&&&&&&&&&&&&&&&&&&&&&&& //把eax当成了i的临时变量[bian liang]了&&& cdq&&& mov&&&&&&&& ecx,3&&&&&&&&&&&&&&&&&&&&& 把3赋于ecx中&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //同样ecx也成了临时变量[bian liang]了&&& idiv&&&&&&& eax,ecx&&&&&&&&&&&&&&&&&&& eax % ecx(2%3),结果放入edx中(等于2)&0040178A&& mov&&&&&&&& dword ptr [ebp-4],edx&&&&& 把edx中的值2写入变量[bian liang]i&&&&&&&&&&&&&&&&&&&&&&&&& //相当于计算i=2 % 3&&&&& &0040178D&& mov&&&&&&&& edx,dword ptr [ebp-4]&&&&& 把i的值2赋于edx&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //现在edx成了i的临时变量[bian liang]&&& add&&&&&&&& edx,1&&&&&&&&&&&&&&&&&&&&& edx中的值加上1&&& mov&&&&&&&& dword ptr [ebp-4],edx&&&&& 把edx中的值3写入变量[bian liang]i&&&&&&&&&&&&&&&&&&&&&&&&& //上面三条命令[ming ling]完成i=i+1&------------------------------------------------------------------------------------------------------------------&最终的结果i=3,如果把运算[yun suan]符%换成+,则结果i=6(注意,这是在VC下得到的结果,不同的编译[bian yi]器[bian yi qi]得到的结果可能会不同!)154 我的程序知道一个应用[ying yong]程序[ying yong cheng xu]的句柄[ju bing],如何使该应用[ying yong]程序[ying yong cheng xu]得到焦点:&http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=192872&&---------------------------------------------------------------&if(::GetForegroundWindow()!=m_MainWnd)& &&::SetForegroundWindow(m_MainWnd);& &::SetFocus(& m_MainWnd);& &---------------------------------------------------------------& &&或:&------------------------------------&::ShowWindow(m_MainWnd,& SW_SHOW);& &::SetForegroundWindow(m_MainWnd);&------------------------------------155  在对话框[dui hua kuang]的标题栏上添加按钮:&http://www.codeguru.com/Cpp/W-D/dislog/titlebar/article.php/c1897&156  判断当前线程[xian cheng]的当前输入[shu ru]法是中文[zhong wen]还是英文输入[shu ru]法(至于到底是哪种中文[zhong wen]输入[shu ru]法我也不知道):&-------------------------------------------------------------------------&HKL hKl = GetKeyboardLayout(0);& //这里0表示当前线程[xian cheng],要查指定线程[xian cheng]的话可以用指定线程[xian cheng]的标识[biao shi]符[biao shi fu]代替&if (ImmIsIME(hKl))&&AfxMessageBox("当前是中文[zhong wen]输入[shu ru]法。");&-------------------------------------------------------------------------&其它地区语言[yu yan]输入[shu ru]法的信息[xin xi]在MSDN中搜索[sou suo]:Table of Language Identifiers157 动态[dong tai]创建静态控件[jing tai kong jian]并加载.bmp图片,先在对话框[dui hua kuang]类中定义成员变量[bian liang][cheng yuan bian liang]:&----------------------------------------------------&public:&CStatic m_&&& //这个是在对话框[dui hua kuang]类中定义的&再:&CB&cb.LoadBitmap(IDB_BITMAP1);&m_pp.Create("",WS_CHILD|WS_VISIBLE|SS_BITMAP,CRect(10,10,200,200),this,101);&m_pp.SetBitmap((HBITMAP)cb);&----------------------------------------------------158  DLL中创建窗口[chuang kou]时对于资源[zi yuan]等,需要先进行状态[zhuang tai]处理:AFX_MANAGE_STATE(AfxGetStaticModuleState( ));159 把图片中某种指定色变成透明[tou ming]色,在对话框[dui hua kuang]的OnPaint()中加入类似如下代码[dai ma]:&-------------------------------------------------------------------------------&//CImage imgO&int XWitdh=imgOriginal.GetWidth();&int XHeight=imgOriginal.GetHeight();&COLORREF TransparentColor= RGB(0x00,0x00,0x00);&&&& //这里黑色变成透明[tou ming]色&CPaintDC dc(this);&imgOriginal.TransparentBlt(dc.m_hDC,0,0,XWitdh,XHeight,TransparentColor);&imgOriginal.StretchBlt(dc,0,0,imgOriginal.GetWidth()/2,imgOriginal.GetHeight()/2,SRCCOPY);&-------------------------------------------------------------------------------160  怎么修改[xiu gai]MFC单文档[wen dang]程序的标题,经常有人在网上问这个问题[wen ti],在C****App::InitInstance()的代码[dai ma]中加入一行就行了:&-----------------------------------------------------------&BOOL CJPGGifApp::InitInstance()&{&&AfxEnableControlContainer();&&......&&&&& //这里省略自动生成的代码[dai ma]&&// The one and only window has been initialized, so show and update it.&&m_pMainWnd-&ShowWindow(SW_SHOW);&&m_pMainWnd-&UpdateWindow();&&m_pMainWnd-&SetWindowText(" 我的标题");&&& //加入这一行就可以了,注意要加在ShowWindow和UpdateWindow的后面
&&return TRUE;&}&------------------------------------------------------------161  怎么使用双缓冲防闪烁[shan shuo]:&http://community.csdn.net/Expert/topic/.xml?temp=5.&&&&&&&&&&&&&&&&&&&&&&&&&& &==========还没试,不知道有没有效[you xiao]果162 鼠标[shu biao]左右键[you jian]同时按下与鼠标[shu biao]与键盘[jian pan]同时按下的识别[shi bie]:&http://www.vckbase.com/article/misc/0017.htm&
  玩过Windows的扫雷游戏吗?该游戏中就有一个同时按下鼠标[shu biao]左右键[you jian]的操作,其实对同时按下鼠标[shu biao]左右键[you jian]的判断并不复杂,判断方法[fang fa]与判断鼠标[shu biao]按键是否与Ctrl和Shift同时按下的方法[fang fa]相同,这里要用到鼠标[shu biao]消息[xiao xi]中的wparam项,其中含有我们想要的几个按键的状态[zhuang tai]。定义如下:
  (1)MK_CONTROL:Ctrl键按下时置1;
  (2)MK_LBUTTON:鼠标[shu biao]左键按下时置1;
  (3)MK_MBUTTON:鼠标[shu biao]中键按下时置1;
  (4)MK_RBUTTON:鼠标[shu biao]右键[you jian]按下时置1;
  (5)MK_SHIFT:Shift键按下时置1。
  通过判断这几个标志位可以得到同时按下的几个键的状态[zhuang tai],从而判断是否有其它键同时按下。
163 数据[shu ju]库[shu ju ku]方面:&http://community.csdn.net/Expert/topic/.xml?temp=.2734644&&&&&&&&&&&&& &===================还没试164 取得Excel中文[zhong wen]本[wen ben]框的内容:&http://community.csdn.net/Expert/topic/.xml?temp=.41&165  Microsoft Office Development with Visual Studio:&http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/vsofficedev.asp&166  让编译[bian yi]器[bian yi qi]忽略某种警告:&--------------------------------&#pragma warning (disable : 4101)&--------------------------------&上面的代码[dai ma]加上后编译[bian yi]器[bian yi qi]不会再出现warning C4101: 'i' : unreferenced local variable这样的警告了。 167 枚举[mei ju]网页[wang ye]各个元素,参考[can kao]:&&http://www.vckbase.com/document/viewdoc/?id=288&&&http://www.vckbase.com/document/viewdoc/?id=1446&168  rundll32.exe,这个程序很方便,用它可以调用[tiao yong]任何 DLL 中的函数[han shu]。你只要给它提供 DLL、函数[han shu]名以及要传递的参数[can shu]即可。Rundll32.exe 绝对多才多艺,你可以用它来关闭和重启[zhong qi] Windows,创建快捷方式以及启动[qi dong]控制[kong zhi]面板[mian ban]程序。只要知道要调用[tiao yong]的DLLs,一切都搞掂。你可以象下面这样用 rundll32.exe 从命令[ming ling]行[ming ling hang]打开一个 URL:&--------------------------------------------------------&rundll32.exe url.dll,FileProtocolHandler &http://www.vckbase.com/&&--------------------------------------------------------&url.dll 中的函数[han shu] FileProtocolHandler 负责这个工作。169 HDC===&CDC*&----------------------------------&HDC hdc=::GetWindowDC(this-&m_hWnd);&&&& //获得窗口[chuang kou]标题栏区域[qu yu]&CDC* pDC = CDC::FromHandle(hdc);&----------------------------------&&&& CDC*===&HDC,可以通过CDC的操作符[cao zuo fu]HDC()来实现:&------------------&HDC hdc=HDC(pDC);&&&&& //或:HDC hdc=pDC-&m_&------------------170 操作状态[zhuang tai]栏[zhuang tai lan],下面以在状态[zhuang tai]栏[zhuang tai lan]中显示[xian shi]鼠标[shu biao]当前坐标为例,代码[dai ma]如下:&-------------------------------------------------------------------------------------------&CMyView::OnMouseMove(UINT nFlag,CPoint point)&{&&CClientDC dc(this);&&CMainFrame *pFrame = (CMainFrame *)AfxGetApp()-&m_pMainW&&CStatusBar *pStatusBar = (CStatusBar *)&pFrame-&m_wndStatusB&&CS&&str.Format("x:%d,y:%d",point.x,point.y);&&CSize size = dc.GetTextExtent(str);&&&&&&& //得到文本[wen ben]所需的大小尺寸&&int nIndex = pStatusBar-&CommandToIndex(ID_INDICATOR_MOUSEPOS);&&pStatusBar-&SetPaneInfo(nIndex,ID_INDICATOR_MOUSEPOS,SBPS_NORMAL,size.cx);&& //按文本[wen ben]所需的宽度设置[she zhi]状态[zhuang tai]栏[zhuang tai lan]宽度&&pStatusBar-&SetPaneText(nIndex,str);
&&CView::OnMouseMove(nFlags, point);&}&-------------------------------------------------------------------------------------------171  一些工具的简单介绍:&http://www.yesky.com/SoftChannel/06/1918484.shtml&172  一个有争论的问题[wen ti],关于delete p和delete []p的区别所在:&http://community.csdn.net/Expert/topic/.xml&&&&&&&&&http://community.csdn.net/Expert/topic/.xml?temp=.5596582&173  GetDeviceCaps,一个可得到很多关于指定设备的具体信息[xin xi]的函数[han shu]174 注册[zhu ce]表中:HKEY_CURRENT_USER\KeyboardLayout\preload分支[fen zhi]下分别有输入[shu ru]法对应的1、2、3、4几个主键,其键值一一对应已安装[an zhuang]的输入[shu ru]法,如:1的键值是英文输入[shu ru]法,知道具体输入[shu ru]法和键值的对应关系后,我们可以根据得到的键值判断用户[yong hu]的当前输入[shu ru]法了。175  在托盘区处显示[xian shi]气泡提示[ti shi]:&http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/iusernotification/SetBalloonInfo.asp&176  设置[she zhi]对话框[dui hua kuang]的背景色[bei jing se]的简单方法[fang fa],其实只要在CWinapp的InitInstance的里面添加一行代码[dai ma]就行了:&---------------------------------------------------------&BOOL CBOOKApp::InitInstance()&{&&&AfxEnableControlContainer();&&SetDialogBkColor(RGB(213,240,227),RGB(173,7,95));&&& //添加这行,前者为背景色[bei jing se],后者为前景色[qian jing se]&&.....&&&& &}&---------------------------------------------------------177  显示[xian shi]gif动画[dong hua]表情的CRechEdit控件:&http://lzzqqq.blogchina.com/2819759.html&178  单文档[wen dang]程序,如何使程序窗口[chuang kou]一开始就固定在某一尺寸:PreCreateWindow中指定大小.可以去掉框架[kuang jia]窗口[chuang kou]的WS_THICKFRAME风格来使窗口[chuang kou]不可改变大小,可以选择[xuan ze]性的去掉WS_MAXIMIZEBO风格。也可以处理WM_GETMINMAXINFO消息[xiao xi]来限制视图[shi tu]的大小。179  CSpinButtonCtrl:&http://www.ruanxun.com/HArticle78020.aspx&180  限制用户[yong hu]调整[tiao zheng]窗口[chuang kou]的最大、最小尺寸,在窗口[chuang kou]的WM_GETMINMAXINFO消息[xiao xi]响应[xiang ying]函数[han shu]中处理,如:&---------------------------------------------------------------------------&void CQQDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) &{&&// TODO: Add your message handler code here and/or call default&&lpMMI-&ptMinTrackSize.x=200;&& //限制最小宽度,单位[dan wei]为像素[xiang su],下同&&lpMMI-&ptMinTrackSize.y=400;&& //限制最小高度&&lpMMI-&ptMaxTrackSize.x=250;&& //限制最大宽度&&lpMMI-&ptMaxTrackSize.y=500;&& //限制最大高度&&CDialog::OnGetMinMaxInfo(lpMMI);&}&---------------------------------------------------------------------------181  获取桌面[zhuo mian]所有图标[tu biao]的标题,代码[dai ma]示范了如何使用VirtualAlloc(),WriteProcessMemory() 和 ReadProcessMemory() 在不同的进程[jin cheng]中分配[fen pei]内存[nei cun]。用Windows的消息[xiao xi]获得图标[tu biao]的名称:   下载[xia zai]源码:&http://www.vckbase.com/code/listcode.asp?mclsid=1&sclsid=101&page=6&182  一台机器可能有不止一个CD-ROM驱动器[qu dong qi]。现在CD-ROM已经是PC机的标准配置[pei zhi],此外再装个可擦[ke ca]写的光盘[guang pan]驱动,甚至是DVD都是很常见的事情。不管一台机器上装多少个不同的驱动器[qu dong qi],如何找到它们呢?下载[xia zai]源码:&http://www.vckbase.com/code/listcode.asp?mclsid=1&sclsid=101&page=6&183  做一个类似文件[wen jian]快捷方式中查找[cha zhao]目标[mu biao]的功能,Net 2003中的MSDN,找到了可以实现该功能的API,SHOpenFolderAndSelectItems()函数[han shu].....本程序可以调用[tiao yong] Explore打开指定文件[wen jian]夹,并把指定文件[wen jian]置为选定状态[zhuang tai],下载[xia zai]源码:&http://www.vckbase.com/code/listcode.asp?mclsid=1&sclsid=101&&&&&&&&&&&& 184 字符[zi fu]串[zi fu chuan]转为Unicode:&-----------------------------------------------------------------&WCHAR wsz[MAX_PATH];&CString str="字符[zi fu]串[zi fu chuan]";&#ifdef _UNICODE&&wcscpy(wsz, str);&& //如果工程支持[zhi chi]Unicode的话用wcscpy函数[han shu]&#else&&//工程不支持[zhi chi]的话用 MultiByteToWideChar函数[han shu]转换[zhuan huan] &&MultiByteToWideChar(CP_ACP, 0, str, -1, wsz, MAX_PATH); &#endif&-----------------------------------------------------------------   也可以用c的函数[han shu]库的函数[han shu]:&mbtowc&&&&&&&&&&&&&&&& 转一个字符[zi fu]&mbstowcs&&&&&&&&&&&&&& 转字符[zi fu]串[zi fu chuan]185 向一个进程[jin cheng]外窗口[chuang kou]发送WM_SHOWWINDOW消息[xiao xi],隐藏或显示[xian shi]该窗口[chuang kou]:&-----------------------------------------------------&HWND hwnd=::FindWindow(0,"ddd");& //隐藏"ddd"窗口[chuang kou]&::PostMessage(hwnd,WM_SHOWWINDOW,FALSE,SW_OTHERZOOM);&&& //参数[can shu]3为FALSE时隐藏,为TRUE则显示[xian shi]该窗口[chuang kou]&-----------------------------------------------------&上面代码[dai ma]有可能失败,因为WM_SHOWWINDOW只是窗口[chuang kou]准备改变状态[zhuang tai]时,系统[xi tong]发出的消息[xiao xi],并不能控制[kong zhi]窗口[chuang kou]状态[zhuang tai]的改变。另一个方法[fang fa]可以把后面一句改成:ShowWindow(hwnd,SW_HIDE);186 使用24位色彩图标[tu biao]的工具条,有源码范例[fan li]的:&http://www.codeguru.com/Cpp/controls/toolbar/article.php/c2537&187  设置[she zhi]CListCtrl控件图标[tu biao]间距离的方法[fang fa]:CListCtrl::SetIconSpacing188 设置[she zhi]层叠窗口[chuang kou]的透明[tou ming]色函数[han shu]:SetLayeredWindowAttributes,部分代码[dai ma]参考[can kao]:&-------------------------------------------------------------------------&SetWindowLong(this-&m_hWnd,GWL_EXSTYLE,GetWindowLong(this-&m_hWnd,GWL_EXSTYLE)|WS_EX_LAYERED);&HWND hWnd=this-&m_hW &typedef DWORD (WINAPI *PSLWA)(HWND, DWORD, BYTE, DWORD);&PSLWA pSetLayeredWindowA&HMODULE hDLL = LoadLibrary ("user32");&pSetLayeredWindowAttributes = (PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes");&if (pSetLayeredWindowAttributes != NULL)&{&&pSetLayeredWindowAttributes (hWnd,0,20,LWA_ALPHA);&}&FreeLibrary(hDLL);&-------------------------------------------------------------------------189  关于滚动条[gun dong tiao]方面的,GetScrollInfo获得滚动条[gun dong tiao]位置[wei zhi]信息[xin xi]:&------------------------------------&SCROLLINFO&ZeroMemory(&si, sizeof(si));&si.cbSize = sizeof(si);&si.fMask = SIF_TRACKPOS;&// Call GetScrollInfo to get current tracking position in si.nTrackPos&GetScrollInfo(hwnd, SB_HORZ, &si);&-----------------------------------&让滚动条[gun dong tiao]滚动需要发送相应的WM_VSCROLL和WM_HSCROLL消息[xiao xi]:&SendMessage (hwnd, WM_VSCROLL, SB_TOP, 0) ;&SetScrollInfo函数[han shu]改变滚动条[gun dong tiao]的位置[wei zhi]。190 切换到软键盘[jian pan]:call ImmSetConversionStatus with IME_CMODE_SOFTKBD191 用SetVolumeLabel函数[han shu]修改[xiu gai]U盘卷标时据说windows会刷新[shua xin]里面的内容。&&&&&&&&&&&&& &===================还没试192 基于对话框[dui hua kuang]的MFC程序想要具有打印功能:&http://community.csdn.net/Expert/topic/.xml?temp=.5908472&193  打开那个标题为"打开方式..."的对话框[dui hua kuang]来选择[xuan ze]程序:WinExec("rundll32.exe shell32.dll,OpenAs_RunDLL path\filename",SW_RESTORE);194 如何屏蔽[ping bi]主窗口[chuang kou]的最大化按钮,并让其自动最小化:&http://community.csdn.net/Expert/topic/.xml?temp=.9465906&195  从立体声[li ti sheng]的wave文件[wen jian]中分别提出左声道和右声道的声音数据[shu ju],实现音频[yin pin]文件[wen jian]的播放——单声道录音、立体声[li ti sheng]录音并保存为.wav文件[wen jian],以及VC.NET简单实现GIF动画[dong hua]:&&http://www.vckbase.com/code/listcode.asp?mclsid=7&196  DirectX Input获得鼠标[shu biao]输入[shu ru]:&http://www.vckbase.com/code/listcode.asp?mclsid=7&sclsid=&page=2&197  数字[shu zi]水印[shu zi shui yin]算法[suan fa]的实现:&http://www.vckbase.com/code/listcode.asp?mclsid=7&sclsid=&page=3&198  程序如何加入全局热键:RegisterHotKey注册[zhu ce]热键,响应[xiang ying]WM_HOTKEY消息[xiao xi]来截获热键:&http://www.xiaozhou.net/cooldog/blogview.asp?logID=78&199  读取[du qu]其它进程[jin cheng]内存[nei cun]中的数据[shu ju]:ReadProcessMemory200 给程序加上系统[xi tong]托盘图标[tu biao]:&http://www.vckbase.com/bbs/prime/viewprime.asp?id=260&&下面是简单的代码[dai ma]:&--------------------------------------------------------------&NOTIFYICONDATA&//初始化[chu shi hua]系统[xi tong]托盘图标[tu biao]&nid.cbSize = sizeof(NOTIFYICONDATA);&nid.hWnd = m_hW&nid.uID = 100;&nid.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;&nid.uCallbackMessage = WM_USER+20;&nid.hIcon=LoadIcon(NULL,IDI_APPLICATION);& //图标[tu biao]&strcpy(nid.szTip, "My Tooltip Text");&&&&& //提示[ti shi]&Shell_NotifyIcon(NIM_ADD, &nid);&--------------------------------------------------------------201  单文档[wen dang]中打印预览,发送消息[xiao xi]模拟[mo ni]点击菜单[cai dan]中“打印预览”:&---------------------------------------------------------------------------------&::SendMessage(this-&GetSafeHwnd(), WM_COMMAND, ID_FILE_PRINT_PREVIEW, 0);&---------------------------------------------------------------------------------202  得到当前登陆用户[yong hu]的用户[yong hu]名[yong hu ming]:GetUserName/GetUserNameEx203 设置[she zhi]发生改变后系统[xi tong]会自动更新,要善加利用:::SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,NULL,NULL);204 拖动[tuo dong]一个没有标题栏的窗口[chuang kou]:&-----------------------------------------------------------------------&void CMyControl::OnLButtonDown(UINT nFlags, CPoint point) &{&// TODO: Add your message handler code here and/or call default&UNUSED_ALWAYS(nFlags);&if (!(GetWindowLong(m_hWnd, GWL_STYLE) & WS_CHILD))&PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));&else&GetParent()-&PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));&}&-----------------------------------------------------------------------205  用指定字体[zi ti]在dc中写字:&-------------------------------------------------------&HDC hdc = ::GetDC(NULL);&HFONT hfont,&hfont = (HFONT)GetStockObject(OEM_FIXED_FONT);&holdfont = (HFONT)SelectObject(hdc,hfont);&TextOut(hdc,10,50,"\1\2\3\4",8);&SelectObject(hdc,holdfont);&DeleteDC(hdc);&-------------------------------------------------------206  桌面[zhuo mian]主题更改的消息[xiao xi]:WM_THEMECHANGED207 修改[xiu gai]菜单[cai dan]项的名称:&CMenu *pMenu = AfxGetMainWnd()-&GetMenu()-&GetSubMenu(0);&pMenu-&ModifyMenu(0,MF_BYPOSITION,0,"Test");208  __LINE__表示本行代码[dai ma]在程序中第几行,同样:__FILE__表示当前文件[wen jian]的全路径[lu jing]&----------------------------------&CS&str.Format("Line is %d", __LINE__);&&& //指这行&AfxMessageBox(str);&----------------------------------209  查看系统[xi tong]函数[han shu]的源代码[dai ma][yuan dai ma]的方法[fang fa]:装一个Visual Assist X,想看某个函数[han shu]的时候ALT + G210 一直以来,想实现窗口[chuang kou]透明[tou ming]程度不同,或局部透明[tou ming],局部不透明[tou ming],但这也只是梦想,下面这个函数[han shu]看来可以让我们梦想成真:UpdateLayeredWindow211 LOGFONT各成员的意义:&---------------------------------------------------------------------------------&LOGFONT&lf.lfHeight=-80;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //字体[zi ti]字符[zi fu]的高度&lf.lfWidth=0;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //字符[zi fu]平均宽度&lf.lfEscapement=45;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //文本[wen ben]行逆时针旋转[xuan zhuan]45度&lf.lfOrientation=0;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //字符[zi fu]角度&lf.lfWeight=FW_HEAVY;&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //字符[zi fu]的粗细度&lf.lfItalic=FALSE;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //倾斜&lf.lfUnderline=FALSE;&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //下划线&lf.lfStrikeOut=FALSE;&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //删除[shan chu]线&lf.lfCharSet=GB2312_CHARSET;&&&&&&&&&&&&&&&&&&&&&& //中文[zhong wen]字[wen zi]符集[zi fu ji]&lf.lfOutPrecision=OUT_STROKE_PRECIS;&&&&&&&&&&&&&& //字体[zi ti]输出[shu chu]结果和要求的匹配程度&lf.lfClipPrecision=CLIP_STROKE_PRECIS;&&&&&&&&&&&& //如何裁剪落于裁剪区之外的字符[zi fu]&lf.lfQuality=DRAFT_QUALITY;&&&&&&&&&&&&&&&&&&&&&&& //字体[zi ti]属性[shu xing]匹配的精确程度&lf.lfPitchAndFamily=VARIABLE_PITCH | FF_MODERN;&&& //字体[zi ti]间距和字体[zi ti]族&strcpy(lf.lfFaceName,"楷体[kai ti] _GB2312");&&&&&&&&&&&&&& //楷体[kai ti]&m_font.CreateFontIndirect(&lf);&&&&&&&&&&&& //m_font为类的成员变量[bian liang][cheng yuan bian liang]:CFont m_&---------------------------------------------------------------------------------212  指向[zhi xiang]指象主对话框[dui hua kuang]的指针[zhi zhen]:AfxGetApp()-&m_pMainWnd或AfxGetApp()-&GetMainWnd()213  去除F1的帮助功能,重载[zhong zai]WM_HELPINFO消息[xiao xi]:&------------------------------------------------------&BOOL CYourdlgDlg::OnHelpInfo(HELPINFO* pHelpInfo) &{&&return TRUE;//CDialog::OnHelpInfo(pHelpInfo);&}&------------------------------------------------------214  串口[chuan kou](包括USB转串口[chuan kou])几个小问题[wen ti]:&http://community.csdn.net/Expert/topic/.xml?temp=.9018061&215  控制[kong zhi]输入[shu ru]法相关的几个函数[han shu]:ImmGetContext、ImmGetConversionStatus、 ImmSetConversionStatus、ImmReleaseContext等216 限定输出[shu chu]字符[zi fu]的矩形范围[fan wei]:ExtTextOut或 DrawText217 控制[kong zhi]滚动条[gun dong tiao]的显示[xian shi]或隐藏:CWnd::ShowScrollBar(UINT nBar,BOOL bShow = TRUE)218 注册[zhu ce]表中:HKEY_LOCAL_MACHINE\SYSTEM \CurrentControlSet\Enum下IDE和SCSI分支[fen zhi]中枚举[mei ju]所有这两种设备。219 更改当前时区:SetTimeZoneInformation   获得当前时区:GetTimeZoneInformation220 直接读取[du qu]硬盘[ying pan]的指定扇区[shan qu]:&(1)用汇编[hui bian];&(2)直接用CreateFile("&file://./PHYSICALDRIVE0&", ...)打开物理磁盘[ci pan]设备即可(物理磁盘[ci pan]设备都是从0开始排号的,0表示第一块硬盘[ying pan],1表示第二块硬盘[ying pan]....),这样用SetFilePointer可以随意读取[du qu]硬盘[ying pan]上任何位置[wei zhi]的东西!至于扇区[shan qu]嘛,一般都是512字节为1扇区[shan qu]的,自己换算就是了~           &===================还没试,不过这里有更多内容:&http://www.51cto.com/html/133.htm&221  获得本机并口的起始地址[di zhi]:可以读取[du qu]bios数据[shu ju]区域[qu yu],当然只能在未进入保护模式[mo shi]的操作系统[xi tong][cao zuo xi tong]前或dos下读取[du qu]段地址[di zhi][duan di zhi]:00H &408H 字 计算机上0号并行[bing hang]打印机[da yin ji]适配器[shi pei qi]的基地址[di zhi], 40AH 字 计算机上1号并行[bing hang]打印机[da yin ji]适配器[shi pei qi]的基地址[di zhi]。 40CH 字 计算机上2号并行[bing hang]打印机[da yin ji]适配器[shi pei qi]的基地址[di zhi]。 40EH 字 计算机上3号并行[bing hang]打印机[da yin ji]适配器[shi pei qi]的基地址[di zhi]。(PS2型此值为扩展[kuo zhan]BIOS数据[shu ju]区段地址[di zhi][duan di zhi]) SetupAPI可以得到所有设备的信息[xin xi]包括IO端口,内存[nei cun]资源[zi yuan],中断[zhong duan]号码222 更换桌面[zhuo mian]背景:&方法[fang fa]一:&  看这里:&http://www.vckbase.com/vck

我要回帖

更多关于 侠盗猎车手4 的文章

 

随机推荐