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,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.