|
I don't see anything in your sample code that shows different threads.
Am I missing something?
Calls across the EXE/DLL boundary should be safe, unless the DLL is linked
to a separate MFC library, in which case all bets are off.
The only way this will work is to use a true MFC extension DLL[^].
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If the DLL is displaying a dialog and the dialog code through it's messageing calls the callback is there a problem. Do dialogs operate in the same thread or different ?
When I first did this I thought that same as you but it does fail. In the DLL I am using some 3rd part imaging software (LEAD) but it all links with the same liraries.
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
Unless you've left out some code, it's all on one thread.
As shown, there's only one message loop - running in the EXE's CWinApp object.
How is the dialog created in the DLL? Does the dialog use a different thread
for it's message loop?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
the DLL function
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
nRet = DoDialogBoxParam(IDD_BCI_DLG, hParentWnd, (DLGPROC)BCIDlgProc, (LPARAM) pBciDlgData);
the partent windows is that of the main app, the dialog resource is in the DLL
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
DoDialogBoxParam? I meant at the MFC/Win32 level -
I have no idea what your functions do
Is the dialog created using MFC or Win32? Modal or modeless?
Also important is what type of DLL you're using - MFC extension DLL or
regular DLL linked to MFC (see Kinds of DLLs[^]).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry about that
DLGPROC pfn;
pfn = (DLGPROC) MakeProcInstance((FARPROC) pfnDialog, AfxGetApp()->m_hInstance);
nRet = (L_INT) DialogBoxParam(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(nDialog), hWnd, pfn, lParam);
FreeProcInstance((FARPROC) pfn);
Regular DLL using / linked with MFC (NOT static, same as main app)
within wincore.cpp here is where it fails
// should be a normal window
ASSERT(::IsWindow(m_hWnd));
// should also be in the permanent or temporary handle map
CHandleMap* pMap = afxMapHWND();
ASSERT(pMap != NULL);
I have to ask the programmer of the main app some questions. I agree with you so far so I think there has to be something in our code messing something up.
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
Tony Teveris wrote: I have to ask the programmer of the main app some questions.
Yes
The module state stuff can affect CWnd pointers across the EXE/DLL
module boundary depending on the type of DLL. This needs to be managed correctly.
The CHandleMap is related to the module state. Your CView is in the EXE's map but in the
DLL function, you've changed the module state, so when the callback is called, the
code on the EXE side isn't finding the CView object in the DLL's map.
That's why the type of DLL is important. With a properly initialized extension DLL,
you don't need to use the AFX_MANAGE_STATE macro. Using an MFC extension DLL
is definitely the best/easiest for passing CWnds back and forth across the EXE/DLL boundary.
The drawback to an extension DLL is it can't be used by a non-MFC EXE.
If you must use a standard DLL, then you'll need to manage the module state for
your callback.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It is NOT an extension DLL, just a normal DLL. I see your point and will look into extension DLL or mangage the state in the callback.
I think were done here - many thanks
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
Tony Teveris wrote: It is NOT an extension DLL, just a normal DLL
Cool. Try adding this to the top of the callback...
AFX_MANAGE_STATE(AfxGetAppModuleState());
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Dear all;
I have finished building an MFC Application in Microsoft visual studio 2003. Now I would like to produce an executable application which can be used in any machine.
How do i do that? please post any articles or help guidelines.
I am thankful
llp00na
|
|
|
|
|
llp00na wrote: which can be used in any machine.
I think you need to be more specific, "any machine" would include my refrigerator.
|
|
|
|
|
Oh sorry,
I meant any computer machine which has windows XP installed on it.
llp00na
|
|
|
|
|
Deployment of MFC applications is documented on msdn so you can find everything you need there. Perhaps some searching like this[^] would help.
|
|
|
|
|
I have finished building an MFC Application
What does a "build" actually refer to?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
I meant implementing or coding. The point i am trying to express if that i have tested the application within Microsoft visual studio 2003 and it works great. Now i would like to run the application outside the development environment.
I hope this is clear enough.
llp00na
|
|
|
|
|
Oh! hmm, well haven't you ever opened your project folder? Have you seen these folders? "Debug" "Release" ? All the binaries you build will get created there. If your .exe doesn't have any dependency, you can take that .exe straight from the "release" folder and distribute. but it's not the usual case. Even if you do something with MFC, it will become mfc dlls dependant. (assuming you are linking dynamically). So use an installer like "Innosetup" (google for it). it's free and cool. You can deploy apps on the fly.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
lol, indeed i have opened my project folder so many times. I have tried using the '.exe' file from the release folder but i encountered problems and thats why i posted this question. As you said it must have dependencies.
Ok, i will look for Innosetup and try it.
Thank you
llp00na
|
|
|
|
|
It Depends![^]
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
you mean an installation package ?
|
|
|
|
|
|
which can be used in any machine.
How do i do that?
Here![^]
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
|
Hello,
I am working for C project. The codebase exist since long time(more than 10 years).
We are using lots of structures with fixed array size. Like
struct tagMystruct
{
char name[256];
char disign[256];
.
.
}
Now new requirement came, I have to change fixed size arrays to dynamic arrays. I defined new array like
struct tagMystruct
{
char *name;
int nameLength;
char *disign;
int disgLength;
.
.
}
Is this correct approcach? In my existing code in lot many places we are using strcpy, strcat etc..
Now i have to check the buffer all the place before calling any function. It will take more time and regression? Can i know how can achive or any new ways?
Thanks and Regards,
Chandu
|
|
|
|
|
If the requirement is it must remain C code, then you have to do something like that you've exposed in your post.
However, if you can afford the C++ power then I strongly suggest to use STL's std::string instead of char * (at least toxcct will be happy ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
As another wrote, think whether it can be a C++ project so, you can use classes. For instance you can use the std libs or the MFC (with CString). There are a lot of other classes here at CP.
Try to develop with structs, as
stringStruct
{
int l;
char *p;
}
If you cant use classes you should think about implementing often used operations in funktions.
SetString( stringStruct *p, "new string" )
{
//do stuff
}
Greetings from Germany
|
|
|
|