VC++±à³Ì¼¼ÊõÁ¬ÔØ£££VC++ÖÆ×÷¾ßÓÐÉùÒôЧ¹ûµÄ¶¯»×ÀÃ澫Áé2007-06-1811:09:52VC++±à³Ì¼¼ÊõÁ¬ÔØ£££VC++ÖÆ×÷¾ßÓÐÉùÒôЧ¹ûµÄ¶¯»×ÀÃ澫Áé²ÉÓÃ͸Ã÷λͼ·½·¨ÔÚ×ÀÃæÉÏÏÔʾλͼ£¬¶¨Ê±¸ü»»Î»Í¼ÒÔʵÏÖ¶¯»Ð§¹û£¬ÔÙ²ÉÓò¥·ÅÄÚ²¿WAV×ÊÔ´Îļþ·½·¨À´²¥·Å×Ô´øWAVÎļþ¼È¿É(ÓÒ¼ü¿É¹Ø±Õ´Ë³ÌÐò)¡£¾ßÌåʵÏÖ²½ÖèÈçÏ£º1¡¢ÔÚн¨µÄ¹¤³ÌÎļþÖÐ(VC6.0)Öе¼ÈëÒ»WAVÎļþ£¬È¡ÃûWEST£¬ÔÙµ¼ÈëÁ½·ùλͼȡÃûWEST1ºÍWEST2¡¡¡£2¡¢Ð½¨Ò».hÎļþ£¬È¡ÃûTransparentWnd.h´úÂëÄÚÈÝÈçÏ£º#if!defined(AFX_TRANSPARENTWND_H__6508F000_5685_11D3_9001_CBBD225E6BC4__INCLUDED_)#defineAFX_TRANSPARENTWND_H__6508F000_5685_11D3_9001_CBBD225E6BC4__INCLUDED_#if_MSC_VER1000#pragmaonce#endif//_MSC_VER1000//TransparentWnd.h:headerfile//////////////////////////////////////////×÷ÕߣºÐì¾°ÖÜ.2000.12//¹¦ÄÜ£ºÍ¸Ã÷λͼ¼°WAV×ÊÔ´²¥·Å////////////////////////////////////////TransparentWndwindowclassTransparentWnd:publicCWnd{//Constructionpublic:TransparentWnd();voidCreateTransparent(LPCTSTRpTitle,RECT&rect);voidSetupRegion(CDC*pDC);voidDoChange(void);voidSoundPlay(void);CBitmapm_bmpDraw;intm_iAniSeq;//Attributespublic://Operationspublic://Overrides//ClassWizardgeneratedvirtualfunctionoverrides//{{AFX_VIRTUAL(TransparentWnd)//}}AFX_VIRTUAL//Implementationpublic:virtual~TransparentWnd();//Generatedmessagemapfunctionsprotected://{{AFX_MSG(TransparentWnd)afx_msgvoidOnLButtonDown(UINTnFlags,CPointpoint);afx_msgintOnCreate(LPCREATESTRUCTlpCreateStruct);afx_msgBOOLOnEraseBkgnd(CDC*pDC);afx_msgvoidOnTimer(UINTnIDEvent);afx_msgvoidOnRButtonDown(UINTnFlags,CPointpoint);//}}AFX_MSGDECLARE_MESSAGE_MAP()};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.#endif//!defined(AFX_TRANSPARENTWND_H__6508F000_5685_11D3_9001_CBBD225E6BC4__INCLUDED_)3¡¢Ð½¨Ò».cppÎļþ£¬È¡Ãû£ºTransparentWnd.cpp´úÂëÄÚÈÝÈçÏ£º//TransparentWnd.cpp:implementationfile////////////////////////////////////////×÷ÕߣºÐì¾°ÖÜ.2000.12//¹¦ÄÜ£ºÍ¸Ã÷λͼ¼°WAV×ÊÔ´²¥·Å//////////////////////////////////////#includestdafx.h#includeWest.h#includeTransparentWnd.h#includeWestDlg.h#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////TransparentWndTransparentWnd::TransparentWnd(){m_iAniSeq=0;//ͼÏñ±ä»¯³õʼֵ}TransparentWnd::~TransparentWnd(){}BEGIN_MESSAGE_MAP(TransparentWnd,CWnd)//{{AFX_MSG_MAP(TransparentWnd)ON_WM_LBUTTONDOWN()ON_WM_CREATE()ON_WM_ERASEBKGND()ON_WM_TIMER()ON_WM_RBUTTONDOWN()ON_COMMAND(IDR_HELP,OnHelp)ON_COMMAND(IDR_EXIT,OnExit)//}}AFX_MSG_MAPEND_MESSAGE_MAP()//********************************************************************************//*CreateTransparent()//*//*Createsthemainapplicationwindowtransparent//********************************************************************************voidTransparentWnd::CreateTransparent(LPCTSTRpTitle,RECT&rect){//´´½¨Ò»¸öÒþ²Ø´°¿ÚCreateEx(0,AfxReGISterWndClass(0,AfxGetApp()-LoadStandardCursor(IDC_ARROW)),pTitle,WS_POPUP,rect,NULL,NULL,NULL);DoChange();}//********************************************************************************//*SetupRegion()//*//*SettheWindowRegionfortransparancyoutsidethemaskregion//********************************************************************************voidTransparentWnd::SetupRegion(CDC*pDC){CDCmemDC;CBitmap&cBitmap=m_bmpDraw;CBitmap*pOldMemBmp=NULL;COLORREFcol,colMask;CRectcRect;intx,y;CRgnwndRgn,rgnTemp;GetWindowRect(&cRect);CPointptOrg=cRect.TopLeft();BITMAPbmInfo;cBitmap.GetObject(sizeof(bmInfo),&bmInfo);CRectrcNewWnd=CRect(ptOrg,CSize(bmInfo.bmWidth,bmInfo.bmHeight));memDC.CreateCompatibleDC(pDC);pOldMemBmp=memDC.SelectObject(&cBitmap);colMask=memDC.GetPixel(0,0);wndRgn.CreateRectRgn(0,0,rcNewWnd.Width(),rcNewWnd.Height());for(x=0;x=rcNewWnd.Width();x++){for(y=0;y=rcNewWnd.Height();y++){col=memDC.GetPixel(x,y);if(col==colMask){rgnTemp.CreateRectRgn(x,y,x+1,y+1);wndRgn.CombineRgn(&wndRgn,&rgnTemp,RGN_XOR);rgnTemp.DeleteObject();}}}if(pOldMemBmp)memDC.SelectObject(pOldMemBmp);SetWindowRgn((HRGN)wndRgn,TRUE);MoveWindow(rcNewWnd);}voidTransparentWnd::DoChange(void){charszBmp[20];//²»¶ÏÌ滻ͼÏñsprintf(szBmp,WEST%d,m_iAniSeq%2+1);m_bmpDraw.DeleteObject();m_bmpDraw.LoadBitmap(szBmp);CWindowDCdc(this);SetupRegion(&dc);Invalidate();}voidTransparentWnd::SoundPlay(void){//ÏȹرÕÔÉùÒô²¥·ÅPlaySound(WEST,AfxGetResourceHandle(),SND_RESOURCE|SND_PURGE|SND_NODEFAULT);SetTimer(2,61080,NULL);//ÉèÖò¥·ÅÉùÒôʱ¼ä61.08Ãë//×ÊÔ´WAVÎļþµÄIDÐë¼ÓË«ÒýºÅ£¬ÓÃÏÂAPIº¯Êý²¥·ÅPlaySound(WEST,AfxGetResourceHandle(),SND_RESOURCE|SND_ASYNC|SND_NODEFAULT);}voidTransparentWnd::OnLButtonDown(UINTnFlags,CPointpoint){CWnd::OnLButtonDown(nFlags,point);//ʵÏÖÎÞ±êÌâÍ϶¯PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(point.x,point.y));}intTransparentWnd::OnCreate(LPCREATESTRUCTlpCreateStruct){if(CWnd::OnCreate(lpCreateStruct)==-1)return-1;SetTimer(1,1000,NULL);//¿ªÊ¼Ê±µÄͼÏñÏÔʾʱ¼äSetTimer(2,500,NULL);//Æô¶¯ÉùÒô²¥·Å¼ÆʱÆ÷SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);/