Load Dialog From a Resource DLL
-
Is the resource ID
ID_DIALOG
in the calling program equal to what was used in the DLL? If you're not sure and you don't have the DLL's code to look it up, you could analyse the DLL with the resource hacker[^].i have the correct id, i need a small code to show the dialog from reource dll in win32 way
Some Day I Will Prove MySelf :: GOLD
-
I need a sample of how to load dialog resource from a dll I found a sample here but it is not working. http://www.codeproject.com/Messages/1212280/Re-how-to-load-dialog-resource-from-a-dll.aspx
// Load the resource dll
HMODULE hModule = LoadLibrary("C:\\another_resource.dll");if(hModule != NULL)
{
// Loading your dialog
HWND hDialog = CreateDialog(hModule, MAKEINTRESOURCE(ID_DIALOG), /* Handle to parent window */, /* Pointer to dialog procedure function */);// Loading your bitmap
HBITMAP hBitmap = LoadBitmap(hModule, MAKEINTRESOURCE(IDB_BITMAP);FreeLibrary(hModule);
}thanx in advance please help
Some Day I Will Prove MySelf :: GOLD
Firstly you need a message handler, essentialy the same as your main message handler, usually WndProc
BOOL CALLBACK DlgProc(HWND hDlg, UINT nMessage, WPARAM wParam, LPARAM lParam) {
switch (nMessage) {
case WM_INITDIALOG:
//This is where you do all your initialisation. This is the first place after all the controls have been created, so you can use GetDlgItem()
return TRUE;case WM\_COMMAND: //This is the same as it is in the WndProc, handle button clicks, etc... switch (LOWORD(wParam)) { case IDOK: //This is usually the OK or Done button return TRUE; case IDCANCEL: //This is usually the Close or Cancel button DestroyWindow(hDlg); //close the dialog return TRUE; } break; } } return FALSE;
}
Then you just need to use that as the "procedure function"
void DisplayDynamicDialog(HWND hParent) {
HMODULE hModule = LoadLibrary("Resources.dll");
if(hModule != NULL) {
hDialog = CreateDialog(hModule, MAKEINTRESOURCE(ID_DIALOG), hParent, (DLGPROC)DlgProc);
ShowWindow(hDialog, SW_SHOW);
FreeLibrary(hModule); //This might need to be called later, after the dialog has been closed since it is modeless
}
}Finally, just to reiterate what Thaddeus Jones said, the ID you supply needs to be the ID defined in the DLL, not the ID defined in the exe, hence the resource.h that you include needs to be from the dll. To avoid confusion, I recommend using quoted string names instead.
-
I need a sample of how to load dialog resource from a dll I found a sample here but it is not working. http://www.codeproject.com/Messages/1212280/Re-how-to-load-dialog-resource-from-a-dll.aspx
// Load the resource dll
HMODULE hModule = LoadLibrary("C:\\another_resource.dll");if(hModule != NULL)
{
// Loading your dialog
HWND hDialog = CreateDialog(hModule, MAKEINTRESOURCE(ID_DIALOG), /* Handle to parent window */, /* Pointer to dialog procedure function */);// Loading your bitmap
HBITMAP hBitmap = LoadBitmap(hModule, MAKEINTRESOURCE(IDB_BITMAP);FreeLibrary(hModule);
}thanx in advance please help
Some Day I Will Prove MySelf :: GOLD
you can also use combination of LoadResource[^] and FindResouce[^]
-
I need a sample of how to load dialog resource from a dll I found a sample here but it is not working. http://www.codeproject.com/Messages/1212280/Re-how-to-load-dialog-resource-from-a-dll.aspx
// Load the resource dll
HMODULE hModule = LoadLibrary("C:\\another_resource.dll");if(hModule != NULL)
{
// Loading your dialog
HWND hDialog = CreateDialog(hModule, MAKEINTRESOURCE(ID_DIALOG), /* Handle to parent window */, /* Pointer to dialog procedure function */);// Loading your bitmap
HBITMAP hBitmap = LoadBitmap(hModule, MAKEINTRESOURCE(IDB_BITMAP);FreeLibrary(hModule);
}thanx in advance please help
Some Day I Will Prove MySelf :: GOLD
-
create dialog.. Is required, I have the correct dialog id and i m able to load the dll using loadlibrary(). After this i m confused what to do next, so i need a small example that demonstrate how to show the dialog from resource dll. Thanx in advance.
Some Day I Will Prove MySelf :: GOLD
-
i know it is incomplete, therefore i m in need of a sample in win32 way.
Some Day I Will Prove MySelf :: GOLD
-
see from msdn documentation http://msdn.microsoft.com/en-us/library/ms644996%28v=vs.85%29.aspx#modeless_box[^]
thanx, but i need help in displaying a dialog from a resouce dll.
Some Day I Will Prove MySelf :: GOLD
-
Firstly you need a message handler, essentialy the same as your main message handler, usually WndProc
BOOL CALLBACK DlgProc(HWND hDlg, UINT nMessage, WPARAM wParam, LPARAM lParam) {
switch (nMessage) {
case WM_INITDIALOG:
//This is where you do all your initialisation. This is the first place after all the controls have been created, so you can use GetDlgItem()
return TRUE;case WM\_COMMAND: //This is the same as it is in the WndProc, handle button clicks, etc... switch (LOWORD(wParam)) { case IDOK: //This is usually the OK or Done button return TRUE; case IDCANCEL: //This is usually the Close or Cancel button DestroyWindow(hDlg); //close the dialog return TRUE; } break; } } return FALSE;
}
Then you just need to use that as the "procedure function"
void DisplayDynamicDialog(HWND hParent) {
HMODULE hModule = LoadLibrary("Resources.dll");
if(hModule != NULL) {
hDialog = CreateDialog(hModule, MAKEINTRESOURCE(ID_DIALOG), hParent, (DLGPROC)DlgProc);
ShowWindow(hDialog, SW_SHOW);
FreeLibrary(hModule); //This might need to be called later, after the dialog has been closed since it is modeless
}
}Finally, just to reiterate what Thaddeus Jones said, the ID you supply needs to be the ID defined in the DLL, not the ID defined in the exe, hence the resource.h that you include needs to be from the dll. To avoid confusion, I recommend using quoted string names instead.
:thumbsup: thanks a lot, worked like a charm, once again thanx.
Some Day I Will Prove MySelf :: GOLD
-
i know it is incomplete, therefore i m in need of a sample in win32 way.
Some Day I Will Prove MySelf :: GOLD
-
sir i had received the answer, thanx for giving ur valuable time sir.
Some Day I Will Prove MySelf :: GOLD