One more question.
Can't seem to find any info wether it's possible to disable Alt+F4 while MessageDlg pops-up or not.
The thing is, that the OnKeyDown event in main form works ok, while set with

if ((ssAlt in Shift) and (Key = VK_F4)) then

But that only affects the Alt+F4 keypress while still focused on form, but it helps nothing, because the MessageDlg is set in OnCloseQuery, and it asks for confirmation wether the app should exit or not.
Regarding the options Yes/No, with default set on "No" so accidental exit is as much unlikely triggered as possible, there is one caution that troubles me, that is, that if Alt+F4 is pressed when MessageDlg is poped-up, the dialog closes as well as the application exits. That's the least option I'd want to have for users.
With the code above it's at least not much likely that hitting Alt+F4 twice would close an app (which does, if the code above is not used), but still, I'd be glad it this would be possible to completely disable. Whether it's disabled during whole time the app is running, or in MessageDlg only, I don't really care... as long as it's in focus, it should be disabled. The app is actually in focus for as long as it runs. It's a controller program on a console, so it's basicaly the core of the console, with windows being a host only for most of the time... :)


Recommended Answers

All 3 Replies

You can recreate the MessageDlg by using your own (new) form, so you have complete control over it.

Will try that, yes... thanks for the hint.

This one was solved using default to "No" answer, and setting property "Can close" to false. Forgot to mention... No need to recreate form, though! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.