Click to See Complete Forum and Search --> : How to get MainFrame window into activeX via another activeX


maheshbeniwal
July 2nd, 1999, 07:55 AM
Dear All,
I have developed two activeX controls, say AX and BX. BX has one method called SetFileName which views file on mainframe window if we pass mainframe window as a parent window during Create method call of BX. It wroks fine. For both ocx i am using wrapper class and create method to create controls. Now my problem is i want to use BX->SetFileName method via AX. I am creating my AX in Application usin create method and passing mainframe window. Then there is method of AX called GetRx(long lWnd). I am passing mainframe window's handle and converting to other end. I did DEBUG .. i am getting same window on both the ends but it does not display any thing.

any ideas ?
here is my code


-----------------------------------------------------
This is applications's view class
-------------------------------------------------------------------
void CKControllerView::OnMcb()
{
CRect rInsoWnd;
GetClientRect(&rInsoWnd);
long longParam = (long)AfxGetApp()->m_pMainWnd->m_hWnd ;
AllocMemFormcb(CMcbViewer);

/* mcb is instance of wrapper class of AX */
mcb->Create("mcbViewer",WS_CHILD|WS_VISIBLE, rInsoWnd, (CWnd*)this, 1113,
NULL, FALSE);

/* Method of AX , given below */
mcb->GetRx(longParam);

}


----------------------------------------------------------------
AX activeX control which calls SetFileName of BX which views the file
----------------------------------------------------------------------------
-----------------------
long CMcbViewerCtrl::GetRx(long lhWnd)
{
CRect rInsoWnd;
GetClientRect(&rInsoWnd);

CWnd* wnd = CWnd::FromHandle(HWND(lhWnd));

AllocMemForViewer(CRxhighx);

/* Creating BX */
m_pViewerWnd->Create("Rxhighx", WS_CHILD|WS_VISIBLE, rInsoWnd, wnd, 2222,
NULL, FALSE);

/* this method works fine becuase later i am calling GetAction and returning
correct value */
m_pViewerWnd->SetAction(1);

/* This method works fine too b/c i am getting correct value in str but it
does not display */

m_pViewerWnd->SetFileName("C:\\winnt\\winnt.bmp");

return 0;
}


----------------------------------------------------------------------------
-----------------






> Dear COMXperts
>
> here is my problem. I created two activeX called AX and BX. And my
> application is APP. The job of BX is to display any file and exposes
> a
> method called Display. Both BX and AX are ocx controls.
>
> From my application I am calling one method of AX called
> Create&DisplayBX ,
> which creates BX and calls Display method of BX.
>
> I am using Create method of ocx to create my control on runtime (
> both AX
> and BX). That means i don't have any dialog or window in AX and BX
> to put
> control at design time. Since when we call Create method of any ocx
> we have
> to pass parent window. So my problem is how to pass my APP's view
> window to
> BX's parent window in AX's Create&Display method.
>
>
> I am passing AfxGetApp()->m_pMainWnd as long to Create&Display(long)
> method
> and casting long to CWnd* again in Create&Display Method of AX and
> passing
> that as a parentWnd. Will this work ? ? If yes then what's wrong ??
>
> Any other way to solve this problem ??? I would appreciate your
> guidance
>
> regards
> mahesh

muscicapa
July 2nd, 1999, 08:01 AM
are AX and BX in the same container ?

maheshbeniwal
July 2nd, 1999, 08:05 AM
Ax is a container of BX .. but BX does not have any window or dialog ..

My application is container of AX .. which ca. In Ax i call BX->Create method and pass mainframe window of application as a parent window of BX.

maheshbeniwal
July 2nd, 1999, 08:06 AM
I treid to create a dummy window in AX and passed that dummy window as parent of BX. It worked fine .. but my porblem is i want to display on mainframe. Can i do that ??

thanks and regards

maheshbeniwal
July 2nd, 1999, 01:38 PM
I found the solutions .. !