如题:我想实现windows xp,2003中,当点开始菜单中的关闭计算机时,桌面的背景变成灰色,并且任何操作都无效。请问怎么实现。
解决方案 »
- delphi中请问在form的大小发生变化的时候怎么让form上控件的位置也随之自动调整大小?谢谢
- CnPack开发组2007年上半年度工作总结
- 奇怪的abort问题!
- 【致斑竹/大斑竹】我怎么进不去 delphi基础类, vcl, database三个小论坛???
- 这样的错误,有人知道是怎么一回事吗?
- 关于鼠标移到和移出TPanel的事件!
- 怎样将panel上所有的label和image等--保存为一幅完整的图片(当然是panel大小)?苦思瞑想毛渐少!!!
- 早回复 早揭贴-----------?
- 诚聘兼职:IC卡读写
- 一个女程序员的烦恼
- 在Excel導入Access過程中 出現了問題
- sql语句出错,求救。
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; //ÏûϢʱ¼ä´Á
dwExtraInfo: DWORD; //ºÍÏûÏ¢Ïà¹ØµÄÀ©Õ¹ÐÅÏ¢
end;
KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;
//Õâ¸öÊǵͼ¶¼üÅ̹³×ÓµÄË÷ÒýÖµ£¬DelphiÖÐûÓУ¬±ØÐë×Ô¼º¶¨Òå
const WH_KEYBOARD_LL = 13;
//¶¨ÒåÒ»¸ö³£Á¿ºÃºÍÉÏÃæÄǸö½á¹¹ÖеÄflags±È½Ï¶øµÃ³öAlt¼üÊÇ·ñ°´ÏÂ
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ֵΪHC_ACTIONʱ±íʾWParamºÍLParam²ÎÊý°üº¬ÁË°´¼üÏûÏ¢
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
//ÉèÖõͼ¶¼üÅ̹³×Ó
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.
Left = 343
Top = 297
BorderStyle = bsNone
Caption = 'ÊäÈë'
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 = 'ÊäÈë: '
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 = 'È·¶¨'
Color = 15785170
HotTrack = True
TabOrder = 1
OnClick = btn_okClick
Glyph.Data = {
36030000424D3603000000000000360000002800000010000000100000000100
1800000000000003000000000000000000000000000000000000C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C000BA3CC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000BA3C00BA3C00BA3CC0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C000BA3C00BA3C00BA3C00BA3C00BA3CC0C0C0C0C0C0C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C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0}
end
object btn_cancle: TRzBitBtn
Left = 168
Top = 72
ModalResult = 2
Caption = 'È¡Ïû'
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