Creating a child window from DLL
'Just Ask' Dan Maher -- dmaher@apdi.net Tuesday, September 10, 1996 Environment: Win 95, VC++ 4.2 have an application that calls an exported function in a DLL, exported as "CREATEME". This function is intended to create a child window within a specified RECT. Here's an abbreviated version of the code involved: // DLL exported function BOOL CREATEME( RECT rcRect, HWND hParent) { CRect rect = rcRect; return theApp.m_pMainWnd->CreateEx( 0, m_strWndClass, "", WS_CHILD | WS_VISIBLE, rect.top, rect.left, rect.Width(), rect.Height(), parent, 0)); // m_pMainWnd is constructed in InitInstance() } // In my constructor for my CWnd - derived class: CMyWnd::CMyWnd() { m_strWndClass = AfxRegisterWndClass( CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW); } Now the function gets called correctly, in fact, it works great under NT 4.0. However, under Win95, MFC spits out some trace output saying that the window was not created and GetLastError() returned 0x00000000. Of course, my window is not created, either. What I'm trying to do is have a DLL create its own windows within a parent owned by the main EXE. Kind of like OLE in-place editing but without the huge overhead required by OLE. Any ideas? dM
Benny -- blee@filenet.com Wednesday, September 11, 1996 Did you put in AFX_MANAGE_STATE(AfxGetModuleState()) in the beginning of "CREATEME"? Ex. void CREATEME() { AFX_MANAGE_STATE(AfxGetModuleState()); // other stuff.. } Benny ---------- From: owner-mfc-l To: mfc-l Subject: Creating a child window from DLL Date: Tuesday, September 10, 1996 12:05PM Environment: Win 95, VC++ 4.2 have an application that calls an exported function in a DLL, exported as "CREATEME". This function is intended to create a child window within a specified RECT. Here's an abbreviated version of the code involved: // DLL exported function BOOL CREATEME( RECT rcRect, HWND hParent) { CRect rect = rcRect; return theApp.m_pMainWnd->CreateEx( 0, m_strWndClass, "", WS_CHILD | WS_VISIBLE, rect.top, rect.left, rect.Width(), rect.Height(), parent, 0)); // m_pMainWnd is constructed in InitInstance() } // In my constructor for my CWnd - derived class: CMyWnd::CMyWnd() { m_strWndClass = AfxRegisterWndClass( CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW); } Now the function gets called correctly, in fact, it works great under NT 4.0. However, under Win95, MFC spits out some trace output saying that the window was not created and GetLastError() returned 0x00000000. Of course, my window is not created, either. What I'm trying to do is have a DLL create its own windows within a parent owned by the main EXE. Kind of like OLE in-place editing but without the huge overhead required by OLE. Any ideas? dM
David Little -- dlittle@communique.net Thursday, September 12, 1996 Be sure and put an AFX_MANAGE_STATE() macro in EVERY class constructor that will use a DLL-defined resource. ---------- From: Lee, Benny[SMTP:blee@filenet.com] Sent: Wednesday, September 11, 1996 9:18 AM To: mfc-l Subject: RE: Creating a child window from DLL Did you put in AFX_MANAGE_STATE(AfxGetModuleState()) in the beginning of "CREATEME"? Ex. void CREATEME() { AFX_MANAGE_STATE(AfxGetModuleState()); // other stuff.. } Benny
| Вернуться в корень Архива |