سؤال

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