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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Full-Screen Mode App with NoClose Property

Status
Not open for further replies.

NormRumac

Programmer
Sep 4, 2003
41
0
0
CA
Hi. I wanted to develop an application that has these two properties:

1. Full-Screen Mode: Application Window Occupies the full screen, so users are unaware of the bacground desktop environment.

2. No Close Button: I dont want my window to have the little 'X' on the top right corner of the window (i.e. I dont want users trying to shutdown the application).

I assume accomplishing #1, will help me accomplish #2.

Thanks,
--Norm
 
The following code shows how to make full screen window. Basically a POPUP style window, so no 'x' button because no title bar. The style CS_NOCLOSE means that Alt+F4 doesn't work either.
Code:
#include <windows.h>

int InitWindow (HINSTANCE);
long CALLBACK wndproc (HWND,UINT,WPARAM,LPARAM);


int WINAPI WinMain(HINSTANCE hInst,
                   HINSTANCE hPrev,
                   LPSTR cmd,
                   int show)
{
  MSG msg;

  InitWindow(hInst);

  while (GetMessage(&msg, 0, 0, 0 ))
  {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return 0;
}

int InitWindow (HINSTANCE hinst)
{
  WNDCLASS wc;
  POINT scr;

  wc.cbClsExtra = 0;
  wc.cbWndExtra = 0;
  wc.hbrBackground = CreateSolidBrush(0x00ffffff);
  wc.hCursor = LoadCursor(0, IDC_ARROW);
  wc.hIcon = LoadIcon(0, IDI_EXCLAMATION);
  wc.hInstance = hinst;
  wc.lpfnWndProc = wndproc;
  wc.lpszClassName = &quot;ScreenWin&quot;;
  wc.lpszMenuName = 0;
  wc.style = CS_NOCLOSE;

  if (!RegisterClass(&wc))
  {
    MessageBox(0,&quot;RegisterClass failed !&quot;, &quot;Error&quot;, MB_OK);
    return 1;
  }
	
  scr.x = GetSystemMetrics(SM_CXSCREEN);
  scr.y = GetSystemMetrics(SM_CYSCREEN);

  HWND hwnd = CreateWindow(&quot;ScreenWin&quot;,&quot;ScreenWin&quot;,
       WS_POPUP,0,0,scr.x,scr.y,0,0,hinst,0);
		
  if (!hwnd)
  {
    MessageBox(0,&quot;CreateWindow failed !&quot;, &quot;Error&quot;, MB_OK);
    return 1;	
  }

  ShowWindow(hwnd, SW_SHOW);
  return 0;
}


long CALLBACK wndproc (HWND hwnd,
                       UINT msg,
                       WPARAM wpar,
                       LPARAM lpar)
{
  return DefWindowProc(hwnd,msg,wpar,lpar);
}
Hope its useful. :)

Don't hate the player - hate the game
 
Thanks for the help guys. I'll give that a try. And the way I'm going to prevent users from closing via Ctl-Alt-Del is by removing the task manager for any non-Administrator user. This can be accomplished through a simple registry tweak, or even easier through the Local Security Policy in gpedit.msc


Thanks,
--Norm
 
A more sophisticated way of disabling ctrl+alt+del on Windows XP is by using a Low Level Keyboard Hook function, and just filtering out the key strokes. A little more complicated to program, but can be done... :)

If you are using some other Windows, like 95/98, I believe you can cheat a little and fool Windows into thinking the ScreenSaver is on when its not. This prevents ctrl+alt+del from having any effect.

An even better way is by modifying the dll file for i/o routines ( gina.dll ? ), but this is difficult and could result in breaking the OS (yep, b.s.o.d.), so if you were ever going to attempt this, do it on someone elses computer... :)

Don't hate the player - hate the game
 
On XP and W2K AFAIK you can ONLY trap ctrl+alt+del by re-writing MSGINA.DLL - not a task for the faint-hearted. This action is by design to keep NT security intact

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
johnwm,

Just to trap Ctrl-Alt-Del, we don't have to write GINA. In other word, rewriting GINA is just one way. There are other way. Here is the article from MSDN magazine. It contains an example code to download

C++ Q&A Typename, Disabling Keys in Windows XP with TrapKeys


-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top