Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling start menu

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
How do I disable the start menu from coming up, (when the windows buttons are pressed)?

I've got a program that's supposed to lock the computer and it does everything but for some reason, I can't prevent the windows buttons from bringing up the start menu. I've tried to do a KeyPreview and when the user presses the start menu button, make it NULL but that didn't work. Any suggestions?

And also, How do I disable ALT+TAB in my app? Thanks!

Cyprus Cyprus
 
you can make call the SystemParametersInfo api.
there is a flag that signals that the screensaver is running, all the windows keys are disabled when the screensaver is active.
 
tried that. it's on windows 2K and I guess those 2 aren't compatible Cyprus
 
There must be a way to make this api work, otherwise all old screensavers do not work anymore on win2k.

I do not have a win2k pc at home and you have triggered my interest :)

is this extract of the dr gui pages of any help ?


Don't Forget the Sun Screen Saver
Dear Dr. GUI,
I would like my application to execute a function if and when the screen saver starts. I have been searching for a way for my program to know that the screen saver has started but the only thing I could find was SystemParametersInfo() used with the SPI_GETSCREENSAVERRUNNING action. However, this is only available for NT 5.0 or Windows 98, and I need it for NT 4.0 and Windows 95. Can I actually get this to happen?

Thanks,

Richard May

Dr. GUI replies:
Personally, Dr. GUI would like an application to execute a function that automatically transports him to an unpopulated beach on Maui, rubs sunscreen on his back, brings him a Mai Tai, and helps him lose 30 pounds. But the good doctor isn't holding his breath.

Well, at least Dr. GUI can help you with your problem.

Here's a bit of info to get you started.

When Screen Saver starts, it posts a WM_SYSCOMMAND message. So, a global WH_GETMESSAGE hook can be installed as below. Since our goal is to give applications an easy way to know when the screen saver is about to start, we'll use a user-defined registered window message called "Screen_Saver_Starting"—so therefore we have to register that message.

UINT WM_SCRNSVSTART = RegisterWindowMessage("Screen_Saver_Starting");
hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc,
(HINSTANCE) hMod, 0);

Don't forget to uninstall the hook when by calling UnhookWindowsHookEx before you exit.

Then, in your hook procedure (you can call it anything, we called it HookProc), you can filter on the WM_SYSCOMMAND message with wParam equal to SC_SCREENSAVE:

LRESULT CALLBACK HookProc(UINT code , WPARAM wParam, LPARAM lParam)
{
MSG *msg = (MSG *)lParam;
if ( msg->message == WM_SYSCOMMAND &&
msg->wParam == SC_SCREENSAVE)
{ // broadcast message to all top-level windows
// you could do other things here, too
PostMessage(HWND_BROADCAST, WM_SCRNSVSTART, 0, 0);
}
// Always call next hook in chain (if any)
return CallNextHookEx(hHook, code, wParam, lParam);
}

This code posts a "Screen_Saver_Starting" registered message to all top-level windows. You could replace the PostMessage call with code to start an executable or do some other function.

To handle this message, your app would call RegisterWindowMessage in its initialization code and then handle the message in the window procedure for a top-level window. An MFC app would use the ON_REGISTERED_MESSAGE message map macro in a top-level window's message map.

 
That didn't work for me. I worked with it for hours trying to revertse it so you could tell windows that the screen saver was running but it didn't like that at all...
anything else?

I'm telling it that the screen saver is running, but for some reason it's not acknowledging. It's got to be something to do with windows 2000. I don't know... Cyprus
 
Look at for trapping the screen saver.

Look for my post called "Taking control" a while back, it MAY have some info to help you.

When you disable the scr with systemparametersinfo, the windows key doesn't work, but this only works in 9x so it won't help you... [Thanks in advance|Hope I helped you]
Exodus300
World-Wide Alliance of Evil and Twisted People
[red]"Experimentation by Example is the best learning tool" - Exodus300[/red]
Code:
if (pop_tarts == 0)
{
   tantrum = 1;
}
[pc3]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top