CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    San Diego
    Posts
    155

    How do I set up my own message in message map?

    Hi,

    I want to setup my own message (MM_REFRESH), and I don't know what exactly to do. Funny how none of my 5 books say anything on this.. hehe.

    Anyways, I thought that I should enter
    afx_msg void OnRefreshTerm();
    to the message map in the header file. I then thought I should add ON_MM_REFRESH() to the message map in the cpp file.

    What am I doing wrong here? I want MM_REFRESH to execute OnRefreshTerm().
    Iwould also like to know what the proper way to call the message is. (ie this->SendMessage(MM_REFRESH, ???, ???);

    Thanks


  2. #2
    Join Date
    Aug 1999
    Posts
    13

    Re: How do I set up my own message in message map?

    In the message map you should put:

    ON_MESSAGE(MM_REFRESH, OnRefreshTerm)

    HTH,

    James Armstrong


  3. #3
    Join Date
    Jun 1999
    Location
    No, no, over here!
    Posts
    26

    Re: How do I set up my own message in message map?

    MFC doesn't know about your message, so it's not going to have a pre-defined macro (#define) called ON_MM_REFRESH. Instead, you have to use ON_MESSAGE in your message map, like this:
    ON_MESSAGE(MM_REFRESH, OnRefreshTerm)


    If you are sending from the saying object (sending to "this"), then just call SendMessage(MM_REFRESH, ...). The other two parameters depend on what the function that handles the message expects for wParam and lParam.

    Hope this helps,
    Brad


  4. #4
    Join Date
    Jul 1999
    Posts
    8

    Re: How do I set up my own message in message map?

    The first thing you want to do is to place a constant that represents the message in the overall header file:
    #define WM_REFRESH (WM_USER+1)
    Next connect the message to the handler with the macro in the message map:

    BEGIN_MESSAGE_MAP(.. , ..)
    ON_MESSAGE(WM_REFRESH,OnRefresh())
    END_MESSAGE_MAP()

    Lastly, place prototype of OnRefresh in the class header and write the fuction itself.

    Enjoy........


  5. #5
    Join Date
    Aug 1999
    Location
    San Diego
    Posts
    155

    Re: How do I set up my own message in message map?

    You guys rule.. thanks


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