• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

在C#,我有的IntPtr到Win32的WndProc。什么是语法调用它

用户头像
it1352
帮助1

问题说明

我在子类本机窗口(组合框的编辑控件...)

I'm subclassing a native window (the edit control of a combobox...)

oldWndProc = SetWindowLong函数(HandleOfCbEditControl,GWL_WNDPROC,newWndProc);

oldWndProc = SetWindowLong(HandleOfCbEditControl, GWL_WNDPROC, newWndProc);

在我的子类的WndProc,我将有code这样的,正确的,但我不能找出语法调用oldWndProc。

In my subclassing wndproc, I'll have code like this, right, but I can't figure out the syntax for calling the oldWndProc.

    int MyWndProc(int Msg, int wParam, int lParam)
    {
         if (Msg.m ==  something I'm interested in...)
         {
              return something special
         }
         else
         {
              return result of call to oldWndProc  <<<<   What does this look like?***
         }

    }

编辑:在这个问题的话子类化指的是Win32 API的意义,而不是C#。子类在这里并不意味着压倒一切的。NET基类的行为。这意味着告诉WIN32调用Windows当前回调的函数指针来代替。它无关的传承在C#。

The word "subclassing" in this question refers to the WIN32 API meaning, not C#. Subclassing here doesn't mean overriding the .NET base class behavior. It means telling WIN32 to call your function pointer instead of the windows current callback. It has nothing to do with inheritence in C#.

正确答案

#1

您会打电话的 CallWindowProc的通过P /调用。只要定义参数INT变量(因为它看起来像你如何在调用SetWindowLong调用中定义他们的),所以是这样的:

You'll call CallWindowProc by P/Invoke. Just define the parameters as int variables (as it looks like that's how you defined them in the SetWindowLong call), so something like this:

[的DllImport(CallWindowProc的...] 公共静态外部INT CallWindowProc的(INT previousProc,INT nativeControlHandle,诠释味精,诠释lParam的,诠释的wParam);

[DllImport("CallWindowProc"...] public static extern int CallWindowProc(int previousProc, int nativeControlHandle, int msg, int lParam, int wParam);

记住,对于编组,INT,UINT和IntPtr的都是相同的。

Remember, that for marshaling, int, uint and IntPtr are all identical.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcgkjij
系列文章
更多 icon
同类精品
更多 icon
继续加载