⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transparentwnd.cpp

📁 visual c++ 实例编程
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//********************************************************************************
//* 名称:OnUpdateFullscreenWalk()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:更新全屏运动还是局部运动
//********************************************************************************
void CTransparentWnd::OnUpdateFullscreenWalk(CCmdUI* pCmdUI) 
{
	if(m_bFullScreenWalk) 
		pCmdUI->SetCheck(TRUE);
	else
		pCmdUI->SetCheck(FALSE);	
}

//********************************************************************************
//* 名称:OnShowhide()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:显示或隐藏精灵助手
//********************************************************************************
void CTransparentWnd::OnShowhide() 
{
	CWnd * pFrame;					 //得到当前窗体指针

	pFrame=AfxGetApp()->GetMainWnd();
	if(!pFrame->IsWindowVisible())	 //是否进行窗体动画,窗体已显示则不进行
	{
		WinAnimation(false);		 //窗体动画从系统区滑出 
		pFrame->ShowWindow(SW_SHOW);
	}
    else							 //是否进行窗体动画,窗体已隐藏则不进行
	{
		m_Tip.SetHideDelay(100);     //隐藏提示窗
		m_Tip.Hide();
        pFrame->ShowWindow(SW_HIDE);
	    WinAnimation(true);			 //窗体动画滑入到系统区中 
	}	
}

//********************************************************************************
//* 名称:OnInitMenuPopup()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:加此涵数,使动态新增菜单条同步以XP风格显示
//********************************************************************************
void CTransparentWnd::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) 
{
	CWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
	
	if(!bSysMenu){
		if(BCMenu::IsMenu(pPopupMenu)) BCMenu::UpdateMenu(pPopupMenu);
	}
}

//********************************************************************************
//* 名称:OnMeasureItem()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:重新测量菜单条
//********************************************************************************
void CTransparentWnd::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) 
{
	BOOL setflag=FALSE;
	if(lpMeasureItemStruct->CtlType==ODT_MENU){
		if(IsMenu((HMENU)lpMeasureItemStruct->itemID)&&BCMenu::IsMenu((HMENU)lpMeasureItemStruct->itemID)){
			m_popmenu.MeasureItem(lpMeasureItemStruct);
			setflag=TRUE;
		}
	}
	if(!setflag)CWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);	
}

//********************************************************************************
//* 名称:OnMenuChar()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:重新绘制菜单条
//********************************************************************************
LRESULT CTransparentWnd::OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) 
{
	LRESULT lresult;
	if(BCMenu::IsMenu(pMenu))
		lresult=BCMenu::FindKeyboardShortcut(nChar, nFlags, pMenu);
	else
		lresult=CWnd::OnMenuChar(nChar, nFlags, pMenu);

	return(lresult);
	
}

//********************************************************************************
//* 名称:GetFullScreenWalk()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取是否全屏运动的标志位
//********************************************************************************
BOOL CTransparentWnd::GetFullScreenWalk()                
{
	return m_bFullScreenWalk;
}  

//********************************************************************************
//* 名称:GetOptionMute()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取静音标志位
//********************************************************************************
BOOL CTransparentWnd::GetOptionMute()                  
{
	return m_bMute;   
}
  
//********************************************************************************
//* 名称:GetOptionTopShow()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取顶层显示标志位
//********************************************************************************
BOOL CTransparentWnd::GetOptionTopShow()               
{
	return m_bTopShow;
}

//********************************************************************************
//* 名称:GetOptionRest()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取静止标志位
//********************************************************************************
BOOL CTransparentWnd::GetOptionRest()                 
{
	return m_bRest; 
}

