MFC user defined message

I'd like to create a user defined message to have a thread pass a message back to the main MFC application.  

My understanding of how to do this is as follows;

1. Register the message:
static const int WMU_RUN_COMPLETE = RegisterWindowMessage("WMU_RUN_COMPLETE");

2. Declare the function that will eventually handle the message;
afx_msg LRESULT OnRunComplete(WPARAM wParam, LPARAM lParam);

3. Add it to the message map;

4. Register the same message name in my thread;
static const int WMU_RUN_COMPLETE = RegisterWindowMessage("WMU_RUN_COMPLETE");

5. Send the message from my thread;
SendMessage(hwnd, MY_WM_RUN_COMPLETE, (WPARAM)0, (LPARAM)0);

I haven't even gotten to steps 4 and 5 yet.  When I compile, I get an undeclared identifier, WMU_RUN_COMPLETE, because of the reference in the message map.

Where am I supposed to put the WMU_RUN_COMPLETE declaration and RegisterWindowMessage?

Note, this is a dialog based application and not a full document view app.

This is the first time I've tried this, so any other comments would be appreciated.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Place the line
static const int WMU_RUN_COMPLETE = RegisterWindowMessage("WMU_RUN_COMPLETE");

to h-file and include it to every cpp file where it is used.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnSantaFeAuthor Commented:

I was trying to declare it as a public member of the clas : {

I moved it up out of the class but still in the .h file and that worked.

Thanks for the tip.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.