Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Items added in the manner shown above display the strLabel text as the message, followed by a link that says "Go There". If you click the link, the WMC navigates to the location specified in strDescriptionstrDestination. You can provide customised hyperlink text by providing your own XAML contenta custom formatted message and link by specifying the NI_FLAG_MESSAGEBAR_CUSTOMMESSAGE  flag . See Custom link text.

 

The flags field of the NAVSETITEM structure dictates how the message bar item will be handled.

FlagDescription
NI_FLAG_MESSAGEBAR_ICONWARNING
NI_FLAG_MESSAGEBAR_ICONINFO
NI_FLAG_MESSAGEBAR_ICONSHIELD
The type of icon to show. Mutually exclusive.
NI_FLAG_MESSAGEBAR_NOTIFYNotify the item of the click. Calls the NavItemNotify handler of the notification interface supplied in NavInsertItem. Without this flag the default behaviour is to go to a navigation location.
NI_FLAG_MESSAGEBAR_USERXAMLCUSTOMMESSAGE Specify to supply custom XAML for the itemmessage text with an embedded link with customised text. See below for details.

Custom link text 
Anchor
CustomLinkText
CustomLinkText

...

Code Block
void AddMessageBarItem(LPCWSTR text, LPCWSTR link)
{
	// First get the root of the MESSAGEBAR domain
	NAVSETITEM messageBarRootData;
	memset(&messageBarRootData, 0, sizeof(NAVSETITEM));
	if( !NavGetItem(_T("MESSAGEBAR"), &messageBarRootData) )
	{
		return;														// Failed to find MESSAGEBAR root
	}
	NavHandle messageBarRoot = messageBarRootData.hItem;
 
	NAVSETITEM newItem;
	memset(&newItem, 0, sizeof(newItem));
	newItem.flags = NI_FLAG_MESSAGEBAR_CUSTOM_MESSAGECUSTOMMESSAGE;
	newItem.EventMask = NI_EVENT_MOUSE_LCLICK;

	newItem.strLabel = L"This is the text <a>with an embedded link</a> to navigate to";
	newItem.strDestination = _T("{Notifications}");	   // where to go to
	newItem.lParam = (LPARAM)this;
	newItem.pInterface = &gTaskInterface;
	NavInsertItem(hMessageBar, _T("NotificationWarning"), &newItem);
	NavHandle messageBarItem = newItem.hItem;
}

...