How do I get the right resource in language-dll
Klaus Kurzawa -- klausk@saruman.cadpoint.se
Monday, December 09, 1996
[Mini-digest: 2 responses]
Thanks for all tips/ideas but nothing works so far.
Sorry if I left out all the other code but I used all default from the dirpicker
example.
Here almost all of my code for this sample that don't work and I do set the
hInstance to my loaded dll. I even checked that it has the same value and it
does.
I got a tip that OFN_ENABLETEMPLATE should be changed to
OFN_ENABLETEMPLATEHANDLE. Maybe this is the problem. (I'm not able to test this
right now.)
CDirDialog cfdlg(FALSE, NULL, NULL,
OFN_SHOWHELP | OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE, NULL);
cfdlg.m_ofn.hInstance = AfxGetInstanceHandle();
HINSTANCE hInst = AfxGetResourceHandle();
HRSRC hRes = ::FindResource(hInst,
MAKEINTRESOURCE(IDD_DLG_SELDIR), RT_DIALOG);
HGLOBAL hGlobal = ::LoadResource(hInst, hRes);
cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(hGlobal);
cfdlg.m_ofn.Flags &= ~OFN_EXPLORER;
if (IDOK==cfdlg.DoModal())
{
cfdlg.m_ofn.lpstrFile[cfdlg.m_ofn.nFileOffset-1]=0; //Nuke the "Junk"
csDir = cfdlg.m_ofn.lpstrFile;
return(TRUE);
}
return (FALSE);
_______________________________________________________________________________
Subject: Q: How do I get the right resource in language-dll
From: klausk@saruman.cadpoint.se on SMTPLINK
Date: 1996-12-05 19.27
[Mini-digest: 2 responses]
---------------------------- Forwarded with Changes ---------------------------
From: Klaus Kurzawa at CADPOINT.SWE
Date: 12/4/96 9:10AM
*To: mfc-l@netcom.com at SMTPLINK
Subject: Q: How do I get the right resource in language-dll
-------------------------------------------------------------------------------
Hi,
Environment: VC++ 4.1, Win 95, NT 4.0, NT 3.51
In my app I load a dll that contains resources of the language the user runs in
and I call AfxSetResourceHandle(hRes) to make it the current resource.
Then I took the dirpkr-sample to use a dir-selector, my app needs to run on
NT3.51 & NT4 & Win95, and in that sample You should assign the dialog-template
to use as Your dialog:
cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DLG_SELDIR);
Now this don't work for me because this only loads the resource from the
exe-file.
So I tried to find the resource in the dll like this:
HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(IDD_DLG_SELDIR),
RT_DIALOG);
I tried this one too with no success
//HINSTANCE hInst = AfxGetResourceHandle();
HRSRC hRes = ::FindResource( hInst,
MAKEINTRESOURCE(IDD_DLG_SELDIR), RT_DIALOG);
HGLOBAL hGlobal = ::LoadResource(hInst, hRes);
Here's my problem, how do I get the template from the HGLOBAL or how should I
solve this in another way?
cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(hGlobal);
The dialog are not displayed
cfdlg.DoModal();
Best regards,
Klaus Kurzawa
/klausk@cadpoint.se
-----From: David Lowndes
>In my app I load a dll that contains resources of the language the user runs
in
and use AfxSetResourceHandle(hRes) to use it.
Then I took the dirpkr-sample to use a dir-selector, my app needs to run
on
NT3.51 & NT4 & Win95, and there You should assign the dialog-template to
use as
Your dialog:....
cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DLG_SELDIR);
<
Klaus,
I replied to your note in the newsgroup but for some reason my messages
aren't appearing at the moment.
line above
is to set the cfdlg.m_ofn.hInstance to the instance handle of your
loaded
DLL (the handle returned by LoadLibrary).
>Dave
-----From: cugr1@gd.swissptt.ch (Cunningham Graham, IT347)
I presume that you have the language setting set to the language of =
choice in the .rc file of the dll. I did the same thing and couldnt see =
my string table, so the solution for me was to edit the .rc file of the =
dll making all the resources language neutral and then it worked.
hth
----------
Von: Klaus Kurzawa=5BSMTP:klausk=40saruman.cadpoint.se=5D
Gesendet: Mittwoch, 4. Dezember 1996 10:36
An: mfc-l=40netcom.com
Betreff: Q: How do I get the right resource in language-dll
Hi,
Environment: VC++ 4.1, Win 95, NT 4.0, NT 3.51
=
I tried the msnews with no luck.
In my app I load a dll that contains resources of the language the user =
runs in
and use AfxSetResourceHandle(hRes) to use it.
=
Then I took the dirpkr-sample to use a dir-selector, my app needs to run =
=
on
NT3.51 & NT4 & Win95, and there You should assign the dialog-template to =
=
use as
Your dialog:
=
cfdlg.m_ofn.lpTemplateName =3D MAKEINTRESOURCE(IDD_DLG_SELDIR);
=
=
Now this don't work for me because this only loads the resource from the
exe-file.
=
So I tried to find the resource in the dll like this:
=
HINSTANCE hInst =3D =
AfxFindResourceHandle(MAKEINTRESOURCE(IDD_DLG_SELDIR),
RT_DIALOG);
=
I tried this one to with no success
//HINSTANCE hInst =3D AfxGetResourceHandle();
=
HRSRC hRes =3D ::FindResource( hInst,
MAKEINTRESOURCE(IDD_DLG_SELDIR), =
RT_DIALOG);
HGLOBAL hGlobal =3D ::LoadResource(hInst, hRes);
=
=
I think this line is the error, how do I get the template from the =
HGLOBAL or
how should I solve this at all?
cfdlg.m_ofn.lpTemplateName =3D MAKEINTRESOURCE(hGlobal);
=
=
The dialog are not displayed
cfdlg.DoModal();
=
=
Hopefully someone on this list can help me?
=
Best regards,
Klaus Kurzawa
=
/klausk=40cadpoint.se
=
=
Jean-Paul Retru -- jpretru@socabim.fr
Thursday, December 12, 1996
----------
Environment: VC++ 4.2, Win 95, NT 4.0, NT 3.51
<
I was coding CDirDialog in a DLL. To display it from an application, I was usinq two helpers functions and a static HINSTANCE.
------------------------------------------------------------------------------------------------
extern "C"
{
DllImport extern HINSTANCE SaveResourceHandle;
}
inline void LockResourceHandle()
{
SaveResourceHandle = AfxGetResourceHandle();
#ifdef _DEBUG
HINSTANCE NewResourceHandle = ::GetModuleHandle("YourDebugDLL.DLL");
#else
HINSTANCE NewResourceHandle = ::GetModuleHandle("YourReleaseDLL.DLL");
#endif
ASSERT(NewResourceHandle != NULL);
AfxSetResourceHandle(NewResourceHandle);
}
inline void UnlockResourceHandle()
{
AfxSetResourceHandle(SaveResourceHandle);
}
To use this DLL code from an application :
DWORD dwFlags = OFN_SHOWHELP | OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE;
CDirDialog cfdlg(FALSE, NULL, NULL, dwFlags, NULL, NULL);
cfdlg.m_ofn.Flags &= ~OFN_EXPLORER;
CString csTitle;
LockResourceHandle();
csTitle = "A Title";
cfdlg.m_ofn.lpstrTitle = (LPCTSTR)csTitle;
cfdlg.m_ofn.hInstance = AfxGetResourceHandle();
cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(FILEOPENORD);
if (IDOK!=cfdlg.DoModal())
{
UnlockResourceHandle();
return;
}
UnlockResourceHandle();
------------------------------------
Jean-Paul RETRU
SOCABIM
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
>Von: Klaus Kurzawa=5BSMTP:klausk=40saruman.cadpoint.se=5D
>Gesendet: Mittwoch, 4. Dezember 1996 10:36
>An: mfc-l=40netcom.com
>Betreff: Q: How do I get the right resource in language-dll
>
>In my app I load a dll that contains resources of the language the user runs in
>and use AfxSetResourceHandle(hRes) to use it.
>
>Then I took the dirpkr-sample to use a dir-selector, my app needs to run on
>NT3.51 & NT4 & Win95, and there you should assign the dialog-template to use as
>your dialog:
> cfdlg.m_ofn.lpTemplateName =3D MAKEINTRESOURCE(IDD_DLG_SELDIR);
>
>Now this don't work for me because this only loads the resource from the
>exe-file.
----------
| Вернуться в корень Архива
|