//********************************************************************************
//* 名称:OnDownload()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:设置下载网页地址
//********************************************************************************
void CTransparentWnd::OnDownload() 
{
	CDownloadAddress dlg;  
	CString str;

	//保证此对话框一次只弹出一个
	if(!FindWindow(NULL,"设置下载网址"))
	{
		if(dlg.DoModal()==IDOK)
		{
			if((str=dlg.GetDownloadAddress())!="")
			{
				CWnd * pFrame;					        

				pFrame=AfxGetApp()->GetMainWnd();
				pFrame->ShowWindow(SW_HIDE);            //下载前先隐藏精灵助手
				if(m_bSuccess)
				{
					m_sdFile.Close();                   //先关闭原打开文件,以便新建文件
					m_bSuccess=FALSE;
				}
				m_bDownloadFailed= FALSE;               //选置假,避免显示提示窗信息
														
				//下载新设置的网页
				m_bDownloadFailed=GetSourceHtml(str,"News.txt");	

				if(m_bDownloadFailed)
					m_bSuccess=m_bDownloadFailed=m_sdFile.Open(strPath+"\\Nesw.txt",
					CFile::modeRead | CFile::typeText);
			}
		}
	}
}

//********************************************************************************
//* 名称:OnActionRun()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:奔跑方式
//********************************************************************************
void CTransparentWnd::OnActionRun() 
{
	int CurAction;
	if((CurAction=GetCurAction())!=TIMER_TRANSFORM)
		KillTimer(CurAction);

	m_Tip.SetHideDelay(100);     //隐藏提示窗
	m_Tip.Hide();

	SetTimer(TIMER_TRANSFORM,500,NULL);  //改奔跑为变形方式
//	SetTimer(TIMER_RUN,500,NULL);	
}

//********************************************************************************
//* 名称:OnActionWalk()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:散步方式
//********************************************************************************
void CTransparentWnd::OnActionWalk() 
{
	int CurAction;
	if((CurAction=GetCurAction())!=TIMER_WALK)
		KillTimer(CurAction);

	m_Tip.SetHideDelay(100); 
	m_Tip.Hide();

	SetTimer(TIMER_WALK,150,NULL);
}

//********************************************************************************
//* 名称:OnActionIdle()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:休息方式
//********************************************************************************
void CTransparentWnd::OnActionIdle() 
{		
	int CurAction;
	if((CurAction=GetCurAction())!=TIMER_IDLE)
		KillTimer(CurAction);

	SetTimer(TIMER_IDLE,300,NULL);
}

//********************************************************************************
//* 名称:GetCurAction()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取当前行为表现方式
//********************************************************************************
int  CTransparentWnd::GetCurAction()
{
	return m_iAction;
}

//********************************************************************************
//* 名称:GetTopWndTitleRect()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取当前桌面最顶层窗口标题区大小
//********************************************************************************
CRect CTransparentWnd::GetTopWndTitleRect()             
{
/*
	HWND TopHwnd;
	CHelpTipDlg ExitDlg;
	CDownloadAddress AddressDlg; 
	CAbout aboutDlg;
	CSetRing RingDlg;

	TopHwnd=::GetForegroundWindow();

	//不能是本程序所具有的窗体,否则返回初窗口标题区大小
	if(TopHwnd==this->m_hWnd||TopHwnd==ExitDlg.m_hWnd||TopHwnd==AddressDlg.m_hWnd||TopHwnd==aboutDlg.m_hWnd||TopHwnd==RingDlg)
		return m_Rect;

	CRect rtWnd;
	::GetWindowRect(TopHwnd,&rtWnd);

	return rtWnd;
*/

	// 查找并返回任务栏窗口大小 
	CRect rect(0,0,0,0);
    CWnd* pWnd = FindWindow("Shell_TrayWnd", NULL);
    if (pWnd)
    {
        pWnd->GetWindowRect(&rect);
	}
	return rect;
}

//********************************************************************************
//* 名称:OnAbout()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:关于对话框
//********************************************************************************
void CTransparentWnd::OnAbout() 
{
/*
	CAbout aboutDlg;

	//保证此对话框一次只弹出一个
	if(!FindWindow(NULL,"关于 精灵助手"))
		aboutDlg.DoModal(); 
*/

	CAbout aboutDlg;

	aboutDlg.DoModal(); 
}

