Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - CXTPTrayIcon failed due to time out
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPTrayIcon failed due to time out

 Post Reply Post Reply
Author
Message
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Topic: CXTPTrayIcon failed due to time out
    Posted: 21 November 2016 at 10:40am
Hi,
Dialog similar to the TrayIconDlg sample.
The Create method to create the Tray Icon failed.
GetLastError get rc=1460 (ERROR_TIMEOUT).
if (!m_TrayIcon.Create(
    _T("Event24x7 Gateway Server"),    // Toolktip text
    this,                                // Parent window
    IDI_TRAYICON,               // Icon resource ID
    IDR_POPUP_TRAY,          // Resource ID of popup menu
    IDR_RESTORE,                // Default menu item for popup menu
    false))                              // True if default menu item is located by position
{           
    csEzer.Format(L"TrayIcon.Create failed rc=%Ld", GetLastError()) ;
    AddLineToLog(csEzer) ;
    TRACE0("Failed to create tray icon\n");
    return -1;
}

Please advice
Thanks,
Yoavm



Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 22 November 2016 at 2:57pm
Hello,

I can't reproduce your issue with v17.3, with TrayIconDlg sample.
Please write more information. Version of 
Windows, ToolkitPro, VisualStudio. Code snippet or ideally a sample application so that we could debug it.

Regards,
 Oleksandr Lebed
Back to Top
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Posted: 22 November 2016 at 6:51pm
Hi,

Windows 2008

TollkitPro 17.2 and also at 16.3.1.

Visual Studio 6.0

 

Used to work for some years. Suddenly several different sites reported about this error.

At our lab it doesn’t happen.

As you can see the code for creating the Tray Icon is identical to yours TrayIconDlg sample.

Since this problem not happening always at all places how can we debug it?

What potentially can causes time out at this call?

Tell me what else I can send.

Thanks,

Yoavm

Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 23 November 2016 at 2:49am
I think that error from calling ::Shell_NotifyIcon() in 

> CXTPTrayIcon::ShellNotify(unsigned long dwMessage) Line 129 C++
  CXTPTrayIcon::AddIcon() Line 333 C++
  CXTPTrayIcon::Create(const wchar_t * lpszCaption, CWnd * pParentWnd, unsigned int nIconID, unsigned int uMenuID, unsigned int uDefMenuItemID, bool bDefMenuItemByPos) Line 533 C++

and answer is  here
Originally posted by Bill Bill wrote:

Shell_NotifyIcon communicates with the Explorer desktop by sending a message with SendMessageTimeout. Shell_NotifyIcon itself does not call SetLastError, so the ERROR_TIMEOUT value you are getting from GetLastError is likely coming from the SendMessageTimeout call. That Shell_NotifyIcon has called SendMessageTimeout indicates that the taskbar window has been created at the time your process calls Shell_NotifyIcon, and the timeout suggests that either the thread that owns the taskbar window has not started pumping window messages or the thread is otherwise blocked.

 

The only real option is to retry the Shell_NotifyIcon call to add your notification icon (NIM_ADD), perhaps after some period of time, such as 5 or 10 seconds.
Back to Top
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Posted: 08 December 2016 at 11:09am
Hi,
Sorry for the delay. It took some time to test it by the customer.
I changed the method ShellNotify from member XTPTrayIcon.cpp:
BOOL CXTPTrayIcon::ShellNotify(DWORD dwMessage)
{
    BOOL bOk;
    int i;
    bOk = false;
    for (i=0; i<20 && !bOk; i++)
    {
        bOk = ::Shell_NotifyIcon(dwMessage, (PNOTIFYICONDATA)&m_niData);
        if (bOk == (BOOL)false)
        {
            Sleep(10000);
        }
    }

    //return ::Shell_NotifyIcon(dwMessage, (PNOTIFYICONDATA)&m_niData);
    return (bOk);
}

Bottom line, creating of the tray icon failed with rc=1008
Is this what you had in mind or there is different way to solve it?

Thanks
yoavm
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 08 December 2016 at 12:08pm
Hello yoavm,

I think it should solve your problem.
So Do your customer no longer gets timeout errors ?
Back to Top
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Posted: 08 December 2016 at 4:16pm
Hi,

It didn't.

The call TrayIcon.Create(... now return code 1008 and the tray icon doesn't appears.

yoavm
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2016 at 5:16am
If you test fixed ShellNotify() method with TrayIconDlg sample then I can say that there is an error in method CTrayIconDlgDlg::OnInitDialog()  - OnBtnShowBalloon() called before creating m_TrayIcon. Should be called even after m_TrayIcon.SetAnimationIcons().
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.170 seconds.