- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个使用 CAtlExeModuleT 的非常简单的 Win32 应用程序。该模块只是创建一个从 CWindowImpl 派生的类 CTestWindow。它只有一个用于 WM_PAINT 的消息处理程序。在我创建窗口并显示它之后,无限调用 OnPaint 方法(WM_PAINT 消息)并消耗 100% 的 CPU。
创建窗口的代码非常简单:
m_pMainWnd = new CTestWindow();
if(NULL == m_pMainWnd->Create(NULL, CWindow::rcDefault, _T("Test Window"), WS_OVERLAPPEDWINDOW, 0, hMenu)){
DWORD dwErr = GetLastError();
return E_FAIL;
}
m_pMainWnd->ShowWindow(nShowCmd);
OnPaint 消息处理程序也非常简单(它什么都不做):
LRESULT CTestWindow::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
// TODO: Add your message handler code here and/or call default
return 0;
}
最佳答案
我猜你不是validating the window in your paint handler .
An application must call BeginPaint and EndPaint in response to WM_PAINT messages, or pass the message to the DefWindowProc function to validate the window. DefWindowProc validates the update region; it can send the WM_ERASEBKGND message if the window background needs to be erased.
这意味着操作系统会认为窗口仍然需要绘制,并再次调用您。
关于windows - 使用 ATL CWindowImpl 永不结束 WM_PAINT 循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1117511/
我正在尝试使用以下类构建一个新窗口。但是我在尝试使用 CWindow::m_hwnd 变量获取新生成的窗口名称时遇到了一些严重的问题。我的猜测是我应该将一个变量传递给保存我 parent 的 HWND
我刚刚尝试设置一个小型 win32 项目,并且正要创建一个窗口。 我在资源设计器中创建了一个对话框并为我的窗口设置了这个类: #pragma once #include "stdafx.h" clas
我正在查看 MFC SDI Cview 全屏示例应用程序: https://www.codeproject.com/Articles/9632/Views-in-Full-Screen-Mode 我用
我有一个使用 CAtlExeModuleT 的非常简单的 Win32 应用程序。该模块只是创建一个从 CWindowImpl 派生的类 CTestWindow。它只有一个用于 WM_PAINT 的消息
我是一名优秀的程序员,十分优秀!