 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Accumulator Guest
|
Posted: Thu Jan 12, 2006 4:31 am Post subject: VCL in DLL from Non-VCL app |
|
|
I have a program (written in MSVC MFC) that needs to embed dynamic VCL
forms. The VCL forms will be contained in various DLL files which can
be loaded and displayed as needed. The parent app has a FRAME which I
use as a Parent for the VCL form. This works and displays fine, it even
resizes fine, but as soon as I do anything on the form that would
generate an EVENT, such as click a button or enter an edit box, the
entire app freezes. I've read some places that this should work fine
and in other places that it is probably not possible. Is it possible
to do this or not and if so, what am I missing?
Here is the code I'm using.
Any help would be greatly appreciated.
MSVC:
void CMainDlg::OnShow()
{
m_hlib = LoadLibrary ("myDll.dll");
*(FARPROC*)&ShowForm = GetProcAddress (m_hlib, "_ShowForm");
*(FARPROC*)&CloseForm = GetProcAddress (m_hlib, "_CloseForm");
*(FARPROC*)&ResizeForm = GetProcAddress (m_hlib, "_ResizeForm");
// error handling omitted
m_handle = ShowForm (m_frame.m_hWnd);
CRect rect;
m_frame.GetClientRect (rect);
ResizeForm(rect.Height(),rect.Width());
}
----------
BCB-H:
#ifdef __DLL__
# define DLL_EXP __declspec(dllexport)
#else
# define DLL_EXP __declspec(dllimport)
#endif
extern "C" int DLL_EXP ShowForm(HWND parent);
extern "C" void DLL_EXP CloseForm(int handle);
extern "C" void DLL_EXP ResizeForm(int height,int width);
----------
BCB-CPP:
int ShowForm(HWND Parent)
{
MainForm = new TMainForm(Parent);
TMainForm *parentForm=(TMainForm*)&Parent;
MainForm->Top =parentForm->Top+4;
MainForm->Left =parentForm->Left+4;
MainForm->Height=parentForm->Height-29;
MainForm->Width =parentForm->Width-8;
MainForm->Show();
Application->Handle=Parent; // someone said this is required
MainForm->Resizer(MainForm->Height,MainForm->Width);
return (int)MainForm;
}
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|