문제

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