c++ 代码 使窗体震动,实现最前提醒

来源:互联网 发布:软件 漏洞 编辑:程序博客网 时间:2024/05/16 18:25
 
#ifndef DEBUG_DISABLE#define DEBUG_ENTERED(M)  MessageBox(NULL,\M,\"Tip",\MB_OK);#else#define DEBUG_ENTERED(M)  #endifBOOLShockWindow(HWND hWindow,DWORD dwDelayTime/*ms*/,DWORD dwShockTimes,DWORD dwSpan,BOOL bStayTop);


 

BOOLShockWindow(HWND hWindow,DWORD dwDelayTime,DWORD dwShockTimes,DWORD dwSpan,BOOL bStayTop){//get the information of the windowRECT rect;GetWindowRect(hWindow,&rect);//valid?if(!hWindow){DEBUG_ENTERED("Can not find window!")return FALSE;}else{ShowWindow(hWindow,SW_NORMAL);DEBUG_ENTERED("ENTER PROCESSING")//if window is minimize,without this statement ,will cause the window hideGetWindowRect(hWindow,&rect);//on topSetWindowPos(hWindow,HWND_TOPMOST,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,SWP_NOSIZE|SWP_NOMOVE);//start shockfor(int i=0;i<dwShockTimes;++i){MoveWindow(hWindow,rect.left+dwSpan,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);Sleep(dwDelayTime);MoveWindow(hWindow,rect.left,rect.top-dwSpan,rect.right-rect.left,rect.bottom-rect.top,TRUE);Sleep(dwDelayTime);MoveWindow(hWindow,rect.left-dwSpan,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);Sleep(dwDelayTime);MoveWindow(hWindow,rect.left,rect.top+dwSpan,rect.right-rect.left,rect.bottom-rect.top,TRUE);Sleep(dwDelayTime);}//back to original positionMoveWindow(hWindow,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);//weather the window want to be on top PS:now it is on topif(!bStayTop){SetWindowPos(hWindow,HWND_NOTOPMOST,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,SWP_NOSIZE|SWP_NOMOVE);}DEBUG_ENTERED("ENTER ENDING")return TRUE;}}


 

原创粉丝点击