Is it possible to fire an event when the user clicks outside a modal dialog?
OK, Windows provides it\'s own clues when you do this by making the \"bonk\" sound, or
I'm not sure how to do this in delphi but using C++ you could do something like this:
// The message loop for our modal dialogbox
BOOL CALLBACK DialogProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
return TRUE;
break;
case WM_COMMAND:
switch(wParam) {
case IDOK:
EndDialog(hwndDlg, 0);
return TRUE;
break;
}
break;
case WM_ACTIVATE:
// message sent when the window if being activated/deactivated
if(wParam == WA_INACTIVE) {
// the window is being inactivated so beep once
Beep(750, 300);
// bring dialog to the foreground
SetForegroundWindow(hwndDlg);
}
break;
}
return FALSE;
}
int main(int argc,char** argv) {
// create a modal dialog
DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_MYDIALOG),
HWND_DESKTOP,
DialogProc);
return 0;
}
You could also have a look at SetWindowsHookEx() and perhaps Subclassing Controls that may point you in the right direction.