多文档的程序,新建文档,然后再关闭文档则会有6个GDI的泄漏,持续该动作会导致GDI涨到上限9999。
发现其中5个GDI是在下面的代码中发生的:
void CFrameWnd::ActivateFrame(int nCmdShow)
// nCmdShow is the normal show mode this frame should be in
{
// translate default nCmdShow (-1)
if (nCmdShow == -1)
{
if (!IsWindowVisible())
nCmdShow = SW_SHOWNORMAL;
else if (IsIconic())
nCmdShow = SW_RESTORE;
}
// bring to top before showing
BringToTop(nCmdShow);
if (nCmdShow != -1)
{
// show the window as specified
ShowWindow(nCmdShow);
// and finally, bring to top after showing
BringToTop(nCmdShow);
}
}
第一次调用BringToTop(nCmdShow);时会增加5个;若跳过该句则会在ShowWindow(nCmdShow);时增加5个;
请教此中缘由,并请教这几个GDI什么时候释放,怎么释放?本人调用childFrame::OnClose了,但却未释放。谢谢。
发现其中5个GDI是在下面的代码中发生的:
void CFrameWnd::ActivateFrame(int nCmdShow)
// nCmdShow is the normal show mode this frame should be in
{
// translate default nCmdShow (-1)
if (nCmdShow == -1)
{
if (!IsWindowVisible())
nCmdShow = SW_SHOWNORMAL;
else if (IsIconic())
nCmdShow = SW_RESTORE;
}
// bring to top before showing
BringToTop(nCmdShow);
if (nCmdShow != -1)
{
// show the window as specified
ShowWindow(nCmdShow);
// and finally, bring to top after showing
BringToTop(nCmdShow);
}
}
第一次调用BringToTop(nCmdShow);时会增加5个;若跳过该句则会在ShowWindow(nCmdShow);时增加5个;
请教此中缘由,并请教这几个GDI什么时候释放,怎么释放?本人调用childFrame::OnClose了,但却未释放。谢谢。
问题应该出在OnPaint()函数里面。