CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    260

    2 CDialogs and sharing 1 systray icon - how to implement?

    Hello Everyone,
    I have previously been able to get one dialog and 1 systray icon to be working, I could right-click on the icon and get the msg trapped. This is all good until I have to add another CDialog to the project. I do DoModal() on both dialogs with threads so that one could be visible while the other is not.


    I have tried to add the systray icon in the CWinApp and Dialog1. However, the most troubling part is to have the right-click msg be trapped and routed.

    Please help me with clarifying the following:
    1. m_IconData.hWnd = m_hwnParent->GetSafeHwnd()
    * m_hwnParent is the "this" pointer passed in from dialog1

    Does m_IconData.hWnd have to be associated with a window that is active all the time? Since one of my 2 dialogs will be hidden while the other is shown.
    Is there from GetAfxApp() that I can pass for this value?

    2. In OnTrayNotification(WPARAM wParam, LPARAM lParam) I have
    m_hwnParent->SendMessage(WM_SYSTRAYICON_CLICKED,0 ,(LPARAM) &pos );

    I have naively thought that if I changed the value of hwnParent while I do the ShowWindow(SW_SHOW/SW_HIDE) handling, I could have the right-click msg being trapped and send to the window that is active at the time the click takes place.
    Is this a correct assumption?

    My ultimate question is it possible to have 2 dialogs, one is always hidden while the other is shown during the lift time of the app, to process the right-click from the SysTray icon?

    Desparated.

    Jiac

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757

    Re: 2 CDialogs and sharing 1 systray icon - how to implement?

    Another approach is have mainframe be the proxy to the dialog windows.

    Kuphryn

  3. #3
    Join Date
    Jul 2003
    Posts
    260

    Re: 2 CDialogs and sharing 1 systray icon - how to implement?

    I tried to have a parent mainframe and then the 2 child dialogs, however, this introduces the problem of moving the child dialog, i.e. it can't be move past the boundary of the parent window until the mouse is let go, and the boundary is reset.

    Or unless I mistaken you, then please give me some clarifications.

    Thank you and still desparate,
    Jiac

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured