Results 1 to 7 of 7

Thread: messages for trayicon

  1. #1

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    For the user-defined message simply do
    #define WM_MYMESSAGE WM_USER + [offset]
    replace [offset] by any number > 0 you want.

    For MFC:
    Add the ON_MESSAGE macro to the message map like this:
    Code:
    // example for ON_MESSAGE
    #define WM_MYMESSAGE (WM_USER + 1)
    BEGIN_MESSAGE_MAP( CMyWnd, CMyParentWndClass )
        //{{AFX_MSG_MAP( CMyWnd
        ON_MESSAGE( WM_MYMESSAGE, OnMyMessage )
        // ... Possibly more entries to handle additional messages
        //}}AFX_MSG_MAP
    END_MESSAGE_MAP( )
    OnMyMessage is the message handler function. It must have this prototype:
    afx_msg LRESULT OnMyMessage(WPARAM, LPARAM);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  2. #2
    Lively Member
    Join Date
    Oct 2001
    Location
    Netherlands
    Posts
    115
    how can I put the value of WPARAM of LPARAM in a textbox?

    VisualPenguin
    ICQ :137108715
    MSN Messenger : [email protected]

  3. #3

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What do those values represent?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4
    Lively Member
    Join Date
    Oct 2001
    Location
    Netherlands
    Posts
    115
    you said they had to be there, so I've put them there. There has to be a variable that contains the number so I know if someone clicked the icon. In VB these variables are long.

    VisualPenguin
    ICQ :137108715
    MSN Messenger : [email protected]

  5. #5

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yes, I know. The first one is a 32-bit unsigned integer and the second one a 32-bit signed integer. But I can't find what they represent. (One must be some flag what happened: mouse click, move, up, down etc)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I know what the lParam can represent. Here is some sample code from my Systray code. It is not MFC though.

    PHP Code:
    case WM_TRAYNOTIFY:                                    //Used For The Systray Msgs
            
    {
                switch(
    LOWORD(lParam))    
                {
                    case 
    WM_LBUTTONDBLCLK:                        //If Double Click On The Icon
                    
    {
                        
    BOOL ret;

                        
    ret IsWindowVisible(m_hWnd);            //Is Window Already Visable

                        
    if(ret)
                        {
                            if(
    m_hWnd_Options != 0x00000000)    //If It Is Set Focus To It
                                
    SetFocus(m_hWnd);
                        }
                        else
                        {
                            
    ShowWindow(m_hWnd,SW_SHOW);            //Else Show The Main Window
                            
    ShowWindow(m_hWnd_Msg,SW_SHOW);        //So The Message List Window
                        
    }

                        break;
                    }  
    //WM_LBUTTONDBLCLK

                    
    case WM_RBUTTONUP:                            //If A Right Click On The Systray Icon
                    
    {
                        
    m_SysTray.ShowMenu();                    //Show The Systray Menu
                        
    break;
                    }  
    //WM_RBUTTONUP

                    
    default:
                        break;
                }
                break;
            }    
    //WM_TRAYNOTIFY 
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  7. #7

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    That would work for MFC too, except for the action taken.
    Code:
    // in message map
    ON_MESSAGE(WM_TRAYNOTIFY, OnTrayNotify)
    
    // function
    LRESULT CMyWnd::OnTrayNotify(WPARAM wParam, LPARAM lParam)
    {
      switch(LOWORD(lParam))
      {
      case WM_LBUTTONDBLCLK:
        if(IsWindowVisible())
        {
          SetFocus();
        }
        else
        {
          ShowWindow(SW_SHOW);
          m_wndMsg.ShowWindow(SW_SHOW);
        }
    // ...
      }
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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