...
Info |
---|
The NavItemHelpers code in sdk\helpers has more convenient ways to manage tasks |
When to add tasks
Tasks stay visible until they are removed with NavDeleteItem therefore you typically want to add them when your panel becomes active and delete them when the panel is deactivated. See Tree items and panels for information of handling (de)activation events.
Removing tasks
To remove a task simply call NavDeleteItem with the FQN or alias of the task you wish to delete.
Changing tasks
If you wish to change a task item's properties (label, description etc) you can do so with NavSetItem or NavSetItemEx
Code Block |
---|
NAVSETITEM newItemProperties;
newItemProperties.mask = NI_MASK_LABEL | NI_MASK_DESCRIPTION;
newItemProperties.strLabel = L"New Label";
newItemProperties.strDescription = L"New Description";
NavSetItem(aliasOrFQNForTaskToChange, &newItemProperties); |
Responding to task activation
...
Code Block |
---|
LPCWSTR settingsTaskFQN = L"TASKLIST\\MyComponentAdBlockerTaskGroup\\SettingsSettingsTask"; LPCWSTR deleteTaskAlias = L"{MyComponentDeleteTask}"; static const unsigned int addItemTaskId = 1; // The registered handled for the notify messages for your navigation items. This example assumes that only task items use this function UINT NavItemNotify(NAVITEMNOTIFY* notifyMessage) { if ( notifyMessage->nMsg != NI_EVENT_MOUSE_LCLICK) // Not a click event so we are out of here { return 0; } if ( (UINT)notifyMessage->pContext == addItemTaskId ) // addItemTaskId was set as the lParam field when registering that task { DoAddItem(); return 0; } if ( _wcsicmp(notifyMessage->strAlias, deleteTaskAlias) ) // We set strAlias when we registered the task { DoDelete(); return 0; } if ( _wcsicmp(notifyMessage->strFQN, settingsTaskFQN) ) // Compare the raw FQN { DoSettings(); return 0; } return 0; } |
...