Click here to Skip to main content
15,920,468 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Terminating a process Pin
led mike13-Nov-06 9:51
led mike13-Nov-06 9:51 
QuestionRe: Terminating a process Pin
David Crow13-Nov-06 9:55
David Crow13-Nov-06 9:55 
AnswerRe: Terminating a process Pin
Jim Crafton13-Nov-06 10:03
Jim Crafton13-Nov-06 10:03 
AnswerRe: Terminating a process Pin
#realJSOP13-Nov-06 10:15
professional#realJSOP13-Nov-06 10:15 
JokeRe: Terminating a process Pin
led mike13-Nov-06 10:43
led mike13-Nov-06 10:43 
AnswerRe: Terminating a process Pin
Stephen Hewitt13-Nov-06 13:21
Stephen Hewitt13-Nov-06 13:21 
QuestionAutomation server - Coclass registration problem Pin
User 21559713-Nov-06 6:48
User 21559713-Nov-06 6:48 
QuestionMessage Map doesn't work in dynamically loaded dll Pin
Stefan Rehling13-Nov-06 6:39
Stefan Rehling13-Nov-06 6:39 
Hi all,
I have a problem, perhaps someone can help me...
I enabled my mfc-application to dynamically load plugin dlls (MFC dlls) via a specific api.
The plugin-dll is provided by a CWnd pointer to the container window of the application and creates its window by a call like this:

<br />
CWnd* CreateMainWindow(CWnd* pParentWnd, CString& strCaption, int& idToolbarResource, UINT* pCmdIDs, int& nCmdIDs)<br />
{<br />
	<br />
	AFX_MANAGE_STATE(AfxGetStaticModuleState());<br />
 	idToolbarResource = IDR_ANALYZER_TOOLBAR;<br />
	pCmdIDs[0] = g_iFirstCmdID + CMDID_ANALYZER_NEW;<br />
	pCmdIDs[1] = g_iFirstCmdID + CMDID_ANALYZER_IMPORT;<br />
<br />
 	nCmdIDs = 2;<br />
<br />
	strCaption = "NC-Prozessanalyse";<br />
<br />
	if(!g_AnalyzerView)<br />
	{<br />
		g_AnalyzerView = new CAnalyzerView;<br />
		g_AnalyzerView->Create(NULL, (LPCTSTR)"", WS_CHILD|WS_VISIBLE,  CRect(0,0,0,0), pParentWnd, 0, NULL);<br />
		return g_AnalyzerView;<br />
	}<br />
<br />
<br />
	return NULL;<br />
}<br />


So, this all works fine and I get a nice window with all kinds of stuff in it all created by the dll class CAnalyzerView in this case. As u see, I also provide the frame app by a toolbar resource, and I do a kind of dynamic Command ID handling. Everything fine so far...

...except the thing with the Message Map...

Lets assume, my CAnalyzerView should have a Combo Box. I tried 2 ways to accomplish that:

1.) using the dialog editor to create a dialog resource (IDD_ANALYZER) with a Combo Box (IDC_TOOL_COMBO) and making CAnalyzerView derived from CFormView.
When the class creates, the combo box element is displayed correctly.
BUT as soon as I create a CComboBox member variable for the combo box which is bound to the resource by a call to

<br />
DDX_Control(pDX, IDC_TOOL_COMBO, m_ComboTools);<br />


