MFC DLL and Dialogs
-
I have a problem I just don't get. I have created two programs, a ProgramApp and a ProgramDLL. The ProgramApp is a SDI and I create a standard modeless dialog when it starts up. Next I load the ProgramDLL so the ProgramApp can use it. I call a function in the Program DLL called ChangeDialogText( lpDlg ), this function sends the lpDlg pointer to the ProgramDLL when calling the ChangeDialogText( lpDlg ). ok, so far so good,.. now the ProgramDLL has a singal line that does this lpDlg->SetWindowText( "DLL Text" ).... bang here I get an assert that the lpDlg doesn't have a m_hWnd??!?!?! I have the AFX_MANAGE_STATE(AfxGetStaticModuleState()) in the beginning of the ChangeDialogText function. I just don't understand it,... it should work. what am I doing wrong. :confused:
-
I have a problem I just don't get. I have created two programs, a ProgramApp and a ProgramDLL. The ProgramApp is a SDI and I create a standard modeless dialog when it starts up. Next I load the ProgramDLL so the ProgramApp can use it. I call a function in the Program DLL called ChangeDialogText( lpDlg ), this function sends the lpDlg pointer to the ProgramDLL when calling the ChangeDialogText( lpDlg ). ok, so far so good,.. now the ProgramDLL has a singal line that does this lpDlg->SetWindowText( "DLL Text" ).... bang here I get an assert that the lpDlg doesn't have a m_hWnd??!?!?! I have the AFX_MANAGE_STATE(AfxGetStaticModuleState()) in the beginning of the ChangeDialogText function. I just don't understand it,... it should work. what am I doing wrong. :confused:
-
I had the same problem through a COM ATL DLL, but the solution is the same, just build a release version of your DLL, it should work (ASSERT only in debug).:) :) Celhtar
-
I had the same problem through a COM ATL DLL, but the solution is the same, just build a release version of your DLL, it should work (ASSERT only in debug).:) :) Celhtar
That isn't a very good solution. I do need my debug version... for debugging :-) and if it asserts then I'm doing something I shouldn't. The assert comes from the ::IsWindow( m_hWnd ) , the m_hWnd comes from my ProgramApp and I can use the lpDlg->SetWindowText( "Whatever" ) without anyproblems,.. but sending the lpDlg over to the DLL and using the same lpDlg->SetWindowText( "Whatever" ) asserts in the ::IsWindow function. The m_hWnd and lpDlg are the same both in the ProgramApp and ProgramDLL. For some reason the ProgramDLL can't see that the m_hWnd is a valid window in the ProgramDLL?! and this confuses me,.. I have now used 3 days and nights trying to solve this problem. :confused: :confused: :confused: :confused: :confused: :confused: Peter Marino ( www.marino.dk )
-
err, now you are confusing me even more :(( Peter Marino ( www.marino.dk )
-
I have a problem I just don't get. I have created two programs, a ProgramApp and a ProgramDLL. The ProgramApp is a SDI and I create a standard modeless dialog when it starts up. Next I load the ProgramDLL so the ProgramApp can use it. I call a function in the Program DLL called ChangeDialogText( lpDlg ), this function sends the lpDlg pointer to the ProgramDLL when calling the ChangeDialogText( lpDlg ). ok, so far so good,.. now the ProgramDLL has a singal line that does this lpDlg->SetWindowText( "DLL Text" ).... bang here I get an assert that the lpDlg doesn't have a m_hWnd??!?!?! I have the AFX_MANAGE_STATE(AfxGetStaticModuleState()) in the beginning of the ChangeDialogText function. I just don't understand it,... it should work. what am I doing wrong. :confused:
Try building both the exe and the dll using MFC in a shared DLL. I found this problem too, and using shared dll's it was solved... Somehow when you use MFC in a shared DLL both the EXE and the DLL will use the same heap or something and pointers can do their work better... You can find the option in the project settings of the project (left tab). Please, let me know if it helped you. Structured programming vs. chaotic mind boggling