//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <windows.h>
#include "LockMain.h"
#include "../../dwlcore.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall LockWindows(int disable)
{
  // disables desktop items
  wlDisableItem(wlTaskTray,disable);
  wlDisableItem(wlDesktop,disable);
  wlDisableItem(wlTaskLinks,disable);
  wlDisableItem(wlStartbutton,disable);

  // find handles for task bar and start button
  HWND hTaskBar     = FindWindowEx(0, 0, "Shell_TrayWnd",NULL);
  // HWND hStartButton = FindWindowEx(hTaskBar, 0, "Button",NULL);
  HWND hProgman     = FindWindowEx(0, 0, "Progman",NULL);


  wlDisableKey(0,0,MOD_WIN,disable);              // disables all WIN keys
  wlDisableKey(0,VK_ESCAPE, MOD_CONTROL,disable);
  wlDisableKey(0,VK_F4, MOD_ALT,disable);
  // wlDisableKey(0,VK_TAB, MOD_ALT,disable);
  // wlDisableKey(0,VK_ESCAPE, MOD_ALT,disable);

  // disables all keys for program manager (desktop)
  wlDisableKey(hProgman,0,MOD_ALL,disable);

  // disables all keys (mouse buttons included) for task bar
  wlDisableKey(hTaskBar,0, MOD_ALL,disable);

 /* statement above includes all following "disables"
    // disables start button
    wlDisableKey(hStartButton,VK_LBUTTON, MOD_ALL,disable);
    wlDisableKey(hStartButton,VK_RBUTTON, MOD_ALL,disable);

    wlDisableKey(hTaskBar,0, MOD_ALT,disable);
    wlDisableKey(hTaskBar,VK_F3, MOD_ALL,disable);
    wlDisableKey(hTaskBar,VK_RBUTTON,MOD_ALL,disable);
    wlDisableKey(hTaskBar,VK_APPS, MOD_ALL,disable);
  */

  //if wlIsGinaInstalled = 1 then          // only if dwlgina is installed
    wlDisableKey(0,VK_DELETE,MOD_CONTROL | MOD_ALT,disable); // disables Ctrl+Alt+Del
}


void __fastcall TForm1::Button1Click(TObject *Sender)
{
  wlDisableKey(0,VK_F1,0,1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::bLockClick(TObject *Sender)
{
  LockWindows(1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::bUnlockClick(TObject *Sender)
{
  // LockWindows(0) also possble
  wlRestoreAll();
}

//---------------------------------------------------------------------------

