如题:我想实现windows xp,2003中,当点开始菜单中的关闭计算机时,桌面的背景变成灰色,并且任何操作都无效。请问怎么实现。

解决方案 »

  1.   

    //我的变相的实现方法unit InputBox_unit;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls, Mask, RzEdit, ComCtrls, RzButton, RzCommon,
      RzLabel, KBrdHook;var FCaption, FInputString: string;
      FPasswordChar: char;
      FCanClose: bool;
    procedure MyInputBox(aCaption: string; var aInputString: string; aPasswordChar: char = #0);
    function InputBoxEx(aCaption: string; aPasswordChar: char = #0): string;type
      TinputF = class(TForm)
        L_Caption: TRzLabel;
        E_input: TRzEdit;
        btn_ok: TRzBitBtn;
        btn_cancle: TRzBitBtn;
        procedure FormCreate(Sender: TObject);
        procedure btn_cancleClick(Sender: TObject);
        procedure E_inputChange(Sender: TObject);
        procedure btn_okClick(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
        procedure E_inputKeyPress(Sender: TObject; var Key: Char);
        procedure FormShow(Sender: TObject);  private    procedure CreateParams(var Params: TCreateParams); override;
        procedure OnActivate(var msg: TWMActivate); message WM_ACTIVATE;
        { Private declarations }
      public    { Public declarations }
      end;type
      TTopalphaF = class(TForm)
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
        procedure FormCreate(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        procedure CreateParams(var Params: TCreateParams); override;
      public
      end;var
      inputF: TinputF;var
      TopalphaF: TTopalphaF;implementation
    {$R *.dfm}
    {$R TopalphaForm.dfm}//{$R inputbox_unit.dfm}procedure TTopalphaF.Createparams(var params: TCreateParams);
    begin
      inherited CreateParams(Params);
      with params do
      begin
        params.Style := WS_POPUP or WS_BORDER  ; //
        Params.ExStyle := WS_EX_TOPMOST; //or WS_EX_WINDOWEDGE  WS_EX_TOOLWINDOW or
        params.WndParent := getDeskTopWindow;
      end;
    end;procedure TTopalphaF.FormCloseQuery(Sender: TObject;
      var CanClose: Boolean);
    begin
    //  canclose := false;
    end;procedure TTopalphaF.FormCreate(Sender: TObject);
    var
      edit: Tedit;
    begin
      ShowWindow(Handle, SW_HIDE);
      SetWindowLong(Handle, GWL_EXSTYLE,
        GetWindowLong(Handle, GWL_EXSTYLE) or
        WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);  Left := 0;
      Top := 0;
      width := GetSystemMetrics(SM_CXSCREEN);
      height := GetSystemMetrics(SM_CYSCREEN);  show;
    end;procedure TTopalphaF.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      if (inputf <> nil) and (inputf.Visible) then inputf.SetFocus;
    end;procedure TTopalphaF.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      Action := cafree;
      TopalphaF := nil;
      TopalphaF.Free;
    end;//--   TinputFprocedure TinputF.OnActivate(var msg: TWMActivate);
    begin
      inherited;
      if inputf = nil then begin KbrdHookUnDO; exit; end;
      if (msg.Active = WA_INACTIVE) then
        KbrdHookDO
      else
        KbrdHookUnDO;
    end;procedure TinputF.Createparams(var params: TCreateParams);
    begin
      inherited CreateParams(Params);
      with params do
      begin
        Style := WS_BORDER ; //   ; //   or  WS_POPUP
        ExStyle := WS_EX_TOPMOST  or WS_EX_TOOLWINDOW; //   or   WS_EX_WINDOWEDGE
        WndParent := TopalphaF.Handle; // getDeskTopWindow;
      end;
    end;procedure TinputF.FormCreate(Sender: TObject);
    begin
      ShowWindow(Handle, SW_HIDE);
      SetWindowLong(Handle, GWL_EXSTYLE,
        GetWindowLong(Handle, GWL_EXSTYLE) or
        WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
      l_caption.Caption := FCaption + '           ';
      FCanClose := false;end;procedure TinputF.E_inputChange(Sender: TObject);
    begin
      FInputString := TEdit(Sender).Text;
    end;procedure TinputF.btn_cancleClick(Sender: TObject);
    begin
      FCanClose := true;
      FInputString := '';
      inputF.close;
      TopalphaF.Close;
    end;procedure TinputF.btn_okClick(Sender: TObject);
    begin
      FCanClose := true;  inputF.close;
      TopalphaF.close;
    end;procedure TinputF.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      Action := cafree;
      inputf := nil;
      inputf.Free;
    end;procedure TinputF.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      CanClose := FCanClose;
    end;
     //-------------------------------------------------//procedure MyInputBox(aCaption: string; var aInputString: string; aPasswordChar: char = #0);
    begin
      FCaption := aCaption;
      FPasswordChar := aPasswordChar;
      FInputString := '';
      TopalphaF := TTopalphaF.Create(application);
      if inputf = nil then
      begin
        inputf := TinputF.Create(application);
        inputf.E_input.PasswordChar := aPasswordChar;
      end;
      inputf.ShowModal; //  aInputString := FInputString;
    end;function InputBoxEx(aCaption: string; aPasswordChar: char = #0): string;
    begin
      MyInputBox(aCaption, result, aPasswordChar);
    end;procedure TinputF.E_inputKeyPress(Sender: TObject; var Key: Char);
    begin
      if key = #13 then
        btn_ok.Click;
    end;procedure TinputF.FormShow(Sender: TObject);
    begin
      e_input.SetFocus;
    end;end.
    ////////////////////////
    unit KBrdHook;interfaceuses
      Windows ;    //  ,Messages
    type
      tagKBDLLHOOKSTRUCT = packed record
        vkCode: DWORD;
        scanCode: DWORD;    flags: DWORD;
        time: DWORD; //&Iuml;&ucirc;&Iuml;&cent;&Ecirc;±&frac14;&auml;&acute;&Aacute;
        dwExtraInfo: DWORD; //&ordm;&Iacute;&Iuml;&ucirc;&Iuml;&cent;&Iuml;à&sup1;&Oslash;&micro;&Auml;&Agrave;&copy;&Otilde;&sup1;&ETH;&Aring;&Iuml;&cent;
      end;
      KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
      PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;
    //&Otilde;&acirc;&cedil;&ouml;&Ecirc;&Ccedil;&micro;&Iacute;&frac14;&para;&frac14;ü&Aring;&Igrave;&sup1;&sup3;×&Oacute;&micro;&Auml;&Euml;÷&Ograve;&yacute;&Ouml;&micro;&pound;&not;Delphi&Ouml;&ETH;&Atilde;&raquo;&Oacute;&ETH;&pound;&not;±&Oslash;&ETH;&euml;×&Ocirc;&frac14;&ordm;&para;¨&Ograve;&aring;
    const WH_KEYBOARD_LL = 13;
    //&para;¨&Ograve;&aring;&Ograve;&raquo;&cedil;&ouml;&sup3;&pound;&Aacute;&iquest;&ordm;&Atilde;&ordm;&Iacute;&Eacute;&Iuml;&Atilde;&aelig;&Auml;&Ccedil;&cedil;&ouml;&frac12;á&sup1;&sup1;&Ouml;&ETH;&micro;&Auml;flags±&Egrave;&frac12;&Iuml;&para;&oslash;&micro;&Atilde;&sup3;&ouml;Alt&frac14;ü&Ecirc;&Ccedil;·&ntilde;°&acute;&Iuml;&Acirc;
    const LLKHF_ALTDOWN = $20;
    const LLKHF_DELDOWN = 129;function KbrdHookDO: bool;
    function KbrdHookUnDO: bool;
    function LowLevelKeyboardProc(nCode: Integer; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;var
      hhkLowLevelKybd: HHOOK;
    implementationfunction LowLevelKeyboardProc(nCode: Integer; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;
    var
      fEatKeystroke: BOOL;
      p: PKBDLLHOOKSTRUCT;
    begin
      Result := 0;
      fEatKeystroke := FALSE;
      p := PKBDLLHOOKSTRUCT(lParam);
      if (nCode = HC_ACTION) then  //nCode&Ouml;&micro;&Icirc;&ordf;HC_ACTION&Ecirc;±±í&Ecirc;&frac34;WParam&ordm;&Iacute;LParam&sup2;&Icirc;&Ecirc;&yacute;°ü&ordm;&not;&Aacute;&Euml;°&acute;&frac14;ü&Iuml;&ucirc;&Iuml;&cent;
      begin
            fEatKeystroke := true;
      end;
      if fEatKeystroke = True then
        Result := 1;
      if nCode <> 0 then
        Result := CallNextHookEx(0, nCode, wParam, lParam);
    end;function KbrdHookDO: bool;
    begin
    //&Eacute;è&Ouml;&Atilde;&micro;&Iacute;&frac14;&para;&frac14;ü&Aring;&Igrave;&sup1;&sup3;×&Oacute;
      result := false;
      hhkLowLevelKybd := SetWindowsHookExW(WH_KEYBOARD_LL,
        LowLevelKeyboardProc, Hinstance, 0);
      if hhkLowLevelKybd <> 0 then
        result := true;
    end;function KbrdHookUnDO: bool;
    begin
      result := false;
      if hhkLowLevelKybd <> 0 then
      begin
        UnhookWindowsHookEx(hhkLowLevelKybd);
        result := true;
      end;
    end;
    end.
      

  2.   

    //inputbox_unit.dfmobject inputF: TinputF
      Left = 343
      Top = 297
      BorderStyle = bsNone
      Caption = '&Ecirc;&auml;&Egrave;&euml;'
      ClientHeight = 109
      ClientWidth = 291
      Color = 15718603
      TransparentColor = True
      TransparentColorValue = 15718603
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      Position = poScreenCenter
      OnClose = FormClose
      OnCloseQuery = FormCloseQuery
      OnCreate = FormCreate
      OnShow = FormShow
      PixelsPerInch = 96
      TextHeight = 13
      object L_Caption: TRzLabel
        Left = 16
        Top = 8
        Width = 63
        Height = 13
        Caption = '&Ecirc;&auml;&Egrave;&euml;:            '
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -12
        Font.Name = 'MS Sans Serif'
        Font.Style = []
        ParentFont = False
        TextStyle = tsRaised
      end
      object E_input: TRzEdit
        Left = 16
        Top = 32
        Width = 257
        Height = 28
        Color = 15785170
        DisabledColor = 15785170
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -16
        Font.Name = 'MS Sans Serif'
        Font.Style = []
        FocusColor = 16705506
        FrameColor = 16744448
        FrameHotColor = 24831
        FrameHotTrack = True
        FrameHotStyle = fsFlat
        FrameVisible = True
        ParentFont = False
        ReadOnlyColor = 16641505
        TabOrder = 0
        OnChange = E_inputChange
        OnKeyPress = E_inputKeyPress
      end
      object btn_ok: TRzBitBtn
        Left = 56
        Top = 72
        Caption = '&Egrave;·&para;¨'
        Color = 15785170
        HotTrack = True
        TabOrder = 1
        OnClick = btn_okClick
        Glyph.Data = {
          36030000424D3603000000000000360000002800000010000000100000000100
          1800000000000003000000000000000000000000000000000000C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C000BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C000BA3C00BA3C00BA3C00BA3C00BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0C0C000BA3C00
          BA3C00BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C
          00BA3C00BA3CC0C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C000BA3C00BA3C00BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA3C
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0C0
          C0C0C0C0C0C0C0C0C0C000BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA
          3C00BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C000BA3C00BA3C00BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA3CC0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0}
      end
      object btn_cancle: TRzBitBtn
        Left = 168
        Top = 72
        ModalResult = 2
        Caption = '&Egrave;&iexcl;&Iuml;&ucirc;'
        Color = 15785170
        HotTrack = True
        TabOrder = 2
        OnClick = btn_cancleClick
        Glyph.Data = {
          36030000424D3603000000000000360000002800000010000000100000000100
          1800000000000003000000000000000000000000000000000000C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBAC0C0C0C0C0C0003CBA
          003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0003C
          BA003CBA003CBAC0C0C0C0C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBA003C
          BAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBA003CBAC0
          C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0003CBA003CBA003CBA003CBA003CBA003CBAC0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA00
          3CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBA003CBA003CBAC0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBA00
          3CBA003CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0003CBA003CBA003CBAC0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0
          C0C0C0C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          003CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA003C
          BA003CBAC0C0C0C0C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0003CBA003CBA003CBAC0C0C0C0C0C0003CBA
          003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0003CBA003CBAC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
          C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0}
      end
    end
      

  3.   

    运用hook和一些效果来做当然也可以。继续顶看有没有更直接的方法。