the program crashes ;-(((

2.) Second, I tried to create all dialog control elements by hand. This is a really hard job when having multiple dialog controls... I created the m_ComboTools variable in the OnCreate method of CAnalyzerView (which in the meantime become CWnd derived again) like this:


<br />
m_ComboTools.Create(WS_CHILD | WM_NOTIFY  | WS_VISIBLE | CBS_DROPDOWNLIST, CRect(0,0,0,0), this, IDC_TOOL_COMBO);<br />
m_ComboTools.SetOwner(this);<br />
m_ComboTools.SetParent(this);<br />
m_ComboTools.SetFont(this->GetFont()); <br />


then I created a Messagemap entry and a callback memberfunction like this:

<br />
BEGIN_MESSAGE_MAP(CAnalyzerView , CWnd)<br />
     ...<br />
     ON_CBN_SELCHANGE(IDC_TOOL_COMBO, OnCbnSelchangeToolCombo)<br />
END_MESSAGE_MAP()<br />


The member function OnCbnSelchangeToolCombo is NEVER CALLED!!!

Then I tried to trap the WM_NOTIFY event by overriding the OnNotify member function of CWnd like this:




<br />
BOOL CAnalyzerView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)<br />
{<br />
	switch(wParam)<br />
	{<br />
	case IDC_TOOL_COMBO:<br />
		if(lParam == CBN_SELCHANGE)<br />
			OnCbnSelchangeToolCombo();<br />
		break;<br />
	case IDC_SEL_CHART:<br />
		if(*pResult == CTCN_SELCHANGE)<br />
			OnTcnSelchangeSelChart();<br />
		break;<br />
<br />
	}<br />
	return CWnd::OnNotify(wParam, lParam, pResult);<br />
}<br />


I dont know, if the pResult or lParam parameter is responsible to deliver the Notify message. I tried both, with no effect. The IDC_TOOL_COMBO does not seem to send Notify messages.
The funny thing is, that the IDC_SEL_CHART control, which is of class CCustomTabCtrl, a class by Andrzej Markowski (here from Code Project) has no problem with sending notify messages... the CCustomTabCtrl was created the same way:

<br />
m_SelChart.Create(WS_CHILD  | WS_VISIBLE, CRect(0,0,0,0), this, IDC_SEL_CHART);<br />


I dont know why it doesnt work with other elements.

I think it is a fundamental problem which lies in the architecture of the dynamically loaded mfc dll. The whole message map does not work properly, as well as the DDX stuff.
Everywhere at the interface to the frame app I used the

AFX_MANAGE_STATE(AfxGetStaticModuleState());

call as the class wizard generated code told me.

I don't know whats going wrong, please help! At this stage I have a well working plugin system, but I will have to forget it all if I couldnt get those controls and message maps to work.

Thanks in advance & plz excuse my bad english
ulretsam
AnswerRe: Message Map doesn't work in dynamically loaded dll Pin
Mark Salsbery13-Nov-06 7:29
Mark Salsbery13-Nov-06 7:29 
GeneralRe: Message Map doesn't work in dynamically loaded dll Pin
Stefan Rehling13-Nov-06 8:05
Stefan Rehling13-Nov-06 8:05 
GeneralRe: Message Map doesn't work in dynamically loaded dll Pin
Mark Salsbery13-Nov-06 8:27
Mark Salsbery13-Nov-06 8:27 
GeneralRe: Message Map doesn't work in dynamically loaded dll Pin
Mark Salsbery13-Nov-06 8:46
Mark Salsbery13-Nov-06 8:46 
GeneralRe: Message Map doesn't work in dynamically loaded dll Pin
Stefan Rehling13-Nov-06 22:31
Stefan Rehling13-Nov-06 22:31 
QuestionafxOccMgr and pWndCtrl problems Pin
earlgraham13-Nov-06 6:36
earlgraham13-Nov-06 6:36 
QuestionMultiLanguage Engine Pin
dannygilbert313-Nov-06 6:11
dannygilbert313-Nov-06 6:11 
AnswerRe: MultiLanguage Engine Pin
toxcct13-Nov-06 6:19
toxcct13-Nov-06 6:19 
AnswerRe: MultiLanguage Engine Pin
ThatsAlok13-Nov-06 7:00
ThatsAlok13-Nov-06 7:00 
QuestionExtern and CLASS Pin
dannygilbert313-Nov-06 6:10
dannygilbert313-Nov-06 6:10 
AnswerRe: Extern and CLASS Pin
Mark Salsbery13-Nov-06 6:16
Mark Salsbery13-Nov-06 6:16 
AnswerRe: Extern and CLASS Pin
toxcct13-Nov-06 6:17
toxcct13-Nov-06 6:17 
AnswerRe: Extern and CLASS Pin
James R. Twine13-Nov-06 6:26
James R. Twine13-Nov-06 6:26 
AnswerRe: Extern and CLASS Pin
ThatsAlok13-Nov-06 7:00
ThatsAlok13-Nov-06 7:00 
Question2 CFileDialogs Pin
Desmo1613-Nov-06 6:07
Desmo1613-Nov-06 6:07 
AnswerRe: 2 CFileDialogs Pin
James R. Twine13-Nov-06 6:09
James R. Twine13-Nov-06 6:09 
AnswerRe: 2 CFileDialogs Pin
toxcct13-Nov-06 6:09
toxcct13-Nov-06 6:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.