I have a main window with a treeview control. I need to track certain changes of a checked item, so I have decided to make a static HTREEITEM variable to store that handle.

I do not know if setting variable to NULL in my WM_DESTROY handler will suffice, or do I need to do something else?

Here are the code snippets that illustrate my dilemma:

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static HTREEITEM LastCheckedItem;

    // Other parts of the code that work well

    case WM_DESTROY:
        {
            LastCheckedItem = NULL;  // or should I do something else ?

            // ...

Thank you.

Best regards.

有帮助吗?

解决方案

The tree view should handle cleanup of the individual items when it receives the WM_DESTROY message, and you probably don't need to set LastCheckedItem to NULL unless you need to check its value later on.

其他提示

You don't need to do any tidy up. When you destroy the tree view it will destroy all of its items.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top