G
Guest
I have a .NET 2.0 form that parents a message box. Neither is currently
active. How can I programatically activate the message box? I can't seem to
do it via the .NET Framework, since message boxes aren't .NET forms, so I've
tried doing it via the Win32 API, but still no luck. Here's what I've tried
so far:
// First activate the parent form
parentForm.Activate();
// Now attempt to activate the message box itself
const int GW_CHILD = 5;
const int WM_ACTIVATE = 6;
const int WA_INACTIVE = 0;
const int WA_ACTIVE = 1;
int hwndParent = (int)parentForm.Handle;
int hwndMsgBox = GetWindow(hwndParent, GW_CHILD);
if (hwndMsgBox != 0)
{
SendMessage(hwndMsgBox, WM_ACTIVATE, WA_ACTIVE, hwndMsgBox);
SendMessage(hwndParent, WM_ACTIVATE, WA_INACTIVE, hwndMsgBox);
}
Regards,
Marcus Ogden
Software Development
QSR International Pty Ltd
active. How can I programatically activate the message box? I can't seem to
do it via the .NET Framework, since message boxes aren't .NET forms, so I've
tried doing it via the Win32 API, but still no luck. Here's what I've tried
so far:
// First activate the parent form
parentForm.Activate();
// Now attempt to activate the message box itself
const int GW_CHILD = 5;
const int WM_ACTIVATE = 6;
const int WA_INACTIVE = 0;
const int WA_ACTIVE = 1;
int hwndParent = (int)parentForm.Handle;
int hwndMsgBox = GetWindow(hwndParent, GW_CHILD);
if (hwndMsgBox != 0)
{
SendMessage(hwndMsgBox, WM_ACTIVATE, WA_ACTIVE, hwndMsgBox);
SendMessage(hwndParent, WM_ACTIVATE, WA_INACTIVE, hwndMsgBox);
}
Regards,
Marcus Ogden
Software Development
QSR International Pty Ltd