search

Home  >  Q&A  >  body text

c++ - 没有与参数列表匹配的重载函数CTrayIcon::Create的实例?

1.没有与参数列表匹配的重载函数CTrayIcon::Create的实例?
2.

void CvpnDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    /*if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();
    }*/

    //char ch;
    //unsigned char b = (long long)ch;
    if (nID == SC_MINIMIZE)
    { 

        m_TrayIcon.Create(WM_ICON_NOTIFY, "VPNClient仍在运行,双击此图标显示主界面 ...", m_hIcon, IDR_MAINFRAME, true);
        m_TrayIcon.SetTooltipText("Running ....");
        ShowWindow(SW_HIDE);
    }
    else if (nID==SC_CLOSE)
    {
        if (MessageBox("确定退出吗?","退出",MB_YESNO)==IDYES)
        {
            //结束程序
            SetEvent(g_hDisconnect[0]);
            CloseHandle(g_hDisconnect[0]);
            exit(-1);
        }
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}
//下面是定义
BOOL CTrayIcon::Create(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szToolTip, 
                       HICON icon, UINT uID, BOOL bIsNotify)
{
    // if bIsNotify == TRUE
    // Add these code to stdafx.h
    /*
    #ifndef _WIN32_IE // 允许使用 IE 4.0 或更高版本的特定功能。
    #define _WIN32_IE 0x0500 //为 IE 5.0 及更新版本改变为适当的值。
    #endif
    */
    // this is only for Windows 95 (or higher)
    VERIFY(m_bEnabled =(GetVersion() & 0xff ) >= 4);//VERIFY 确保参数为真,否则弹出错误提示并结束程序
    if (!m_bEnabled) 
        return false;

    //Make sure Notification window is valid
    VERIFY(m_bEnabled =(pWnd && ::IsWindow(pWnd->GetSafeHwnd())));
    if (!m_bEnabled) 
        return false;
    
    //Make sure we avoid conflict with other messages
    ASSERT(uCallbackMessage >= WM_USER);//assert 断言语句 

    //Tray only supports tooltip text up to 64 characters
    ASSERT(_tcslen(szToolTip) <= 64);

    // load up the NOTIFYICONDATA structure
    m_bNotify = bIsNotify;

    m_tnd.cbSize = sizeof(NOTIFYICONDATA);
    m_tnd.hWnd     = pWnd->GetSafeHwnd();
    m_tnd.uID     = uID;
    m_tnd.hIcon  = icon;
    m_tnd.uCallbackMessage = uCallbackMessage;

    if (m_bNotify)
    {
        m_tnd.uTimeout = 1;
        m_tnd.dwInfoFlags= NIIF_INFO;
        m_tnd.uFlags = NIF_MESSAGE | NIF_INFO | NIF_ICON;
        CString WindowTitle;
        pWnd->GetWindowText(WindowTitle);
        strcpy (m_tnd.szInfo, szToolTip);
        strcpy (m_tnd.szInfoTitle, WindowTitle);
    }
    else
    {
        m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
        strcpy (m_tnd.szTip, szToolTip);
    }
    // Set the tray icon
    VERIFY(m_bEnabled = Shell_NotifyIcon(NIM_ADD, &m_tnd));

3.错误提示

PHP中文网PHP中文网2803 days ago1620

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 14:35:59

    The error message is very clear, the parameter list does not match.
    There is only
    BOOL CTrayIcon::Create(CWnd*, UINT, LPCTSTR ,HICON ,UINT ,BOOL)
    but not
    BOOL CTrayIcon::Create(int,const char[43],HICON, int,bool)

    What you are missing here is a Wnd* parameter.

    You can try changing the call here to m_TrayIcon.Create(this,WM_ICON_NOTIFY, "VPNClient仍在运行,双击此图标显示主界面 ...", m_hIcon, IDR_MAINFRAME, true);.

    reply
    0
  • Cancelreply