如何做成类似QQ的系统托盘 RT最近做一小程序,功能界面都差不多了,但是想实现在最小化时变成类似QQ或MSN在右下角的图标托盘,并支持右键弹出菜单请问应该如何实现?给个提示或文章链接3X 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 网上例子很多,解释也很详细,我就不说了http://www.vckbase.com/document/viewdoc/?id=677http://www.yesky.com/190/1878190.shtml 还有个问题 如何将整个desktop锁定? 就是类似网吧管理软件的那种 而等待一定的时间后才能自动解缩 #pragma onceclass CTrayIcon{public: CTrayIcon(); ~CTrayIcon(); // Set notify message window BOOL SetNotifyWnd(CWnd* pNotifyWnd, UINT nMsg); BOOL SetIcon(HICON hIcon); // Set tray icon BOOL SetIcon(UINT nID); // Set tray icon by resource HICON GetIcon() const; // Get tray icon handle BOOL SetToolTip(const CString& strTip); // Set tooltip text BOOL SetToolTip(UINT nID); // Set tooltip text by resource CString GetToolTip() const; // Get tooltip text #if (_WIN32_IE >= 0x0500) BOOL ShowBalloonTip(const CString& strTitle, const CString& strMsg, UINT nTimeout=3000); BOOL GetBalloonTip(CString& strTitle, CString& strMsg, UINT nTimeout) const;#endif BOOL ShowTray(BOOL bShow);private: NOTIFYICONDATA m_nid;};/********************************************************************** * File Name: TrayIcon.cpp * Module Name: CTrayIcon * Copyright (C) by LQ messager * Description: System taskbar tray icon control * Author: LiJun * Create Data: 2005-11-18 Update Data: 2006-07-18 * E-Mail: mailto:[email protected] * *********************************************************************/#include "StdAfx.h"#include "trayicon.h"CTrayIcon::CTrayIcon(){ memset(&m_nid, 0, sizeof(NOTIFYICONDATA)); m_nid.cbSize = sizeof(NOTIFYICONDATA);}CTrayIcon::~CTrayIcon(){ ShowTray(FALSE);}BOOL CTrayIcon::SetNotifyWnd(CWnd* pNotifyWnd, UINT nMsg){ ASSERT(pNotifyWnd != NULL); ASSERT(::IsWindow(pNotifyWnd->m_hWnd)); m_nid.hWnd = pNotifyWnd->m_hWnd; if(nMsg > 0) { m_nid.uCallbackMessage = nMsg; if(!(m_nid.uFlags & NIF_MESSAGE)) m_nid.uFlags |= NIF_MESSAGE; } else { m_nid.uCallbackMessage = 0; if(m_nid.uFlags & NIF_MESSAGE) m_nid.uFlags &= ~NIF_MESSAGE; } return TRUE;}BOOL CTrayIcon::SetIcon(HICON hIcon){ ASSERT(hIcon != NULL); if(!(m_nid.uFlags & NIF_ICON)) m_nid.uFlags |= NIF_ICON; m_nid.hIcon = hIcon; return Shell_NotifyIcon(NIM_MODIFY, &m_nid);}BOOL CTrayIcon::SetIcon(UINT nID){ return SetIcon(AfxGetApp()->LoadIcon(nID));}HICON CTrayIcon::GetIcon() const{ return m_nid.hIcon;}BOOL CTrayIcon::SetToolTip(const CString& strTip){ if(!(m_nid.uFlags & NIF_TIP)) m_nid.uFlags |= NIF_TIP; lstrcpy(m_nid.szTip, strTip); return Shell_NotifyIcon(NIM_MODIFY,&m_nid);}BOOL CTrayIcon::SetToolTip(UINT nID){ TCHAR szText[128]; ::LoadString(AfxGetInstanceHandle(), nID, szText, 128); return SetToolTip(szText);}CString CTrayIcon::GetToolTip() const{ return m_nid.szTip;}#if (_WIN32_IE >= 0x0500)BOOL CTrayIcon::ShowBalloonTip(const CString& strTitle, const CString& strMsg, UINT nTimeout){ if(!(m_nid.uFlags & NIF_INFO)) m_nid.uFlags |= NIF_INFO; m_nid.uTimeout = nTimeout; lstrcpy(m_nid.szInfoTitle, strTitle); lstrcpy(m_nid.szInfo, strMsg); return Shell_NotifyIcon(NIM_MODIFY, &m_nid);}BOOL CTrayIcon::GetBalloonTip(CString& strTitle, CString& strMsg, UINT nTimeout) const{ strTitle = m_nid.szInfoTitle; strMsg = m_nid.szInfo; nTimeout = m_nid.uTimeout; return TRUE;}#endifBOOL CTrayIcon::ShowTray(BOOL bShow){ return Shell_NotifyIcon( bShow ? NIM_ADD : NIM_DELETE, &m_nid );} 显示桌面::SetWindowPos(::FindWindow(NULL, "Program Manager"), NULL,0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);隐藏桌面::SetWindowPos(::FindWindow(NULL, "Program Manager"), NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER); void Lock(BOOL bFALG){ //锁住屏幕,系统不能支持鼠标和键盘事件 if (bFALG) { SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, NULL,0); EnableWindow(GetDesktopWindow(),FALSE); } //屏幕解锁 else { SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, NULL,0); EnableWindow(GetDesktopWindow(),TRUE); }}这个是锁住屏幕和解锁~~~主要是在2000和98系统~~~在远程控制里面见的比较多~~~ 好像还有个函数以前听说可以~~~LockWindowUpdate具体的你自己参考一下MSDN~~~ 哈哈,思危没去过网吧啊关于托盘的就不多说了,网上多D是,to 思危:Program Manager就是桌面的title? 呵呵,如果你们用过Win3.1(估计现在的人也没几个用过的),里面有个叫Program Manager的程序,相当于现在资源管理器,是Win3.1的Shell。虽然后来Win3.1被淘汰了,不过微软把这个名字继承了下了,用作现在Shell的名字,也就是我们说的桌面。而桌面真正的程序名是 progman.exe,有兴趣可以查找来看一下 。 :) windows 3.2中文版,用过2分钟 第二次进入线程后,程序出错!请各位高手指点 MFC 可拖放对话框分割 真的没辙了,跪求解答!!! VC高手是什么样的 大家快来,一个SQL问题 老是用VC编译时会出现这样的错误 有请 DLL 高手,帮忙解答一个问题,郁闷了我几天。。。。。。。 如何响应动态创建的控件?? 天津的朋友谁买到VS.net正式版了?(当然是那个“非暴力版”)从哪买的? 请问济南万千新闻组跑哪儿去了?后来一个新的的地址是多少啊。哪位老哥知道啊。谢谢啦~~ 如何从消息队列中获得一个按钮按下的消息 为什么我无法保存位图?极度苦闷中.在线急等!
http://www.yesky.com/190/1878190.shtml
{
public:
CTrayIcon();
~CTrayIcon();
// Set notify message window
BOOL SetNotifyWnd(CWnd* pNotifyWnd, UINT nMsg);
BOOL SetIcon(HICON hIcon); // Set tray icon
BOOL SetIcon(UINT nID); // Set tray icon by resource
HICON GetIcon() const; // Get tray icon handle BOOL SetToolTip(const CString& strTip); // Set tooltip text
BOOL SetToolTip(UINT nID); // Set tooltip text by resource
CString GetToolTip() const; // Get tooltip text
#if (_WIN32_IE >= 0x0500)
BOOL ShowBalloonTip(const CString& strTitle, const CString& strMsg, UINT nTimeout=3000);
BOOL GetBalloonTip(CString& strTitle, CString& strMsg, UINT nTimeout) const;
#endif
BOOL ShowTray(BOOL bShow);
private:
NOTIFYICONDATA m_nid;
};/**********************************************************************
* File Name: TrayIcon.cpp
* Module Name: CTrayIcon
* Copyright (C) by LQ messager
* Description: System taskbar tray icon control
* Author: LiJun
* Create Data: 2005-11-18 Update Data: 2006-07-18
* E-Mail: mailto:[email protected]
*
*********************************************************************/
#include "StdAfx.h"
#include "trayicon.h"CTrayIcon::CTrayIcon()
{
memset(&m_nid, 0, sizeof(NOTIFYICONDATA));
m_nid.cbSize = sizeof(NOTIFYICONDATA);
}CTrayIcon::~CTrayIcon()
{
ShowTray(FALSE);
}BOOL CTrayIcon::SetNotifyWnd(CWnd* pNotifyWnd, UINT nMsg)
{
ASSERT(pNotifyWnd != NULL);
ASSERT(::IsWindow(pNotifyWnd->m_hWnd)); m_nid.hWnd = pNotifyWnd->m_hWnd;
if(nMsg > 0)
{
m_nid.uCallbackMessage = nMsg;
if(!(m_nid.uFlags & NIF_MESSAGE))
m_nid.uFlags |= NIF_MESSAGE;
}
else
{
m_nid.uCallbackMessage = 0;
if(m_nid.uFlags & NIF_MESSAGE)
m_nid.uFlags &= ~NIF_MESSAGE;
}
return TRUE;
}BOOL CTrayIcon::SetIcon(HICON hIcon)
{
ASSERT(hIcon != NULL); if(!(m_nid.uFlags & NIF_ICON))
m_nid.uFlags |= NIF_ICON; m_nid.hIcon = hIcon;
return Shell_NotifyIcon(NIM_MODIFY, &m_nid);
}BOOL CTrayIcon::SetIcon(UINT nID)
{
return SetIcon(AfxGetApp()->LoadIcon(nID));
}HICON CTrayIcon::GetIcon() const
{
return m_nid.hIcon;
}BOOL CTrayIcon::SetToolTip(const CString& strTip)
{
if(!(m_nid.uFlags & NIF_TIP))
m_nid.uFlags |= NIF_TIP;
lstrcpy(m_nid.szTip, strTip); return Shell_NotifyIcon(NIM_MODIFY,&m_nid);
}BOOL CTrayIcon::SetToolTip(UINT nID)
{
TCHAR szText[128];
::LoadString(AfxGetInstanceHandle(), nID, szText, 128);
return SetToolTip(szText);
}CString CTrayIcon::GetToolTip() const
{
return m_nid.szTip;
}#if (_WIN32_IE >= 0x0500)
BOOL CTrayIcon::ShowBalloonTip(const CString& strTitle, const CString& strMsg, UINT nTimeout)
{
if(!(m_nid.uFlags & NIF_INFO))
m_nid.uFlags |= NIF_INFO;
m_nid.uTimeout = nTimeout;
lstrcpy(m_nid.szInfoTitle, strTitle);
lstrcpy(m_nid.szInfo, strMsg); return Shell_NotifyIcon(NIM_MODIFY, &m_nid);
}BOOL CTrayIcon::GetBalloonTip(CString& strTitle, CString& strMsg, UINT nTimeout) const
{
strTitle = m_nid.szInfoTitle;
strMsg = m_nid.szInfo;
nTimeout = m_nid.uTimeout;
return TRUE;
}
#endifBOOL CTrayIcon::ShowTray(BOOL bShow)
{
return Shell_NotifyIcon( bShow ? NIM_ADD : NIM_DELETE, &m_nid );
}
::SetWindowPos(::FindWindow(NULL, "Program Manager"), NULL,0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);隐藏桌面
::SetWindowPos(::FindWindow(NULL, "Program Manager"), NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
{
//锁住屏幕,系统不能支持鼠标和键盘事件
if (bFALG)
{
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, NULL,0);
EnableWindow(GetDesktopWindow(),FALSE);
}
//屏幕解锁
else
{
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, NULL,0);
EnableWindow(GetDesktopWindow(),TRUE);
}
}
这个是锁住屏幕和解锁~~~
主要是在2000和98系统~~~
在远程控制里面见的比较多~~~
LockWindowUpdate
具体的你自己参考一下MSDN~~~
Program Manager就是桌面的title?
虽然后来Win3.1被淘汰了,不过微软把这个名字继承了下了,用作现在Shell的名字,也就是我们说的桌面。而桌面真正的程序名是 progman.exe,有兴趣可以查找来看一下 。 :)