欢迎来到天天文库
浏览记录
ID:41032888
大小:79.50 KB
页数:10页
时间:2019-08-14
《VC编程技巧20法》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、VC编程技巧20法编程技巧20法(修订)作者:徐景周1.如何激活当前屏幕保护程序//激活当前屏幕保护程序,jingzhouxuPostMessage(WM_SYSCOMMAND,SC_SCREENSAVE,0);2.如何禁止/启用屏幕保护及电源管理staticUINTdss_GetList[]={SPI_GETLOWPOWERTIMEOUT,SPI_GETPOWEROFFTIMEOUT,SPI_GETSCREENSAVETIMEOUT};staticUINTdss_SetList[]={SPI_SETLOWPOWERT
2、IMEOUT,SPI_SETPOWEROFFTIMEOUT,SPI_SETSCREENSAVETIMEOUT};staticconstintdss_ListCount=_countof(dss_GetList);l禁止屏幕保护及电源管理{m_pValue=newint[dss_ListCount];for(intx=0;x3、alue;}l启用屏幕保护及电源管理{m_pValue=newint[dss_ListCount];for(intx=0;x4、ternetExplorer");ShellExecute(h,"open","C:\simple.html",NULL,NULL,SW_SHOWNORMAL);}//关闭IE及其它应用voidCloseIE(){intapp=BSM_APPLICATIONS;unsignedlongbsm_app=(unsignedlong)app;BroadcastSystemMessage(BSF_POSTMESSAGE,&bsm_app,WM_CLOSE,NULL,NULL);}4.如何给树控件加入工具提示l首先给树控件加入5、TVS_INFOTIP属性风格,如下所示:if(!m_ctrlTree.Create(WS_CHILD6、WS_VISIBLE7、TVS_HASLINES8、TVS_HASBUTTONS9、TVS_LINESATROOT10、TVS_SHOWSELALWAYS11、TVS_INFOTIP,//加入提示TVS_INFOTIP,jingzhouxu(树控件ID:100)CRect(0,0,0,0),&m_wndTreeBar,100)){TRACE0("Failedtocreateinstantbarchild");return-1;12、}l其次加入映射消息声明,如下所示:afx_msgvoidOnGetInfoTip(NMHDR*pNMHDR,LRESULT*pResult);//树控件上加入提示消息,jingzhouxuON_NOTIFY(TVN_GETINFOTIP,100,OnGetInfoTip)//树控件条目上加入提示,jingzhouxul最后加入呼应涵数处理:voidCCreateTreeDlg::OnGetInfoTip(NMHDR*pNMHDR,LRESULT*pResult){*pResult=0;NMTVGETINFOTIP*p13、TVTipInfo=(NMTVGETINFOTIP*)pNMHDR;LPARAMitemData=(DWORD)pTVTipInfo->lParam;//对应每个条目的数据HTREEITEMhItem=pTVTipInfo->hItem;CStringtip;HTREEITEMhRootItem=m_chassisTree.GetRootItem();if(hRootItem!=pTVTipInfo->hItem){tip="树结点的提示";}else{tip="树根上的提示";}strcpy(pTVTipInfo->14、pszText,(LPCTSTR)tip);}5.如何获取系统信息框的路径#include#defineIDS_REG_KEY_MSINFO_PATH1_T("Software\Microsoft\SharedTools\MSInfo")#defineIDS_REG_KEY_MSINFO_PATH2_T
3、alue;}l启用屏幕保护及电源管理{m_pValue=newint[dss_ListCount];for(intx=0;x4、ternetExplorer");ShellExecute(h,"open","C:\simple.html",NULL,NULL,SW_SHOWNORMAL);}//关闭IE及其它应用voidCloseIE(){intapp=BSM_APPLICATIONS;unsignedlongbsm_app=(unsignedlong)app;BroadcastSystemMessage(BSF_POSTMESSAGE,&bsm_app,WM_CLOSE,NULL,NULL);}4.如何给树控件加入工具提示l首先给树控件加入5、TVS_INFOTIP属性风格,如下所示:if(!m_ctrlTree.Create(WS_CHILD6、WS_VISIBLE7、TVS_HASLINES8、TVS_HASBUTTONS9、TVS_LINESATROOT10、TVS_SHOWSELALWAYS11、TVS_INFOTIP,//加入提示TVS_INFOTIP,jingzhouxu(树控件ID:100)CRect(0,0,0,0),&m_wndTreeBar,100)){TRACE0("Failedtocreateinstantbarchild");return-1;12、}l其次加入映射消息声明,如下所示:afx_msgvoidOnGetInfoTip(NMHDR*pNMHDR,LRESULT*pResult);//树控件上加入提示消息,jingzhouxuON_NOTIFY(TVN_GETINFOTIP,100,OnGetInfoTip)//树控件条目上加入提示,jingzhouxul最后加入呼应涵数处理:voidCCreateTreeDlg::OnGetInfoTip(NMHDR*pNMHDR,LRESULT*pResult){*pResult=0;NMTVGETINFOTIP*p13、TVTipInfo=(NMTVGETINFOTIP*)pNMHDR;LPARAMitemData=(DWORD)pTVTipInfo->lParam;//对应每个条目的数据HTREEITEMhItem=pTVTipInfo->hItem;CStringtip;HTREEITEMhRootItem=m_chassisTree.GetRootItem();if(hRootItem!=pTVTipInfo->hItem){tip="树结点的提示";}else{tip="树根上的提示";}strcpy(pTVTipInfo->14、pszText,(LPCTSTR)tip);}5.如何获取系统信息框的路径#include#defineIDS_REG_KEY_MSINFO_PATH1_T("Software\Microsoft\SharedTools\MSInfo")#defineIDS_REG_KEY_MSINFO_PATH2_T
4、ternetExplorer");ShellExecute(h,"open","C:\simple.html",NULL,NULL,SW_SHOWNORMAL);}//关闭IE及其它应用voidCloseIE(){intapp=BSM_APPLICATIONS;unsignedlongbsm_app=(unsignedlong)app;BroadcastSystemMessage(BSF_POSTMESSAGE,&bsm_app,WM_CLOSE,NULL,NULL);}4.如何给树控件加入工具提示l首先给树控件加入
5、TVS_INFOTIP属性风格,如下所示:if(!m_ctrlTree.Create(WS_CHILD
6、WS_VISIBLE
7、TVS_HASLINES
8、TVS_HASBUTTONS
9、TVS_LINESATROOT
10、TVS_SHOWSELALWAYS
11、TVS_INFOTIP,//加入提示TVS_INFOTIP,jingzhouxu(树控件ID:100)CRect(0,0,0,0),&m_wndTreeBar,100)){TRACE0("Failedtocreateinstantbarchild");return-1;
12、}l其次加入映射消息声明,如下所示:afx_msgvoidOnGetInfoTip(NMHDR*pNMHDR,LRESULT*pResult);//树控件上加入提示消息,jingzhouxuON_NOTIFY(TVN_GETINFOTIP,100,OnGetInfoTip)//树控件条目上加入提示,jingzhouxul最后加入呼应涵数处理:voidCCreateTreeDlg::OnGetInfoTip(NMHDR*pNMHDR,LRESULT*pResult){*pResult=0;NMTVGETINFOTIP*p
13、TVTipInfo=(NMTVGETINFOTIP*)pNMHDR;LPARAMitemData=(DWORD)pTVTipInfo->lParam;//对应每个条目的数据HTREEITEMhItem=pTVTipInfo->hItem;CStringtip;HTREEITEMhRootItem=m_chassisTree.GetRootItem();if(hRootItem!=pTVTipInfo->hItem){tip="树结点的提示";}else{tip="树根上的提示";}strcpy(pTVTipInfo->
14、pszText,(LPCTSTR)tip);}5.如何获取系统信息框的路径#include#defineIDS_REG_KEY_MSINFO_PATH1_T("Software\Microsoft\SharedTools\MSInfo")#defineIDS_REG_KEY_MSINFO_PATH2_T
此文档下载收益归作者所有