...
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 strDestination. You can provide a 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.
...
Custom link text
Anchor | ||||
---|---|---|---|---|
|
The default link text is Go There but it can be customised by providing your own message string with your link text surrounded by the <a></a> tags when inserting the element. To use a custom message you need to set the By default a message bar item contains user-supplied text followed by a hyperlink with the text Go There. You can supply a custom message that allows you to set the hyperlink text as well as place it anywhere within the message. To do so set the flag NI_FLAG_MESSAGEBAR_CUSTOMMESSAGE in flags field of the NAVSETITEM structure . and provide a message in strLabel, enclosing the hyperlink portion in <a></a> tags. e.g.
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_CUSTOMMESSAGE; 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 = &gTaskInterfacenotificationInterface; NavInsertItem(hMessageBar, _T("NotificationWarning"), &newItem); NavHandle messageBarItem = newItem.hItem; } |
...