From: Ranger on
After talking to the concierge, I found out that there is no managed
newsgroup specific to pocketpc or wm5.0 questions. So I am posting this
here.

I am a C++ developer on WM5.0. Starting with the notifyMFC example from the
WM5.0 SDK, I am creating a notification and calling SHNotificationAdd from a
method in my dialog. I am filling out SHNOTIFICATIONDATA as follows...

HICON hIcon =(HICON)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);

SHNOTIFICATIONDATA* pCurrentNotification =(SHNOTIFICATIONDATA*)malloc(
sizeof(SHNOTIFICATIONDATA));

CString html = CString(_T("Test"));

pCurrentNotification->dwID = 10000;
pCurrentNotification->clsid = guidNotifyApp;
pCurrentNotification->npPriority = SHNP_INFORM;
pCurrentNotification->csDuration = 20;
pCurrentNotification->hwndSink = this->GetSafeHwnd();
pCurrentNotification->pszHTML = html;
pCurrentNotification->hicon = hIcon;
pCurrentNotification->cbStruct = sizeof(SHNOTIFICATIONDATA);
pCurrentNotification->pszTitle = TEXT("Test Notification...");
pCurrentNotification->grfFlags = SHNF_FORCEMESSAGE;
pCurrentNotification->rgskn[0].pszTitle = TEXT("SK1");
pCurrentNotification->rgskn[0].skc.wpCmd = IDM_SK1;
pCurrentNotification->rgskn[0].skc.grfFlags =
NOTIF_SOFTKEY_FLAGS_DISMISS;
pCurrentNotification->rgskn[1].pszTitle = TEXT("SK2");
pCurrentNotification->rgskn[1].skc.wpCmd = IDM_SK2;
pCurrentNotification->rgskn[1].skc.grfFlags =
NOTIF_SOFTKEY_FLAGS_DISMISS;

SHNotificationAdd(pCurrentNotification);

I have the following lines in the MESSAGE_MAP for my dialog.

ON_COMMAND(IDM_SK1, OnSK1)
ON_COMMAND(IDM_SK2, OnSK2)

When I select either softkey, I get an assert on line 2592 of wincore.cpp.
This is in CWnd::OnCommand() and the assert is ASSERT(nID == 0 ||
::IsWindow(hWndCtrl)). The IsWindow() method returns false. hWndCtrl doesn't
seem to be the window handle. In fact it is the value of dwID I set in the
SHNOTIFICATIONDATA struct.

If I use the notifyMFC sample from wce500, I don't get an assert. It
doesn't use MFC and MESSAGE_MAP. It uses a callback that switches on message
which hits the WM_COMMAND case with LOWORD(wParam) equal to IDM_SK1 or
IDM_SK2.

If I set dwID to zero, my OnSK1/OnSK2 methods execute but then my
application cannot have more than one notification.

Is there a way to get this to work with MFC and MESSAGE_MAP?
From: "TerryFei" on
Hi,
Welcome to MSDN Newsgroup!

Based on my knowledge, you can try the following workaround for this issue:
Since the OnCommand is a virtual method declared in CWnd class, we can
override it in our class derived from CWnd and copy / paste the code from
CWnd's, only remove ASSERT(nID == 0 ||::IsWindow(hWndCtrl)). Then try to
test your application whether or not it can work fine.

