Home > Software engineering >  [for post] Win32 DLL project using MFC support problem: on the external program control to create a
[for post] Win32 DLL project using MFC support problem: on the external program control to create a

Time:11-10

Environment: VS2015
Program (DLL) : Win32 DLL project using MFC support, with a dialog box interface,
Program (MFC dialog box) : have a CStatic control, is planning to create DLL interface on the control,
Exception: failed to Create, Create DLL interface in the Create direct collapse:

Other conditions: dialog DLG. DoModel modal form () to create success!
In the form of the modal dialog box to create success, but the interface is pop up, not the desired effect,

friends advice with MFC Shared DLL written in form, but I believe that Microsoft's this big company, the usage scenarios should be considered, so Posting to see any great god know the solution???????

Win32 DLL project Settings as follows,

export function code is as follows:
 
//h export
//the following ifdef block is created to make from the DLL export more simple
//macro standard method, all the files in this DLL is defined using the command line TLVISIONMODULE_EXPORTS
The compiler//symbol, and the DLL for use in
//should not define this symbol on any other project, so, any other project in the source file containing the file will be
//TLVISIONMODULE_API functions as from a DLL import, while the DLL will use this macro to define the
//symbol as are exported,
# ifdef TLVISIONMODULE_EXPORTS
# define TLVISIONMODULE_API __declspec (dllexport)
# the else
# define TLVISIONMODULE_API __declspec (dllimport)
# endif

//this is from tlVisionModule. DLL export
The class TLVISIONMODULE_API CtlVisionModule {
Public:
CtlVisionModule (void);
//TODO: add your way here,

Bool CreateView (CWnd * view);

};

//CPP
//way to Create a crash
Bool CtlVisionModule: : CreateView (CWnd * view)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());
M_pDlgMain=new CDlgMain;
M_pDlgMain - & gt; Create (IDD_DIALOG_MAIN, view);//collapse ~ ~
M_pDlgMain - & gt; ShowWindow (SW_SHOW);

return true;
}
//two way of running, the DLL interface is a pop-up, is not I want
Bool CtlVisionModule: : CreateView (CWnd * view)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());
M_pDlgMain=new CDlgMain;
M_pDlgMain - & gt; Create (IDD_DIALOG_MAIN, NULL);//
M_pDlgMain - & gt; ShowWindow (SW_SHOW);

return true;
}



debug interface, a lot of Pointers, look not to understand:

CodePudding user response:

problem solving, or oneself this aspect knowledge too lack : the HWND transfer
 
//h definition
The CWnd m_pwnd;//this doesn't define the CreateView function, function end collapse

//CPP code changes following
Bool CCamController: : CreateView (HWND HWND)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());
M_pDlgMain=new CDlgMain;

M_pwnd. Attach (HWND);
M_pDlgMain - & gt; Create (IDD_DIALOG_MAIN, & amp; M_pwnd);
M_pDlgMain - & gt; ShowWindow (SW_SHOW);

return true;
}

CodePudding user response:

DLL interface parameters, unfavorable use MFC class/class pointer do different compilers will produce different results
It is best to use basic variable types, strong compatibility

CodePudding user response:

Pit stepping much become experts
  • Related