-
January 21st, 2014, 04:28 AM
#1
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:isplaySafetyDialog(HWND wnd)
{
HWND retValue = CreateDialog(m_instance, MAKEINTRESOURCE(IDD_SAFETY), NULL, dialogProc);
return true;
}
INT_PTR CALLBACK CDialogs:ialogProc(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
-
January 21st, 2014, 06:51 AM
#2
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 '#'.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
January 21st, 2014, 08:05 AM
#3
Re: Creating a dialog from a dll
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
-
January 22nd, 2014, 07:58 AM
#4
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 ?
-
January 22nd, 2014, 09:09 AM
#5
Re: Creating a dialog from a dll
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.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|