Creating a dialog from a dll
Hello,
I have a dll I built to be loaded as a pluging. As part of the dll I have a dialog I'm trying to create and display.
The dialog is created and displayed using CreateDialog, however once the dialog is shown it doesn't respond, as soon as I pass the mouse over the dialog the mouse pointer changes to busy, and the dialog isn't responding while the rest of the module keeps running.
bool CDialogs::displaySafetyDialog(HWND wnd)
{
HWND retValue = CreateDialog(m_instance, MAKEINTRESOURCE(IDD_SAFETY), NULL, dialogProc);
return true;
}
INT_PTR CALLBACK CDialogs::dialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static int num;
BOOL translated = false;
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (num == GetDlgItemInt(hwnd, IDC_INPUT, &translated, false))
{
DestroyWindow(hwnd);
}
return TRUE;
case IDCANCEL:
DestroyWindow(hwnd);
return TRUE;
default:
break;
}
break;
default:
break;
}
return FALSE;
}
Any help will be appreciated,
Best regards,
Alex
Re: Creating a dialog from a dll
Please format your code properly before posting and use code tags. Your code as shown is not easy to understand. Go Advanced, select the code and click '#'.
Re: Creating a dialog from a dll
Quote:
Originally Posted by
khalameizer
Hello,
I have a dll I built to be loaded as a pluging. As part of the dll I have a dialog I'm trying to create and display.
The dialog is created and displayed using CreateDialog, however once the dialog is shown it doesn't respond, as soon as I pass the mouse over the dialog the mouse pointer changes to busy, and the dialog isn't responding while the rest of the module keeps running.
Code:
bool CDialogs::displaySafetyDialog(HWND wnd)
{
HWND retValue = CreateDialog(m_instance, MAKEINTRESOURCE(IDD_SAFETY), NULL, dialogProc);
return true;
}
INT_PTR CALLBACK CDialogs::dialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static int num;
BOOL translated = false;
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (num == GetDlgItemInt(hwnd, IDC_INPUT, &translated, false))
{
DestroyWindow(hwnd);
}
return TRUE;
case IDCANCEL:
DestroyWindow(hwnd);
return TRUE;
default:
break;
}
break;
default:
break;
}
return FALSE;
}
Any help will be appreciated,
Best regards,
Alex
Attached above the formatted code.
Thank you,
Alex
Re: Creating a dialog from a dll
maybe a silly question, but in that kind of setup... Who'll be doing the "pumping" of the messages of your dialog ?
also. The thread that creates the window, needs to be the SAME thread that processes the messages. Does your plugin guarantee this is always going to be the case ?
Re: Creating a dialog from a dll
Quote:
Originally Posted by
khalameizer
as soon as I pass the mouse over the dialog the mouse pointer changes to busy, and the dialog isn't responding while the rest of the module keeps running.
You need to learn about modal and modeless dialogs. CreateDialog just creates modeless dialog which requires a proper message pump be present in the thread. DialogBox function creates a modal dialog and internally takes care about dialog messages proper pumping.