View Full Version : Lock Screen

6th July 2010, 17:12
I want to make a lock screen like the one Windows does when u log off.
A full screen which u cannot minimize or close or switch to other applications. just normal lock screen.
any API's, ideas or any guides?

6th July 2010, 19:07
This is going to be completely different depending on the targetted OS and your requirements. Do you want to block ALT+F4? How about ALT+TAB or WindowsKey+TAB (Vista and above), or WindowsKey+D, etc?

Maybe immitating a screen saver would be the way to go, as in SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);

I've no idea about Linux or Mac though.

6th July 2010, 19:13
thanks for replying

1- my target is Windows
2- yes I want to disable all the keys you mentioned
3- I will try ur advice and give u feedback

9th July 2010, 18:54
I didn't get any luck about immitating screen saver

any help ? I want to implement a custom full screen widget that locks the screen

9th July 2010, 20:34
Which is what a screen saver does.

Which part of you struggling with?

9th July 2010, 20:49
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);

I don't understand where to find this !!

no info in the docs

9th July 2010, 23:54
It's an OS specific function, as stated.


10th July 2010, 11:22
thanks alot for help,

I tried to set the parameter as u told me but the method returns false:

bool prevState=0;
bool result;

result=SystemParametersInfo(SPI_SETSCREENSAVERRUNN ING, TRUE, &prevState, 0);

but i get result = false

I am working on Windows 7

10th July 2010, 12:27
Did you call GetLastError to find out why? http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx

10th July 2010, 13:33
thanks again, I think it's a compatibility issue, so I decided to change the strategy.

now I have a screen that I disabled close events for it, set it to full screen, working well.

the only problem now is to disable the (alt + tab ) combination or any key combination that lets the OS raise another application on the top.

can I do that using event catching?

10th July 2010, 18:30
No, as it's another system function.

Its doubtful it's a compatibility issue, more likely to be that your application has insufficient priviledges to execute the stated command on Windows 7. You would probably have to request administrative priviledges (or at least, elevated priviledges) in your applications manifest.

10th July 2010, 21:40
You could try grabbing the keyboard and mouse, I don't know if that overrides the system hotkeys but you can try it. But still your application could be closed/deactivated by another software. It would be good if you said why you need this functionality.

11th July 2010, 04:57
I need this functionality because my application should prevent kids at certain times from continuing sitting on the PC , so it will show the lock screen at these times and have a password that is different from the Windows account password.

11th July 2010, 09:29
Why reinvent the wheel? Can't you use the parental control facilities built into Windows? The moment the kids learn what Ctrl+Alt+Del does, your app will be useless. And kids learn fast these days :)

11th July 2010, 10:42
Ctrl+Alt+Del will fail in showing the apps list as I said in the other topic :)
If u have any material that show me how using the parental control facilities, please tell me.

11th July 2010, 10:48
As a starting point: http://msdn.microsoft.com/en-us/library/ms711682%28v=VS.85%29.aspx or a real c++ sample: http://msdn.microsoft.com/en-us/library/ms711674%28v=VS.85%29.aspx

11th July 2010, 10:55
Thank u, I will start reading