//********************************************************************************
//* 名称:OnActionSpecial()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:闹铃设置对话框
//********************************************************************************
void CTransparentWnd::OnActionSpecial() 
{
	CSetRing RingDlg;

	//保证此对话框一次只弹出一个
	HWND hWnd = ::FindWindow(NULL,"设置闹钟功能");
	if(!hWnd)
	{
		if(RingDlg.DoModal()==IDOK)
		{
			m_Time=RingDlg.GetCurRingTime();
			if(m_Time!=NULL)
				SetTimer(TIMER_SETRING,1000,NULL);	 //一秒钟更新一次
		}
	}
}

//********************************************************************************
//* 名称:OnActionSpecial()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:闹铃设置对话框
//********************************************************************************
void CTransparentWnd::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	CRect rcWnd;
	GetWindowRect(&rcWnd);
	CPoint pt;
	GetCursorPos(&pt);

	if(rcWnd.PtInRect(pt))
		OnActionSpecial();	

	CWnd::OnLButtonDblClk(nFlags, point);
}

//********************************************************************************
//* 名称:StartupAutorun()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:开机时程序自动运行
//********************************************************************************
BOOL CTransparentWnd::StartupAutorun(BOOL bIsAdd)
{
	HKEY hKey;
	LONG lRet, lRet2;
	DWORD dwLength, dwDataType;
	TCHAR szItemValue[MAX_PATH], szPrevValue[MAX_PATH];
	TCHAR szBuffer[MAX_PATH];

	// 得到程序全路径名
	GetModuleFileName( NULL, szItemValue, MAX_PATH );


	// 打开注册表键
		lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, gcszAutoRunKey,
			0, KEY_READ | KEY_WRITE, &hKey );
		if( lRet != ERROR_SUCCESS )
			return FALSE;

	// 查询自动运行项目是否存在
		dwLength = sizeof( szBuffer );
		lRet = RegQueryValueEx( hKey, gcszWindowClass, 
			NULL, &dwDataType, (LPBYTE)szBuffer, &dwLength );

	// 添加
		if( bIsAdd == TRUE ) 
		{
	// 自动运行项目不存在
			if( lRet != ERROR_SUCCESS )
				lRet2 = RegSetValueEx( hKey, gcszWindowClass,
				0, REG_SZ, (LPBYTE)szItemValue, strlen( szItemValue ) );
			else 
			{
	// 存在, 比较二者是否相同
				dwLength = sizeof( szPrevValue );
				lRet2 = RegQueryValueEx( hKey, gcszWindowClass, 
					0, &dwDataType,(LPBYTE)szPrevValue, &dwLength );
	// 不相同则替换
				if( lstrcmp( szItemValue, szPrevValue ) ) 
				{
					lRet2 = RegDeleteValue( hKey, gcszWindowClass );
					lRet2 = RegSetValueEx( hKey, gcszWindowClass, 
						0, REG_SZ,(LPBYTE)szItemValue, strlen( szItemValue ) );
				}
			}
		}
	// 删除
		else 
	// 自动运行项目已存在则删除
			if( lRet == ERROR_SUCCESS )
				lRet2 = RegDeleteValue( hKey, gcszWindowClass );

	// 关闭注册表键
		RegCloseKey( hKey );

		if( lRet2 != ERROR_SUCCESS )
			return FALSE;


	return TRUE;
}

//********************************************************************************
//* 名称:OnAutorun()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:开机时程序自动运行
//********************************************************************************
void CTransparentWnd::OnAutorun() 
{
	m_bAutorun = !m_bAutorun;
	
}

//********************************************************************************
//* 名称:GetAutorunFlag()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取自动运行标志
//********************************************************************************
BOOL CTransparentWnd::GetAutorunFlag()		
{
	return m_bAutorun;
}

//********************************************************************************
//* 名称:GetShowNews()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:获取显示新闻标志
//********************************************************************************
BOOL CTransparentWnd::GetShowNewsFlag()   
{
	return m_bShowNews;
}

//********************************************************************************
//* 名称:OnShownews()
//* 作者:徐景周(jingzhou_xu@163.net)
//* 功能:是否显示新闻
//********************************************************************************
void CTransparentWnd::OnShownews() 
{
	m_bShowNews = !m_bShowNews;
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -