dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: System Tray Icon Popup menu bug

  1. #1
    Join Date
    Jul 2005
    Posts
    266

    System Tray Icon Popup menu bug

    Hm i don't know what can be causing this but this is my code
    Code:
    CPoint pt;
    GetCursorPos (&pt);
        CMenu menu,*sub;
    	menu.LoadMenu (IDR_MENU1);
    	sub = menu.GetSubMenu(0);
    	::SetMenuDefaultItem(sub->m_hMenu,0,TRUE);
    	SetForegroundWindow();
    	::TrackPopupMenu(sub->m_hMenu,0, pt.x, pt.y,0,this->m_hWnd,NULL); 
    	::PostMessage(this->m_hWnd, WM_NULL, 0, 0);
    So what happens is
    i click with my right button on the icon sometimes it shows this menu (IDR_MENU1) only ( as it should be) but sometimes it shows me both this menu and the menu which appears when you right click some empty space on the taskbar it is really messy and buggy
    Any help is appreciated!

  2. #2
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: System Tray Icon Popup menu bug

    I am clearly not clear with ur question and the definition. can u explain ur problem clearly now?
    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

  3. #3
    Join Date
    Jul 2005
    Posts
    266

    Re: System Tray Icon Popup menu bug

    ok i set up a tray icon
    when i right click it a menu appears
    sometimes when i right click the icon my menu appears along with the taskbar menu
    now you get it?

  4. #4
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: System Tray Icon Popup menu bug

    How do you handle the right click on the icon.
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  5. #5
    Join Date
    Jul 2005
    Posts
    266

    Re: System Tray Icon Popup menu bug

    Code:
    LRESULT CsttrayDlg::OnTrayNotify(WPARAM wParam, LPARAM lParam)
      {
      
      
     CPoint pt;  
      
      
        switch (lParam)
    {
    
        case WM_LBUTTONDOWN:
          GetCursorPos(&pt);
    	  ClientToScreen(&pt);
    	  CsttrayDlg::OnTrayLButtonDown(pt);
          break;
      
        case WM_RBUTTONDOWN:
        case WM_CONTEXTMENU:
          GetCursorPos(&pt);
    
          CsttrayDlg::OnTrayRButtonDown(pt);
          break;
    }
    return 0;
    }

  6. #6
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: System Tray Icon Popup menu bug

    You have to get the notify message to.
    When you build the Tray icon
    Code:
    NOTIFYICONDATA lpdata;
    .
    .
    .
    
    lpdata.uFlags=NIF_ICON|NIF_MESSAGE;
    lpdata.uCallbackMessage=WMU_NOTIFY;
    Code:
    //define in the handle
    #define WMU_NOTIFY WP_APP+1
    //call WindowProc
    .
    .
    if(message==WMU_NOTIFY&&LOWORD(lParam)==WM_RBUTTONUP)
    Something like this.
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  7. #7
    Join Date
    Jul 2005
    Posts
    266

    Re: System Tray Icon Popup menu bug

    Well i don't need to do this because my message
    is here
    in there message map
    There is something else wrong
    ON_MESSAGE(WM_TRAY_MESSAGE ,OnTrayNotify)

  8. #8
    Join Date
    Jul 2005
    Posts
    266

    Re: System Tray Icon Popup menu bug

    hey i figured it out
    i should use WM_RBUTTONUP instead of RBUTTONDOWN
    this works!
    10x anywayz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)