Solved

RegisterWindowMessage

Posted on 2000-04-26
8
291 Views
Last Modified: 2013-12-04
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
Comment
Question by:hasmet
8 Comments
 
LVL 3

Accepted Solution

by:
GlennDean earned 300 total points
ID: 2753369
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
 
LVL 15

Expert Comment

by:NickRepin
ID: 2753493
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
 
LVL 1

Author Comment

by:hasmet
ID: 2755186
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 23

Expert Comment

by:chensu
ID: 2755897
Have you tried using Spy++ to see if the message is indeed sent?
0
 
LVL 1

Author Comment

by:hasmet
ID: 2757077
Adjusted points from 200 to 300
0
 
LVL 1

Author Comment

by:hasmet
ID: 2757078
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
 
LVL 1

Author Comment

by:hasmet
ID: 2757093
I am sorry, I my program was complicated
but when I simplified it, I could
see your answer.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2757100
GlennDann already gave you the right answer.

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

but not ON_MESSAGE
   
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question