Is it possible to make the main form of an application system modal? My application will FTP a file from a remote company PC. Users should not be allowed to interact with the desktop while this process is in progress.
Application.MainFormOnTaskbar := True;
Application.ShowMainForm := False;
...
FormChild.ShowModal;
Create your own desktop using
CreateDesktop()
(and create a status window to display on it), then useOpenDesktop()
to retreive the user's desktop, then switch between them usingSwitchDesktop()
when the file transfer begins and ends. While your custom desktop is active, the user cannot access his/her desktop (the screensaver does exactly this, for instance).As other answers mention that you want to do is difficult to comprehend as modal form's purpose is to disable all application forms below so basically application form might be considered a modal form itself.
Although if you wish to make your application the only receiver of focus on current windows desktop (possibly non-administrative user desktop), you need to:
With new versions of windows you can do all of that as non-priviledged user, except Ctrl+Alt+Del combination using global window hooks.
You can also set "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe" registry key value to some dummy text, to disable task manager (including Ctrl+Shift+Esc combination).
It doesn't make sense to make the main form modal. Indeed, if you have an ordinary application with a (normal) main form, and then displays a modal form (e.g. a dialog box, or a
TOpenDialog
), then the "modality" means that the main form, and the rest of your application, becomes "disabled" until the modal form is closed. (But other applications aren't affected at all by this.) But this doesn't make sense for the main form, because when the main form is shown, there is no "rest" of your application to disable. In fact, a normal main form is in a sense already modal, if you do not open any other forms.I think that you wish to create a system modal form, that is, a form that disables the rest of the desktop when shown. But this isn't too easy to do, because of the security principles of modern versions of the Microsoft Windows operating system. Indeed, a single application isn't (normally) supposed to take control over the entire OS like this.
If you want to take over the user's desktop and prevent them from using their computer, you could use dWinLock.