I hope the above information is helpful for you. If there is anything I can
do for you, please feel free to let me know. Thanks for your understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
>Thread-Topic: Assert with Notifications in WM5.0
>thread-index: AcZDjSTZLRQli8XWTRCDclDo7DFOzg==
>X-WBNR-Posting-Host: 192.216.148.182
>From: =?Utf-8?B?UmFuZ2Vy?= <ranger(a)nospam.nospam>
>Subject: Assert with Notifications in WM5.0
>Date: Thu, 9 Mar 2006 07:21:31 -0800
>Lines: 57
>Message-ID: <6D609A1C-F0E6-4387-9F66-682AEA8FF582(a)microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
>Newsgroups: microsoft.public.vc.mfc
>Path: TK2MSFTNGXA03.phx.gbl
>Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.vc.mfc:468789
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>X-Tomcat-NG: microsoft.public.vc.mfc
>
>After talking to the concierge, I found out that there is no managed
>newsgroup specific to pocketpc or wm5.0 questions. So I am posting this
>here.
>
>I am a C++ developer on WM5.0. Starting with the notifyMFC example from
the
>WM5.0 SDK, I am creating a notification and calling SHNotificationAdd from
a
>method in my dialog. I am filling out SHNOTIFICATIONDATA as follows...
>
> HICON hIcon =(HICON)LoadImage(AfxGetInstanceHandle(),
>MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
>
> SHNOTIFICATIONDATA* pCurrentNotification
=(SHNOTIFICATIONDATA*)malloc(
>sizeof(SHNOTIFICATIONDATA));
>
> CString html = CString(_T("Test"));
>
> pCurrentNotification->dwID = 10000;
> pCurrentNotification->clsid = guidNotifyApp;
> pCurrentNotification->npPriority = SHNP_INFORM;
> pCurrentNotification->csDuration = 20;
> pCurrentNotification->hwndSink = this->GetSafeHwnd();
> pCurrentNotification->pszHTML = html;
> pCurrentNotification->hicon = hIcon;
> pCurrentNotification->cbStruct = sizeof(SHNOTIFICATIONDATA);
> pCurrentNotification->pszTitle = TEXT("Test Notification...");
> pCurrentNotification->grfFlags = SHNF_FORCEMESSAGE;
> pCurrentNotification->rgskn[0].pszTitle = TEXT("SK1");
> pCurrentNotification->rgskn[0].skc.wpCmd = IDM_SK1;
> pCurrentNotification->rgskn[0].skc.grfFlags =
>NOTIF_SOFTKEY_FLAGS_DISMISS;
> pCurrentNotification->rgskn[1].pszTitle = TEXT("SK2");
> pCurrentNotification->rgskn[1].skc.wpCmd = IDM_SK2;
> pCurrentNotification->rgskn[1].skc.grfFlags =
>NOTIF_SOFTKEY_FLAGS_DISMISS;
>
> SHNotificationAdd(pCurrentNotification);
>
>I have the following lines in the MESSAGE_MAP for my dialog.
>
> ON_COMMAND(IDM_SK1, OnSK1)
> ON_COMMAND(IDM_SK2, OnSK2)
>
>When I select either softkey, I get an assert on line 2592 of wincore.cpp.

>This is in CWnd::OnCommand() and the assert is ASSERT(nID == 0 ||
>::IsWindow(hWndCtrl)). The IsWindow() method returns false. hWndCtrl
doesn't
>seem to be the window handle. In fact it is the value of dwID I set in
the
>SHNOTIFICATIONDATA struct.
>
>If I use the notifyMFC sample from wce500, I don't get an assert. It
>doesn't use MFC and MESSAGE_MAP. It uses a callback that switches on
message
>which hits the WM_COMMAND case with LOWORD(wParam) equal to IDM_SK1 or
>IDM_SK2.
>
>If I set dwID to zero, my OnSK1/OnSK2 methods execute but then my
>application cannot have more than one notification.
>
>Is there a way to get this to work with MFC and MESSAGE_MAP?
>

From: Ranger on
Terry,

I guess you are telling me that the implementation in CWnd may not be
correct or does not support commands from Notification softkeys. I
personally think that the way the command is generated for Notification
softkey presses is not correct.

Anyway, there are a few problems with overriding OnCommand and removing the
check. First of all, I would think that ASSERT for IsWindow would be desired
for all the other commands that come into my Dialog. I would only want to
skip it if the command was from a Notification SoftKey press. Second, there
is no header file for CTestCmdUI. Lastly, the reference to _afxThreadState
in OnCommand gives me an unresolved external symbol for my project. I
created my project using the defaults from VS2005 when creating an MFC Smart
Device Application and selecting WM5.0 (ARMV4I). Also I created it as a
Dialog based. I must need to set a compiler/linker option in my project
properties?

It also seems that this Notification mechanism is half-baked. It allows the
user to set lParam (a user-defined parameter according to MSDN documentation)
in SHNOTIFICATIONDATA. However, the lParam you get if you use a winproc
callback (like the notifyMFC sample from the SDK) has the value from
SHNOTIFICATIONDATA.dwID not SHNOTIFICATIONDATA.lParam. And if you use
MESSAGE_MAP, you don't even get an wParam or lParam. So it doesn't seem that
the notifier can use lParam to send data to the notifiee.

Any more insights?


""TerryFei"" wrote:

> Hi,
> Welcome to MSDN Newsgroup!
>
> Based on my knowledge, you can try the following workaround for this issue:
> Since the OnCommand is a virtual method declared in CWnd class, we can
> override it in our class derived from CWnd and copy / paste the code from
> CWnd's, only remove ASSERT(nID == 0 ||::IsWindow(hWndCtrl)). Then try to
> test your application whether or not it can work fine.
>
> I hope the above information is helpful for you. If there is anything I can
> do for you, please feel free to let me know. Thanks for your understanding!
>
> Best Regards,
>
> Terry Fei [MSFT]
> Microsoft Community Support
> Get Secure! www.microsoft.com/security
>
> --------------------
> >Thread-Topic: Assert with Notifications in WM5.0
> >thread-index: AcZDjSTZLRQli8XWTRCDclDo7DFOzg==
> >X-WBNR-Posting-Host: 192.216.148.182
> >From: =?Utf-8?B?UmFuZ2Vy?= <ranger(a)nospam.nospam>
> >Subject: Assert with Notifications in WM5.0
> >Date: Thu, 9 Mar 2006 07:21:31 -0800
> >Lines: 57
> >Message-ID: <6D609A1C-F0E6-4387-9F66-682AEA8FF582(a)microsoft.com>
> >MIME-Version: 1.0
> >Content-Type: text/plain;
> > charset="Utf-8"
> >Content-Transfer-Encoding: 7bit
> >X-Newsreader: Microsoft CDO for Windows 2000
> >Content-Class: urn:content-classes:message
> >Importance: normal
> >Priority: normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
> >Newsgroups: microsoft.public.vc.mfc
> >Path: TK2MSFTNGXA03.phx.gbl
> >Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.vc.mfc:468789
> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> >X-Tomcat-NG: microsoft.public.vc.mfc
> >
> >After talking to the concierge, I found out that there is no managed
> >newsgroup specific to pocketpc or wm5.0 questions. So I am posting this
> >here.
> >
> >I am a C++ developer on WM5.0. Starting with the notifyMFC example from
> the
> >WM5.0 SDK, I am creating a notification and calling SHNotificationAdd from
> a
> >method in my dialog. I am filling out SHNOTIFICATIONDATA as follows...
> >
> > HICON hIcon =(HICON)LoadImage(AfxGetInstanceHandle(),
> >MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
> >
> > SHNOTIFICATIONDATA* pCurrentNotification
> =(SHNOTIFICATIONDATA*)malloc(
> >sizeof(SHNOTIFICATIONDATA));
> >
> > CString html = CString(_T("Test"));
> >
> > pCurrentNotification->dwID = 10000;
> > pCurrentNotification->clsid = guidNotifyApp;
> > pCurrentNotification->npPriority = SHNP_INFORM;
> > pCurrentNotification->csDuration = 20;
> > pCurrentNotification->hwndSink = this->GetSafeHwnd();
> > pCurrentNotification->pszHTML = html;
> > pCurrentNotification->hicon = hIcon;
> > pCurrentNotification->cbStruct = sizeof(SHNOTIFICATIONDATA);
> > pCurrentNotification->pszTitle = TEXT("Test Notification...");
> > pCurrentNotification->grfFlags = SHNF_FORCEMESSAGE;
> > pCurrentNotification->rgskn[0].pszTitle = TEXT("SK1");
> > pCurrentNotification->rgskn[0].skc.wpCmd = IDM_SK1;
> > pCurrentNotification->rgskn[0].skc.grfFlags =
> >NOTIF_SOFTKEY_FLAGS_DISMISS;
> > pCurrentNotification->rgskn[1].pszTitle = TEXT("SK2");
> > pCurrentNotification->rgskn[1].skc.wpCmd = IDM_SK2;
> > pCurrentNotification->rgskn[1].skc.grfFlags =
> >NOTIF_SOFTKEY_FLAGS_DISMISS;
> >
> > SHNotificationAdd(pCurrentNotification);
> >
> >I have the following lines in the MESSAGE_MAP for my dialog.
> >
> > ON_COMMAND(IDM_SK1, OnSK1)
> > ON_COMMAND(IDM_SK2, OnSK2)
> >
> >When I select either softkey, I get an assert on line 2592 of wincore.cpp.
>
> >This is in CWnd::OnCommand() and the assert is ASSERT(nID == 0 ||
> >::IsWindow(hWndCtrl)). The IsWindow() method returns false. hWndCtrl
> doesn't
> >seem to be the window handle. In fact it is the value of dwID I set in
> the
> >SHNOTIFICATIONDATA struct.
> >
> >If I use the notifyMFC sample from wce500, I don't get an assert. It
> >doesn't use MFC and MESSAGE_MAP. It uses a callback that switches on
> message
> >which hits the WM_COMMAND case with LOWORD(wParam) equal to IDM_SK1 or
> >IDM_SK2.
> >
> >If I set dwID to zero, my OnSK1/OnSK2 methods execute but then my
> >application cannot have more than one notification.
> >
> >Is there a way to get this to work with MFC and MESSAGE_MAP?
> >
>
>
From: "TerryFei" on
Hi,
Thanks for your update!

In the current situation, I hope you can provide me a simplified sample,
which reproduces your issue so that I could debug it on our side. Since
this issue is about MFC Message Map, not related to WM5.0, I hope you can
remove code about WM5.0 for the simple sake. I think it will help us get
closer to this issue and be more effective to resolve it.

Thanks for your understanding. Have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security



--------------------
>Thread-Topic: Assert with Notifications in WM5.0
>thread-index: AcZEXLn7xcd5sY4fTZy4mqYZ5KZuLg==
>X-WBNR-Posting-Host: 192.216.148.182
>From: =?Utf-8?B?UmFuZ2Vy?= <ranger(a)nospam.nospam>
>References: <6D609A1C-F0E6-4387-9F66-682AEA8FF582(a)microsoft.com>
<bG9weH$QGHA.6296(a)TK2MSFTNGXA03.phx.gbl>
>Subject: RE: Assert with Notifications in WM5.0
>Date: Fri, 10 Mar 2006 08:07:27 -0800
>Lines: 140
>Message-ID: <14ACB976-3CC4-4EF1-A02C-DFFE514A5A6E(a)microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
>Newsgroups: microsoft.public.vc.mfc
>Path: TK2MSFTNGXA03.phx.gbl
>Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.vc.mfc:468958
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>X-Tomcat-NG: microsoft.public.vc.mfc
>
>Terry,
>
>I guess you are telling me that the implementation in CWnd may not be
>correct or does not support commands from Notification softkeys. I
>personally think that the way the command is generated for Notification
>softkey presses is not correct.
>
>Anyway, there are a few problems with overriding OnCommand and removing
the
>check. First of all, I would think that ASSERT for IsWindow would be
desired
>for all the other commands that come into my Dialog. I would only want to
>skip it if the command was from a Notification SoftKey press. Second,
there
>is no header file for CTestCmdUI. Lastly, the reference to
_afxThreadState
>in OnCommand gives me an unresolved external symbol for my project. I
>created my project using the defaults from VS2005 when creating an MFC
Smart
>Device Application and selecting WM5.0 (ARMV4I). Also I created it as a
>Dialog based. I must need to set a compiler/linker option in my project
>properties?
>
>It also seems that this Notification mechanism is half-baked. It allows
the
>user to set lParam (a user-defined parameter according to MSDN
documentation)
>in SHNOTIFICATIONDATA. However, the lParam you get if you use a winproc
>callback (like the notifyMFC sample from the SDK) has the value from
>SHNOTIFICATIONDATA.dwID not SHNOTIFICATIONDATA.lParam. And if you use
>MESSAGE_MAP, you don't even get an wParam or lParam. So it doesn't seem
that
>the notifier can use lParam to send data to the notifiee.
>
>Any more insights?
>
>
>""TerryFei"" wrote:
>
>> Hi,
>> Welcome to MSDN Newsgroup!
>>
>> Based on my knowledge, you can try the following workaround for this
issue:
>> Since the OnCommand is a virtual method declared in CWnd class, we can
>> override it in our class derived from CWnd and copy / paste the code
from
>> CWnd's, only remove ASSERT(nID == 0 ||::IsWindow(hWndCtrl)). Then try to
>> test your application whether or not it can work fine.
>>
>> I hope the above information is helpful for you. If there is anything I
can
>> do for you, please feel free to let me know. Thanks for your
understanding!
>>
>> Best Regards,
>>
>> Terry Fei [MSFT]
>> Microsoft Community Support
>> Get Secure! www.microsoft.com/security
>>
>> --------------------
>> >Thread-Topic: Assert with Notifications in WM5.0
>> >thread-index: AcZDjSTZLRQli8XWTRCDclDo7DFOzg==
>> >X-WBNR-Posting-Host: 192.216.148.182
>> >From: =?Utf-8?B?UmFuZ2Vy?= <ranger(a)nospam.nospam>
>> >Subject: Assert with Notifications in WM5.0
>> >Date: Thu, 9 Mar 2006 07:21:31 -0800
>> >Lines: 57
>> >Message-ID: <6D609A1C-F0E6-4387-9F66-682AEA8FF582(a)microsoft.com>
>> >MIME-Version: 1.0
>> >Content-Type: text/plain;
>> > charset="Utf-8"
>> >Content-Transfer-Encoding: 7bit
>> >X-Newsreader: Microsoft CDO for Windows 2000
>> >Content-Class: urn:content-classes:message
>> >Importance: normal
>> >Priority: normal
>> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
>> >Newsgroups: microsoft.public.vc.mfc
>> >Path: TK2MSFTNGXA03.phx.gbl
>> >Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.vc.mfc:468789
>> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>> >X-Tomcat-NG: microsoft.public.vc.mfc
>> >
>> >After talking to the concierge, I found out that there is no managed
>> >newsgroup specific to pocketpc or wm5.0 questions. So I am posting
this
>> >here.
>> >
>> >I am a C++ developer on WM5.0. Starting with the notifyMFC example
from
>> the
>> >WM5.0 SDK, I am creating a notification and calling SHNotificationAdd
from
>> a
>> >method in my dialog. I am filling out SHNOTIFICATIONDATA as follows...
>> >
>> > HICON hIcon =(HICON)LoadImage(AfxGetInstanceHandle(),
>> >MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
>> >
>> > SHNOTIFICATIONDATA* pCurrentNotification
>> =(SHNOTIFICATIONDATA*)malloc(
>> >sizeof(SHNOTIFICATIONDATA));
>> >
>> > CString html = CString(_T("Test"));
>> >
>> > pCurrentNotification->dwID = 10000;
>> > pCurrentNotification->clsid = guidNotifyApp;
>> > pCurrentNotification->npPriority = SHNP_INFORM;
>> > pCurrentNotification->csDuration = 20;
>> > pCurrentNotification->hwndSink = this->GetSafeHwnd();
>> > pCurrentNotification->pszHTML = html;
>> > pCurrentNotification->hicon = hIcon;
>> > pCurrentNotification->cbStruct = sizeof(SHNOTIFICATIONDATA);
>> > pCurrentNotification->pszTitle = TEXT("Test Notification...");
>> > pCurrentNotification->grfFlags = SHNF_FORCEMESSAGE;
>> > pCurrentNotification->rgskn[0].pszTitle = TEXT("SK1");
>> > pCurrentNotification->rgskn[0].skc.wpCmd = IDM_SK1;
>> > pCurrentNotification->rgskn[0].skc.grfFlags =
>> >NOTIF_SOFTKEY_FLAGS_DISMISS;
>> > pCurrentNotification->rgskn[1].pszTitle = TEXT("SK2");
>> > pCurrentNotification->rgskn[1].skc.wpCmd = IDM_SK2;
>> > pCurrentNotification->rgskn[1].skc.grfFlags =
>> >NOTIF_SOFTKEY_FLAGS_DISMISS;
>> >
>> > SHNotificationAdd(pCurrentNotification);
>> >
>> >I have the following lines in the MESSAGE_MAP for my dialog.
>> >
>> > ON_COMMAND(IDM_SK1, OnSK1)
>> > ON_COMMAND(IDM_SK2, OnSK2)
>> >
>> >When I select either softkey, I get an assert on line 2592 of
wincore.cpp.
>>
>> >This is in CWnd::OnCommand() and the assert is ASSERT(nID == 0 ||
>> >::IsWindow(hWndCtrl)). The IsWindow() method returns false. hWndCtrl
>> doesn't
>> >seem to be the window handle. In fact it is the value of dwID I set in
>> the
>> >SHNOTIFICATIONDATA struct.
>> >
>> >If I use the notifyMFC sample from wce500, I don't get an assert. It
>> >doesn't use MFC and MESSAGE_MAP. It uses a callback that switches on
>> message
>> >which hits the WM_COMMAND case with LOWORD(wParam) equal to IDM_SK1 or
>> >IDM_SK2.
>> >
>> >If I set dwID to zero, my OnSK1/OnSK2 methods execute but then my
>> >application cannot have more than one notification.
>> >
>> >Is there a way to get this to work with MFC and MESSAGE_MAP?
>> >
>>
>>
>