c++ Winapi HWND获取windproc配置
C++ Winapi HWND Get WndProc configuration
我需要获得当前的WndProc
及其消息和配置,并将我自己的代码添加到其中。我为什么需要这个?因为我在一个IDE下工作,它定义了一个带有WndProc
的窗口(及其子控件),我需要修改它,因为它包含与每个控件相关的所有操作。如果我将控件指向自定义WndProc
,该控件将失去IDE设置的所有操作和配置。建议吗?
方案:
HWND button; //My Button
LONG_PTR wndProc = GetWindowLongPtr(button, GWL_WNDPROC); //Getting the WndProc
wndProc -> Get this `WndProc` source code
LRESULT CALLBACK WndProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
wndProc (all the data);
+ my messages
}
你当然不能获得"旧的" windowproc的源代码,但是你可以在你的新windowproc中使用CallWindowProc()调用它。
当你子类化一个窗口时,它是窗口的原始窗口过程当你想调用原始窗口过程时你必须调用的子类
:
…你的子类函数应该像这样:
wndProcOrig = (WNDPROC)SetWindowLongPtr(hwndButton, GWLP_WNDPROC, (LONG_PTR)SubclassWndProc); LRESULT CALLBACK SubclassWndProc(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam) { switch (wm) { ... default: return CallWindowProc(wndprocOrig, hwnd, wm, wParam, lParam); } }
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 无法找到/读取配置文件.conf-FileIOException
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 一种在C++中读取TXT配置文件的简单方法
- 生成MRPT库时cmake配置失败
- FFMPEG配置文件级别id大小无效
- 如何通过Conan和CMake找到用于pkg配置的.pc文件
- 配置文件解析器仅返回以前的值
- 我的程序有一个保存配置文件的GUI,如何双击此配置文件以直接加载带有配置数据的GUI?
- 更改命令行 qt5 源代码构建配置的正确/快速方法
- 是否可以配置提升日志刷新?
- 如何配置Visual Studio Code以使用cygwin,cmake和gcc进行调试
- C/C++:打印(配置)头文件的内容
- 配置:错误:找不到 MySQL 包含目录
- 安装 psutil 和为 pypy 配置期间出错
- 叮当格式化程序多行格式配置错误
- 使用 Eclipse CDT 进行 Cplex 配置
- 为c++配置Visual studio代码
- 如何定义自定义生成配置类型,其中通常是.exe的目标改为 DLL
- c++ Winapi HWND获取windproc配置