Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ ATL 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);
 
 
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 meSmile | :)
 
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)
Posted 8-Oct-12 4:07am
Argonia11.1K
Edited 11-Oct-12 23:43pm
v4

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Argonia at 10-Oct-12 8:40am
   
the floating child window still gets overlapped by the window container in this case hAtl and yes hSelf is the HWND of the dialog
Andrew Cherednik at 10-Oct-12 14:51pm
   
yes, but in this case you will be able to SetWindowPos(hAtl, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE).
Also, when creating the hAtl, try to replace WS_CHILD to WS_POPUP
Argonia at 11-Oct-12 1:58am
   
The floating windows (of the Com object) still get overlapped by the parent(hAtl) and the dialog. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100