ActiveX控件,Com和重叠的子窗口 [英] ActiveX Control , Com and overlaped child windows

查看:70
本文介绍了ActiveX控件,Com和重叠的子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次问好,
我对ActiveX控件有问题.我有一个com(用c#编写),它是一个带有几个子窗口的框架.我制作了一个c ++应用,该应用通过ActiveX控件在对话框中调用COM对象.

Hello again,
I have a problem with ActiveX control. I have a com (written in c#) which is a frame with few child windows. I made a c++ app which calls the COM object in a Dialog via ActiveX control

BOOL (WINAPI *m_AtlAxWinInit)();
	m_AtlAxWinInit = (BOOL (WINAPI *)(void))::GetProcAddress(hWebLib, "AtlAxWinInit");
    m_AtlAxWinInit();

	// Get the bounds for the activeX control 
	CRect rect;
	m_ActiveXarea.GetWindowRect(&rect);
	
	hAtl = ::CreateWindowEx(
			WS_EX_DLGMODALFRAME/*| WS_CLIPSIBLINGS*/, \
			TEXT("AtlAxWin"),\
			strActiveXName,\
			WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_EX_RTLREADING,\
			rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,\
			hSelf,\
			NULL,\
			NULL,\
			NULL);
	
	if (!hAtl)
	{
		::MessageBox( NULL, TEXT("Can not load AtlAxWin!"), TEXT("Caption"), MB_OK | MB_ICONSTOP);
		throw int(106901);
	}

	HRESULT (WINAPI *m_AtlAxGetControl) (HWND h, IUnknown** pp);
	m_AtlAxGetControl = (HRESULT (WINAPI *) (HWND, IUnknown**))::GetProcAddress(hWebLib, "AtlAxGetControl");

	m_AtlAxGetControl(hAtl, &pUnk);
	HRESULT res = pUnk->QueryInterface(IID_Control,(LPVOID *) &pFunLineViewer);



此代码摘自本文如何在C ++中集成C#窗口项目

我面临的问题是,当我从COM对象中断开一个子窗口并单击对话框(或浮动窗口外部的框架本身)时,该对话框与浮动子窗口重叠了.

我在对话框和包含COM对象的新HWND hAtl中尝试了WS_CLIPCHILDREN,WS_CLIPSIBLINGS,SetWindowPos,但似乎没有任何作用
如果您还有其他想法或建议,该怎么办,请告诉我:)

还有一个问题:是否可以向COM对象发送消息,例如,最小化,以便在按下对话框上的最小化"按钮时可以最小化浮动窗口?

更新:使用Spy ++(VS实用程序)后,我发现通常在将一个窗口记录下来时,它是某个窗口的子窗口,而该窗口本身就是对话框的子窗口.问题是,当某个窗口浮动时,它不再是Dialog(grandchild)的子级.



This code is taken from this article How to Integrate C# Window in C++ Project

The problem i am facing is that when i undock one of the child windows from the COM Object and click on the Dialog (or the frame itself outside of the floating window ),the Dialog overlaps the floating child window

I tried with WS_CLIPCHILDREN, WS_CLIPSIBLINGS, SetWindowPos on the dialog and on the new HWND hAtl which contains the COM Object but nothing seems to work
If you have some more ideas or suggestions what to do please tell me:)

One more question: is it possible to send a message to the COM object for example minimize so it can minimize the floating windows when minimize button on the dialog is pressed?

Update: After using Spy++ (VS utility) i found that normally when one window is docket its child of some window which is child of the dialog itself. The problem is when some window is floating it is no longer a child of the Dialog(grandchild)

推荐答案

尝试传递null而不是hSelf(我认为是对话框的HWND)到CreateWindowEx函数.在这种情况下,COM对象中的帧将独立存在而没有父对象.然后,您将可以为hAtl设置SetWidowPos.
Try to pass null instead of hSelf (which I assume is the HWND of the dialog) to the CreateWindowEx function. In this case the Frame from the COM object will live on its own without the parent. You will then be able to SetWidowPos for the hAtl.


这篇关于ActiveX控件,Com和重叠的子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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