在C#中,我有一个的IntPtr到Win32的WndProc。什么是语法调用它? [英] In C#, I have a IntPtr to a WIN32 WndProc. What is the syntax for calling it?

查看:419
本文介绍了在C#中,我有一个的IntPtr到Win32的WndProc。什么是语法调用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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#.

推荐答案

您会打电话的 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.

这篇关于在C#中,我有一个的IntPtr到Win32的WndProc。什么是语法调用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