当前位置:编程学习 > C#/ASP.NET >>

C#调用C++的函数,返回C++的窗体handle,嵌入C#控件中,但Tab键无效

IntPtr CBHandle = CallCFunc();  //返回C++窗体的Handle
// Put it into this form 
SetParent(CBHandle, this.Handle); //嵌入当前C#窗体
// Remove border and whatnot  
SetWindowLong(CBHandle, GWL_STYLE, WS_VISIBLE);
// Move the window to overlay it on this window  
MoveWindow(CBHandle, 0, 0, this.Width, this.Height, true);

一切都是正常的,就是Tab键不起作用
SetWindowLong(CBHandle, GWL_STYLE, WS_VISIBLE | WS_TABSTOP); 也不行
--------------------编程问答-------------------- 自己顶起,就这样简单的也不行,C#那边不做任何处理,仅Pinvoke调用C++的
dwRunProg()函数开启个窗体:

extern "C" __declspec(dllexport)void HWND dwRunProg()
{
    TForm1 *Form1 = new TForm1(Application);
    Form1->Show();
}

正常CB调用就没问题 --------------------编程问答-------------------- 好长时间不来csdn,是不是csdn没落了?以前问个问题,就算没人会,也有帮顶的
现在发个贴,冷冷清清 --------------------编程问答--------------------
.net的窗体事件不会发送不到c++窗体事件上的。可以试试,在.net窗体上按tab键的时将窗口焦点设置到c++窗体上试试。我是瞎猜的。仅供参考··· --------------------编程问答-------------------- 你要在帮我顶下帖子吧。我的问题快沉没了
http://bbs.csdn.net/topics/390276370 --------------------编程问答-------------------- 强力顶起!!! --------------------编程问答-------------------- 试试 WS_CHILD | WS_VISIBLE | WS_TABSTOP --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 关心下,希望了解 --------------------编程问答-------------------- Application.AddMessageFilter(new ...)
类实现IMessageFilter接口,在该类中可以处理消息,但是Tab键的顺序正好倒过来了,好奇怪,
有谁清楚 C++Build的消息处理机制的?

    public class t : IMessageFilter
    {
        IntPtr hwd;
        public t(IntPtr hwd)
        {
            this.hwd = hwd;
        }
        [DllImport("user32.dll")]
        public static extern bool IsDialogMessage(IntPtr hWnd, ref Message msg);
        public bool PreFilterMessage(ref Message m)
        {
            if (IsDialogMessage(hwd, ref m))
                return true;
            return false;
        }
    }
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,