Destroy-ing window on Win32

drjackool 956 Reputation points
2023-07-21T08:54:55.05+00:00

Hi

Platform: Win32/VC++/ATL

I create a tooltip for the status bar on my app, my question is should I destroy the tooltip window when the main frame destroyed or system will do it?

Also I set icons for the status bar, should destroy icons or system will do it?

thanks

/*...*/
::SendMessage(m_hwndStatusBar, SB_SETICON, 1, (LPARAM)LoadImage(Module::GetResourceInstance(), MAKEINTRESOURCE(IDI_SOMEICON), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
/*...*/
HWND hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hWnd, NULL, Module::GetModuleInstance(), NULL);
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,752 questions
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2023-07-24T02:29:12.9633333+00:00

    As comments said, when the process is about to exit,

    All this memory management is pointless. The process is exiting. All that memory will be freed when the address space is destroyed. Stop wasting time and just exit already.

    This is also mentioned in Terminating a Thread:

    • Any resources owned by the thread, such as windows and hooks, are freed.

    By the way, if you just change the icon, you need to free the previous one.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.