Page tree

Versions Compared

Key

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

...

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;
 
	// Now add a simple message bar item
	NAVSETITEM newItem;
	memset(&newItem, 0, sizeof(newItem));
	newItem.flags = NI_FLAG_MESSAGEBAR_ICONWARNING;						// The icon we want to show. NI_FLAG_MESSAGEBAR_ICONINFO, NI_FLAG_MESSAGEBAR_ICONWARNING and NI_FLAG_MESSAGEBAR_ICONSHIELD
	newItem.EventMask = NI_EVENT_MOUSE_LCLICK;							// Need click events to navigate somewhere when the link is clicked
	newItem.strLabel = L"This is a message bar message";
	newItem.strDescriptionstrDestination = L"NAVIGATIONTREE\\ControlPanel\\Events";	// Override description field as the FQN or alias to navigate to when the link is clicked
	newItem.lParam = 0;													// Custom context data
	newItem.pInterface = &notificationInterface;						// Interface to handle messages from the message bar
	NavInsertItem(messageBarRoot, _T("MyComponentWarningEvents"), &newItem);
}

...

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_MESSAGE;
	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;
}

Hyperlink tag is always the item to look up to check how the event is processed (NOTIFY or GOTO).

If item wants to be notified (MESSAGEBAR_NOTIFY) then Hyperlink tag is the string to call NavNotifyItem on e.g. "MESSAGEBAR\NotificationWarning". So basically the target and notify items are the same.  

If item doesn't want notification then target item's description is used in a call to NavGotoItem.
If the item is inserted with USERXAML, then the tag is specified by the user in the XAML. If it's not custom XAML,then the Hyperlink tag is made from the FQN of the item (Made of the parent and 2nd argument to NavInsertItem)