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;
 
	NAVSETITEM newItem;
	memset(&newItem, 0, sizeof(newItem));
	newItem.flags = NI_FLAG_MESSAGEBAR_USERXAML;
	newItem.EventMask = NI_EVENT_MOUSE_LCLICK;

	std::wstring strLabel;
	FormatString(strLabel, L"<Image Source='2400'/><TextBlock Padding='3, 0, 20, 0' VerticalAlignment='Center'>This is the message: <Hyperlink Tag='MESSAGEBAR\\MyComponent'>%s</Hyperlink></TextBlock>", CResString(IDS_LABEL_THEREISANOTIFICATION).GetBuffer(0), CResString(IDS_LABEL_GOTONOTIFICATIONS).GetBuffer(0));

	ItemNew.strLabel = strLabel.c_str();
	ItemNew.strDescription = _T("{Notifications}");	   // where to go to
	ItemNew.lParam = (LPARAM)this;
	ItemNew.pInterface = &gTaskInterface;
	NavInsertItem(hMessageBar, _T("NotificationWarning"), &ItemNew);
	hWarning = ItemNew.hItem;
}

Hyperlink tag is always the item to find to process the event on (Notify or go to depending on THAT item's flags). This could be the item itself or someone else. If the item is inserted with USERXAML, then the tag is specified by the user. If it's not custom XAML,then the Hyperlink tag is made from the FQN of the item (The 2nd argument to NavInsertItem);

For the target item

If MESSAGEBAR_NOTIFY flag, then Hyperlink tag is the object to notify e.g. "MESSAGEBAR\NotificationWarning". So basically the target and notify items are the same. This is an item that's been inserted with NavINsertItem. 

If not MESSAGEBAR NOTIFY then target item's description is the nav location to go to