Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:


const UINT CWndExcel::WM_GETNAVINFO = (0xC111); //::RegisterWindowMessage(_T("WM_GETNAVINFO"));

I have one dialog app(MFC based but question is Windows Q);
I also have a dll that loads to excel and subclass excel. I want to send message from
excel_subclassed window  to dialog window.

if I use above a value WM_USER + x
I get the message.
if I use WM_APP + x < 0xc000
works fine
but if I use RegisterWindowMessage
to get my message no
for example the one I get is 49597
between 0xc000 and 0xffff
I dont receive the message.
both windows has exactly the same message no, but no response ????
this is windows 2000, I also randomly
selected (semi random) 0xc111,
that did not work. it seems if message no >= 0xc000 it fails ??
what to do ???
1 Solution
You can't declare the WM_USER message handler the same as for those of a RegisterWindowMessage.  
  The macro you must use is

const UINT CWndExcel::WM_GETNAVINFO = (0xC111); //::RegisterWindowMessage(_T("WM_GETNAVINFO"));

That is wrong.

You have to call RegisterWindowMessage both in the dll and in your app and use the returned value, but not the hard-code it.

This line must be BOTH in the dll and in the app:

const UINT CWndExcel::WM_GETNAVINFO = ::RegisterWindowMessage(_T("WM_GETNAVINFO"));

hasmetAuthor Commented:
Yes of course, I am sorry if I confuse you but that is exactly what I do.
when it did not work then I started putting hard code values.
im my app I use
const UINT CMyDlg::WM_GETNAVINFO = ::RegisterWindowMessage(_T("WM_GETNAVINFO"));

in dll
const UINT CWndExcel::WM_GETNAVINFO = ::RegisterWindowMessage(_T("WM_GETNAVINFO"));

this is the the way it does not work??
so when I try hard code values,
instead of creating them with
RegisterWindowMessage, then it works if values are less than 0xc000.
above 0xc000, it doesnot work and this is the range of RegisterWindowMessage
anyway ??? so it seems RegisterWindowMessage range is infeasible???

I delibaretly commented out
RegisterWindowMessage in my question above to test some hard code values.

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Have you tried using Spy++ to see if the message is indeed sent?
hasmetAuthor Commented:
Adjusted points from 200 to 300
hasmetAuthor Commented:
SPY++ SHOWS THAT message is send;
0038038A S message:0xC1BD[Registered:"WM_GETNAVINFO"] wParam:00000000 lParam:00000000

in fact I now created two dlg (MFC)
apps, one sends one receives.
the receiving one is as below

const UINT CAppdlgDlg::WM_GETNAVINFO = ::RegisterWindowMessage(_T("WM_GETNAVINFO"));
LRESULT CAppdlgDlg::OnGetInfo(WPARAM wParam, LPARAM lParam)
      Beep(3000, 200);
      return 0;
LRESULT CAppdlgDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
      // TODO: Add your specialized code here and/or call the base class
      if(WM_GETNAVINFO == message)
            Beep(3000, 200);
      return CDialog::DefWindowProc(message, wParam, lParam);

this is odd but DefWindowProc gets it and beeps. but not coming to OnGetInfo ???

remember that if the message is WM_APP + 100, it works !! so it is not a matter
of implementing it, somehow MFC fails to
deliver it from DefWindowProc to
OnGetInfo ??? this is really odd ???
I am sorry this question may be an MFC
section, but most experts know it here anyway.
hasmetAuthor Commented:
I am sorry, I my program was complicated
but when I simplified it, I could
see your answer.
GlennDann already gave you the right answer.


but not ON_MESSAGE
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now