WINAPI System Modal

Programming, for all ages and all languages.
Post Reply
Xqzzy Rcxmcq

WINAPI System Modal

Post by Xqzzy Rcxmcq »

Can somebody give me the function name for the System Modal function in the Windows API?
Thanks.
Tim

Re:WINAPI System Modal

Post by Tim »

Assuming you mean "how do I create a system modal dialog in Win32?", you can't.
Xqzzy Rcxmcq

Re:WINAPI System Modal

Post by Xqzzy Rcxmcq »

Well, I'm just talking about a standard Visual Basic form. Not a dialog box.
Tim

Re:WINAPI System Modal

Post by Tim »

Same thing. What are you trying to achieve?
ark

Re:WINAPI System Modal

Post by ark »

What Tim is saying is that Microsoft removed the ability to create system modal windows starting with Windows 95, so that no application could hold up the entire system. The "system modal" that currently exists essentially is just a setting for the window to always stay on top (WS_EX_TOPMOST is the style, IIRC).

Having explained that, it goes back to Tim's question of what you are trying to achieve. System modal is generally undesirable for the user, and it was really intended to provide absolutely critical information to the user. If you tell us what you are trying to do, we might be able to give you some better alternatives.
Xqzzy Rcxmcq

Re:WINAPI System Modal

Post by Xqzzy Rcxmcq »

I want the user to not be able to have the window lose the focus. Also, the user cannot click Start, etc. on the taskbar. This is a computer locking program that requires a password to unlock the system.

Thanks.
Tim

Re:WINAPI System Modal

Post by Tim »

Depending on the type of Windows you're using, you can't completely lock the system. On any version of Windows you'll be able to press Ctrl+Alt+Del. On Win95/98/Millenium this brings up a dialog where you can kill your lock program. On NT/2000/XP you get the Windows Security dialog where you can run Task Manager and do pretty much whatever you like.

If you are running on one of the NT operating systems, you should use the normal Lock Computer function to lock the computer. This will require you to enter the logged-on user's password to continue, and you can do this through your program by calling LockWorkStation.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:WINAPI System Modal

Post by Candy »

Xqzzy Rcxmcq wrote: I want the user to not be able to have the window lose the focus. Also, the user cannot click Start, etc. on the taskbar. This is a computer locking program that requires a password to unlock the system.

Thanks.
obvious answer:

Code: Select all

Window::LostFocus() {
   this->setFocus();
}
otherwise, the official ways (see Tim's reply)(.
ark

Re:WINAPI System Modal

Post by ark »

I don't believe that takes care of Tim's point that there is always Ctrl+Alt+Delete.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:WINAPI System Modal

Post by Candy »

Joel wrote: I don't believe that takes care of Tim's point that there is always Ctrl+Alt+Delete.
Windows is by design incapable of letting a simple application take over the system. It would make for quite a security risk (imagine a virus that takes over your corporate computer and won't let you access it until you pay the author $10). Don't try to make something like that, or use the win32 system calls to do it (if you register in some special way it might be possible. Don't think so though).
Tim

Re:WINAPI System Modal

Post by Tim »

One of the Windows design points is "The user is always in control of their computer". So the user is always able to kill misbehaving applications (given the right permissions -- by default, an unprivileged user can only kill their own processes).
sonneveld

Re:WINAPI System Modal

Post by sonneveld »

Tim Robinson wrote: One of the Windows design points is "The user is always in control of their computer".
Thank God for DRM then hey?

- Nick
Post Reply