一. 一次只运行一个程序实例
下列两种方式都可以实现,建议采用第二种方式: 【程序编程相关:Thoughtworks 】 【推荐阅读:我写的第一个ASP.NET"组】1. if( findwindow(null,"程序标题")) 【扩展信息:导出oracle数据库对象---同义词,】 exit(0); 2.bool cdemotbareapp::instanceisrun() { handle m_hmutex; m_hmutex = ::createmutex(null, true, _t("yourapplication")); assert(m_hmutex); if (getlasterror() == error_already_exists) { m_hmutex = null; return true;//实例已经运行 } return false;//实例未运行 }二. 装载光标
setcursor(afxgetapp()->loadstandardcursor(idc_wait)); 其中::setcursor()是全局函数,用来设置整个例程的光标参数是宏定义光标句柄.afxgetapp ()是一个系统函数,它返回当前的一个cwinapp对象.其成员函数loadstandardcursor()用来读取一个系统指针,每一种系统指针的具体宏定义如下: idc_appstarting 带小沙漏的标准箭头 idc_arrow 标准箭头 idc_cross 十字光标(用于定位) idc_hand windows 2000:手型 idc_help 带问号的箭头 idc_ibeam i型标 idc_icon obsolete for applications marked version 4.0 or later. idc_no 禁止符号 idc_size obsolete for applications marked version 4.0 or later. use idc_sizeall. idc_sizeall 十字箭头 idc_sizenesw 指向东北与西南的双向箭头 idc_sizens 指向南与北的双向箭头 idc_sizenwse 指向西北与东南的双向箭头 idc_sizewe 指向东西的双向箭头 idc_uparrow 上箭头 idc_wait 沙漏三.获得主框架:
cmainframe * pmainframe = (cmainframe *) afxgetapp()->m_pmainwnd; .获取应用程序的实例句柄: example: handle hinstance=afxgetinstancehandle();获得应用程序主窗口的指针:
example: afxgetmainwnd() ->showwindow(sw_showmaxmized); //使程序最大化四.重新建立字体的代码
if(m_fontlogo.m_hobject) m_fontlogo.detach();... 下一页