Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

RegisterWindowMessage

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 ???
0
hasmet
Asked:
hasmet
1 Solution
 
GlennDeanCommented:
You can't declare the WM_USER message handler the same as for those of a RegisterWindowMessage.  
  The macro you must use is
ON_REGISTERED_MESSAGE(CWndExcel::WM_GETNAVINFO,"Your handler")

   Glenn
0
 
NickRepinCommented:
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"));

0
 
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.


0
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.

 
chensuCommented:
Have you tried using Spy++ to see if the message is indeed sent?
0
 
hasmetAuthor Commented:
Adjusted points from 200 to 300
0
 
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"));
BEGIN_MESSAGE_MAP(CAppdlgDlg, CDialog)
      //{{AFX_MSG_MAP(CAppdlgDlg)
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      //}}AFX_MSG_MAP
      ON_MESSAGE(WM_GETNAVINFO, OnGetInfo)
END_MESSAGE_MAP()
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.
0
 
hasmetAuthor Commented:
I am sorry, I my program was complicated
but when I simplified it, I could
see your answer.
0
 
NickRepinCommented:
GlennDann already gave you the right answer.

ON_REGISTERED_MESSAGE(CWndExcel::WM_GETNAVINFO,"Your handler")

but not ON_MESSAGE
   
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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