诚心请教!

解决方案 »

  1.   

    哦。你是说在任务栏没有图标哦。使用:
    FUNCTION ulong Shell_NotifyIcon(ulong dwMessage,ref NOTIFYICONDATA lpData)
      

  2.   

    SyntaxBOOL Shell_NotifyIcon(          DWORD dwMessage,
        PNOTIFYICONDATA lpdata
    );
    ParametersdwMessage:
    [in] Variable of type DWORD that specifies the action to be taken. It can have one of the following values: NIM_ADD
    Adds an icon to the status area. The hWnd and uID members of the NOTIFYICONDATA structure pointed to by lpdata will be used to identify the icon in later calls to Shell_NotifyIcon. NIM_DELETE
    Deletes an icon from the status area. Use the hWnd and uID members of the NOTIFYICONDATA structure pointed to by lpdata to identify the icon to be deleted. NIM_MODIFY
    Modifies an icon in the status area. Use the hWnd and uID members of the NOTIFYICONDATA structure pointed to by lpdata to identify the icon to be modified. NIM_SETFOCUS
    Version 5.0. Returns focus to the taskbar notification area. Taskbar icons should use this message when they have completed their user interface operation. For example, if the taskbar icon displays a shortcut menu, but the user presses ESC to cancel it, use NIM_SETFOCUS to return focus to the taskbar notification area. NIM_SETVERSION
    Version 5.0. Instructs the taskbar to behave according to the version number specified in the uVersion member of the structure pointed to by lpdata. This message allows you to specify whether you want the version 5.0 behavior found on Microsoft® Windows® 2000 systems, or that found with earlier Shell versions. The default value for uVersion is zero, indicating that the original Windows 95 notify icon behavior should be used. For details, see the Res section. lpdata:
    [in] Address of a NOTIFYICONDATA structure. The content of the structure depends on the value of dwMessage. 
    Return Value
      

  3.   

    发信人: yxm (勇敢的弱者), 信区: VisualC
    标  题: Re: 如何使程序只出现在 托盘
    发信站: BBS 水木清华站 (Tue May 15 16:40:05 2001)
        重载PreCreateWindow()函数,在其中加入
            // 创建一个隐藏窗口
            if (!::IsWindow(m_wndParent.m_hWnd))
            {
                    LPCTSTR pstrOwnerClass = AfxRegisterWndClass(0);
                    if (!m_wndParent.CreateEx(0, pstrOwnerClass, "", WS_POPUP,
                                    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_
    USEDEFAULT,
                                    NULL, 0))
                            return FALSE;
            }
            cs.hwndParent = m_wndParent.m_hWnd;
         其中m_wndParent是成员变量,是CWnd类型的。
       这样的话,程序就可以不出现在工具栏和任务管理器的应用程序中,但是无论如何还
    是会在进程中(Win2000中)。
       之后,要做的工作就是做一个系统托盘的工作了。呵呵。
       这样,虽说可以达到你的要求,不过,还是有点不好的地方,最小化的时候总是先跑
    到屏幕的最左下角才消失掉。
      

  4.   

    发信人: April (椰风海韵), 信区: VisualC
    标  题: Re: 如何使程序只出现在 托盘
    发信站: BBS 水木清华站 (Tue May 15 21:17:33 2001)其实用shell就可以了实现不在taskbar上出现的.
       typedef ITaskbarList *LPITaskbarList;
        LPITaskbarList pTaskbar = NULL;
                    CoInitialize(0);
                    CoCreateInstance(CLSID_TaskbarList,0,
    CLSCTX_INPROC_SERVER,IID_ITaskbarList,
    (void **)&pTaskbar);    //CLSID_TaskbarList在SHLGUID.H里有定义,创建Taskbar COM
    对象指针
                    pTaskbar->HrInit();
                    pTaskbar->DeleteTab(AfxGetMainWnd()->GetSafeHwnd());
    要是进程不在任务管理里出现:
    98下用RegisterServiceProces:
    nt/2000没有什么好办法,可以注册成系统进程或者干脆象BO那样把进程代码copy进去
    系统进程空间运行.
      

  5.   

    ^__^感谢I_Love_CPP(我爱C++) 的方法,贴在这里给大家共享。
    发送者 I_Love_CPP 发送时间 2004-11-18 18:08:09 删除  回复  
    内容 用我提供给你的方法可以,但很麻烦尤其是我要给你说清楚很麻烦,所以我仔细查阅了一下文献,找到了另一个替代的方法,特点是非常非常简单:
    以基于对话框为例给你讲解:
    BOOL CxxApp::InitInstance()
    {  /*-------------添加的代码开始----------------------------*/
           CxxxDlg dlgParent;
           dlgParent.Create(IDD_DLGVIEW_DIALOG);//这会造成一次闪烁
           dlgParent.ShowWindow(SW_HIDE);       
      /*--------------添加的代码结束----------------------------*/
           CxxxDlg dlg(&dlgParent);//还要修改这儿
           m_pMainWnd = &dlg;
           INT_PTR nResponse = dlg.DoModal();
           if (nResponse == IDOK)
             ........
    }
    然后在:
    BOOL CxxxDlg::OnInitDialog()里面添加:
    this->ModifyStyleEx(WS_EX_APPWINDOW, 0);呵呵,就搞定了。我已经调试成功了。虽然有缺点(闪烁一次),但这么简单地完成任务已经不错了。
    去交差吧!!!  :)
     
      

  6.   

    我这里补充以下: 我的对话框属性的Styles-Title bar没有被选中,所以,当我运行的时候,连闪烁都没有,效果非常好好! 再次感谢I_Love_CPP(我爱C++)