|
Try this:
In the function in your DLL that invokes the dialog add the following code:
// Get the Handle to the DLL
HMODULE hDLL = GetModuleHandle("MyDLLName.dll");
// Get the current resource Handle (i.e.from whomever
// called us -- probaby for the .exe)
HINSTANCE hEXE = AfxGetResourceHandle();
// Set the current resource Handle to point to the DLL's resources
AfxSetResourceHandle((HINSTANCE) hDLL);
// Now create & show the dialog -- it will use the DLL's resources
CMyDialog Dlg;
if (Dlg.DoModal() == IDOK) {
...
}
// Restore the resource handle to where it was when we were called
AfxSetResourceHandle(hEXE);
// Now it is safe to return
return;
John
|
|
|
|
|
Dear John,
Thank you for your advice, but the first try didn't get the result expected.
But idea is very interesting for me by itself.
I'll try again, may be I just have to pay attention to any other factors too.
|
|
|
|
|
Do you have a common resource.h file so that none of the resource IDs will confilct?
John
|
|
|
|
|
Dear John,
Thank you very much for your help, finally your first answer was exactly what I needed. I understood it today after I repeated my tests carefully and accurately.
You can’t imagine how happy now I’m ! This problem with resources worried me during almost a month. It was growing together with number of my DLLs. Now I use 11 different DLLs in the same project. And finally you helped me to find such a simple and perfect decision !
I’m very grateful to you !
With best regards and wishes from Russia.
Alexander.
|
|
|
|
|
You are welcome. This was code I got on another website. I generally do this a little bit differently but if you understand the example I gave you, you can understand what I do.
Here is what I do with all my DLLs (this was done with an vc6 appwizard that I created for that purpose):
In the file that has DLL main
#include "stdafx.h"
#include <afxdllx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static AFX_EXTENSION_MODULE ExtDllTestDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("EXTDLLTEST.DLL Initializing!\n");
if (!AfxInitExtensionModule(ExtDllTestDLL, hInstance))
return 0;
new CDynLinkLibrary(ExtDllTestDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("EXTDLLTEST.DLL Terminating!\n");
AfxTermExtensionModule(ExtDllTestDLL);
}
return 1;
}
EXTDLLTEST_DLLState::EXTDLLTEST_DLLState()
{
m_hInstOld = AfxGetResourceHandle();
AfxSetResourceHandle(ExtDllTestDLL.hModule);
}
EXTDLLTEST_DLLState::~EXTDLLTEST_DLLState()
{
AfxSetResourceHandle(m_hInstOld);
}
Then in your dll header file:
#if defined(EXTDLLTEST_STATIC)
#define EXTDLLTEST_CLASS_EXPORT
#elif !defined(EXTDLLTEST_DLL)
#define EXTDLLTEST_CLASS_EXPORT AFX_CLASS_IMPORT
#else
#define EXTDLLTEST_CLASS_EXPORT AFX_CLASS_EXPORT
#endif
class EXTDLLTEST_CLASS_EXPORT EXTDLLTEST_DLLState
{
public:
EXTDLLTEST_DLLState();
~EXTDLLTEST_DLLState();
protected:
HINSTANCE m_hInstOld;
};
Then to use it is very simple. In a function that I need resources from this dll I declare a variable of EXTDLLTEST_DLLState and all the work is done for me:
int CFileDlg::DoModal()
{
EXTDLLTEST_DLLState state;
return CDialog::DoModal();
}
Notes:
I export all symbols from my dlls by putting a EXTDLLTEST_CLASS_EXPORT before the symbol name like EXTDLLTEST_DLLState above. EXTDLLTEST_DLL is only defined in the project that contains the dll. If you do not want to export EXTDLLTEST_DLLState you can do it completly transparent to the end user. This is what I typically do. You can do this with dialogs by overriding DoModal and Create (if you want to support modeless dialogs).
John
|
|
|
|
|
How to move CDailog child window under other it's child window?
I need to show one child window on toop of others.
Problem:
Or for owner-drawn window was not drawing
background above toher controls.
How to do that?
thanks.
|
|
|
|
|
Check out SetWindowPos api. this api may of some interest to u.
|
|
|
|
|
I need sample code or more explained opinion.
Just that call nothing does with insertAfter flag.
|
|
|
|
|
Set the proper parent of each child dialog and they will be over each other.
|
|
|
|
|
I have followinf problem:
Owner-drawn CStatic lies over CEdit
all within CDialog,
But I need Cedit must be visible.
|
|
|
|
|
Hi All
I dunno if this is the right place to ask, but here it goes.
I have been creating a small shell extension for one of my programs. Now how can i unload the extension so i can replace the .DLL with the updated one. I saw a solution other places in here but that included rebooting and placing a .BAT file in the RunOnce section of the Windows Registry.
I any have a better solution for this i would gladly be the one to know
Thx in advance
|
|
|
|
|
This is want i used to do , from the task manager delete all instances of the explorer the taskbar will disappear and then compile the extension dll, this will replace ur binaries.
Hope this helps.
|
|
|
|
|
This code restarts the Windows shell programmatically:
HWND hwndShell = FindWindow("Progman", NULL);
PostMessage(hwndShell, WM_QUIT, 0, 0L);
WinExec("Explorer.exe",SW_SHOW);
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Interesting code.
Will it close all instanses of the explorer?
|
|
|
|
|
Mr.Prakash wrote:
Will it close all instanses of the explorer?
errr... there's only ONE instance running.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Rickard Andersson19 wrote:
there's only ONE instance running
I know for sure coz i have developed namespace extensions, if two explorers are open you need to terminate each of them using the task manager otherwize the namespace is not unloaded from the memory.
So i dont think ONE instance is the right answer always, there can be more than one.
|
|
|
|
|
Yay thanks. It was something like this i was looking for. So i basicly just make my updating between the PostMessage and WinExec
|
|
|
|
|
I need to disable CListCtrl, so user won't be able to do anything with list control.
I'm calling CListCtrl::EnableWindow(FALSE); to do that, but it also
displays list control in gray color.
How to disable this without changing the color to gray ?
Thanks !
rrrado
|
|
|
|
|
In general you cannot change the color of a control that is in a disabled state without subclassing.
Kuphryn
|
|
|
|
|
I got a lot of include files in vc6 like ios.h that are or damaged or they have errors, and i cant make programs that use them, also, vs.net timetrial have those files working, but it doesnt have some files i got in vc6. what is wrong here?
also, do you know where i can find learn-yourself-style tutorials about game programming?
|
|
|
|
|
|
I want to convert a char * to unsigned char[](or fill that array with char * string) but I can't find it, I can do reverse of it but not this one.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
It will be helpfull with little bit of code that you are trying to convert.
char *pszString;
pszString = new char[20];
now pszString can store upto 19 bytes of string.
you can either access it as
pszstring,
if you want to access each char then
*(pszString+index)
or
pszString[index]
hope i answered ur question properly.
|
|
|
|
|
Mr.Prakash wrote:
now pszString can store upto 19 bytes of string.
WRONG!
You allocated 20, right? How can you say it can hold 19 bytes then?
You know, it is starting from 0, that means 0 is the first element.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
i allocated 20 bytes, 19 bytes for some string and the 20th for \0
|
|
|
|