MFC Resource labels not set

MFC Resource labels not set

Anonymous
Not applicable
220 Views
1 Reply
Message 1 of 2

MFC Resource labels not set

Anonymous
Not applicable
Hi,

another question about ARX & MFC:
We use an ARX extension dll (dynamically linked), we reproduce exactly the
MFC
example, using TemporaryResourceOverride and module state managing.

When executing the application, the labels of the button with IDOK, IDCANCEL
and
IDC_STATIC have some random text. All the rest is correctly shown. Since i
rename,
i.e. IDOK resource to IDOK_MYUNIQUEANDVERYSPECIALRESOURCE,
all works fine. It looks to me like a resource handling problem, but i
cannot figure out
where it is:

my main file:

...
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved);

if (dwReason == DLL_PROCESS_ATTACH)
{
_hdllInstance = hInstance;
CTemporaryResourceOverride::SetDefaultResource(_hdllInstance);
...

and when creating dialog:

...
CTemporaryResourceOverride temp;
DlgLogin dlg;
...
theArxDLL.AttachInstance(hInstance);

Thanx,
Wolf.
0 Likes
221 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hi, Wolf,

from my experiences with MFC under Arx :

Because of some trouble with CTemporaryResourceOverride (similar to yours),
I will never use it anymore - simply, there is no reason to use it, MFC
provides simple & stable technique for !

What I do (without any problems):

DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
_hdllInstance = hInstance;
}
Like you, I will save my own resource handle - so far so good.

Creating the dialog :

HINSTANCE oldInstance = :: AfxGetResourceHandle(); // buffer the currently
active resource
::AfxSetResourceHandle(_hdllInstance);
DlgLogin *pDlg = new DlgLogin();
:
:
open the dialog with pDlg->DoModal(); or pDlg->Create(....); as needed
:
:
::AfxSetResourceHandle(OldInstance);
return;


With this simple 'buffer & restore' technique, together with ONLY dynamic
dialog creation, I have never experienced any resource problems - and I have
really complex MFC/Arx programs running ...
The advantage is, that your code can control resource usage, and the time of
resource usage is clear.

I hope this helps ....
Torsten Moses
0 Likes