修改windowproc窗口钩子中lParam的值
Changing the value of lParam in WndProc windows hook
我试图在我的c# WPF应用程序中更改矩形,其中窗口与shell挂钩最小化到HSHELL_GETMINRECT。
遵循这个Win32 C API重定向最小化动画我能够编组在lParam参数中返回的结构,但我不能改变它的值,以便windows获得新的矩形。
这是目前为止我的WndProc方法。
public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
// If windows sends the HSHELL_GETMINRECT event, a window in the taskbar is minimizing or maximizing.
if (wParam.ToInt32() == WindowInterop.HSHELL_GETMINRECT)
{
var param = Marshal.PtrToStructure<WindowInterop.MinRectParam>(lParam);
var icon = FindIcon(param.hWnd);
var rect = new WindowInterop.SRect
{
Bottom = (short)(icon.Y + icon.Height),
Left = (short)icon.X,
Right = (short)(icon.X + icon.Width),
Top = (short)icon.Y
};
var newParam = new WindowInterop.MinRectParam
{
hWnd = param.hWnd,
Rect = rect
};
// As I understand it, this will only create a new IntPtr pointing to the structure,
// it won't write the new structure to the existing pointer's location.
Marshal.StructureToPtr(newParam, lParam, true);
handled = true;
}
return IntPtr.Zero;
}
我需要为Windows添加return new IntPtr(1);
以使用新的结构。
相关文章:
- 数组索引的值没有增加
- 'short int'持有的值溢出,但"自动"不会溢出?
- 是默认情况下分配给char数组常量的值
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值
- 为什么我无法更改"set<set>"循环中的值<int>
- 有效地使用std::unordered_map来插入或增加键的值
- <streamsize>C++ 中 numeric_limits::max() 的值
- 为什么不能修改对象中的值?另外,我如何改进此链表?
- 无法获取webot::PositionSensor对象中位置传感器的值
- 正在将无序映射设置为无序映射的值
- 着色器纹理值与创建纹理时写入的值不同
- 无法按cpp中的值返回矢量
- 指针没有更新它在void函数内部指向的值
- 不能将 "void *" 类型的值分配给类型 "TCHAR" 的实体
- 获取从C++中同一类中的构造函数调用的方法返回的值
- 为什么在我的函数类型后使用引用运算符 (&) 允许我修改它返回的值?
- 如何在c++中获取要更新的值
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- 修改windowproc窗口钩子中lParam的值
- 检查WM_KEYDOWN上的LPARAM -不正确的值