 |
|
 |
it is what i find,but i really don't know how to use,please help me!!
|
|
|
|
 |
|
|
 |
|
 |
Hallo Alexey!
The problem you describe is actually mine. But I am sorry, I do not understand, how to use your code. I tried to put your code to my samples, but without success. Could you give a short example?
Thanks Anton!
|
|
|
|
 |
|
 |
following is my code piece:
1. in the .h file , add the following ( "WorkerDLL" is desired in the cpp file like this: static AFX_EXTENSION_MODULE WorkerDLL = { NULL, NULL }; and you can alter it your favourite)
...
extern AFX_EXTENSION_MODULE WorkerDLL;
class DllInstanceSwitcher
{
public:
DllInstanceSwitcher()
{
m_hInst = AfxGetResourceHandle();
AfxSetResourceHandle(WorkerDLL.hResource);
}
~DllInstanceSwitcher()
{
AfxSetResourceHandle(m_hInst);
}
private:
HINSTANCE m_hInst;
};
#define SWITCH_DLLRES DllInstanceSwitcher swres
2. when you need switch res in the cpp file
...
SWITCH_DLLRES;
m_pInetStockdrvDlg = new CInetStockdrvDlg;
m_pInetStockdrvDlg->Create(CInetStockdrvDlg::IDD,NULL);
m_pInetStockdrvDlg->ShowWindow(SW_SHOWNORMAL);
m_pInetStockdrvDlg->SetFocus();
...
|
|
|
|
 |
|
 |
Hi, I have a problem,
I've done a DLL, that is inherited from CDialog. It build up itsself his own Dialog.
The whloe time I included the classes and make an Object of them.
So I could use the inherited function. But nowadays I have to build up a DLL.
How can I use the inherited functions from CDialog ?
A Pointer in the DLL have I, but no Handle to the CWNd object . . .
this = 0x34093049 CWnd (hnwd = 0000000000) ???
Can anybody help me . . .
All functions that I start in the DLL like MoveWindow() . . . return an Access Violation
Thanx
BeginnerOnline
|
|
|
|
 |
|
|
 |
|
 |
Does anyone know how to use this switcher with command ID's to route command to correct MFC message map?
|
|
|
|
 |
|
 |
You have to be careful here. If you use the CDynLinkLibrary() constructor to link your extension DLL into the DLL user's resource chain, then your DLL 'shares' the resource space with the calling application. In this case, the ID's assigned to your resources in the DLL have to be set to not conflict with those in the application, and the approach outlined in this article is not required.
If you don't use the CDynLinkLibrary(), then it is up to you to ensure within the DLL that every reference within the DLL to a resource is accessed from the correct place using AfxSetResourceHandle().
If this sounds like the voice of experience, it is. I just finished fixing a bug in a product that had been released for over a year related to this problem. I renumbered some resources in a DLL, and all of the sudden a dialog box implemented within the DLL stopped working.
I do like the approach in your article, though.
Gary R. Wheeler
|
|
|
|
 |
|
 |
For avoiding those problems when you renumber resource id's in your resource.h file, there is a simple way for solving this:
use the same \res-folder and resource.h file for your dll-project.
Never got any problems with renumbering of resource id's in my main project.
After renumbering the only problem is, for avoiding dll hell, that you must compile the whole project (foreign language dll and afterwards your main project)
Bye,
Michael Kuelshammer
|
|
|
|
 |
|
 |
For last year I've been writing an application with number of extension DLL's and using the method you explained (set different ID's for different DLL's). So, it's very difficult to support such app, because we need to control every ID in every DLL.
"...If you use the CDynLinkLibrary() constructor to link your extension DLL into the DLL user's resource chain, then your DLL 'shares' the resource space with the calling application..."
That means that application uses union resource space. But we can simply change resource context to only DLL resources and access only them (not all application and other DLL resources).
|
|
|
|
 |
|
 |
I can't believe that it works for an MDI application, where you can define different toolbars and menus for different views when defining your MDI views with CMultiDocTemplate(), if some of the mdi windows will be open and you wish to switch the resource to another language resource dll then I don't think that this easy way will work....
I think you have to walk through all multi doc templates and replace the resources....
If you really be sure that it will work the way you described then a small mdi project with possibility of switching between two language extension dll's would be the best demonstration that it really works....
Bye,
Michael Kuelshammer
Michael Kuelshammer
|
|
|
|
 |
|
 |
You right. This method is not intended to switch the language in you app.
I have a number of DLL's in my project and every DLL uses it's own resources.
This snatch provided to switch resource context to own DLL resources.
|
|
|
|
 |
|
 |
Yeah, really nice and simple way
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
 |
|
 |
Nice solution, but I think (As far as I recall) it will not work in Win 98 & Me, because AfxSetResourceHandle can't be change after you set it
|
|
|
|
 |
|
 |
I successfully use a similar technique in product software which has been tested and verified on Windows98SE. Do you have any references to documented limitations on this platform?
|
|
|
|
 |
|
 |
"..AfxSetResourceHandle can't be change after you set it..."
I think you wrong. AfxSetResourceHandle() present in MFC since 4.1 (Win95) and works fine.
Why I can't change this handle twice? Many API functions use HINSTANCE to target working context: FindResource, etc.
Do you have some links (refs) explaining this problem?
|
|
|
|
 |
|
 |
This is a nice way of doing it. In the past I always hard coded the AfxSetResourceHandle() calls to switch to the DLL resources.
I think I will be using this in the future.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
 |