W
wengang16
Unregistered / Unconfirmed
GUEST, unregistred user!
我用下面的语句做了一个透明的Panel,然后在panel上放了一个Button和一个Label,单击Button时,使得Label移动;虽然Panel是透明了,并且Label也可以移动,但移动Label后,会在透明Panel上显示灰色的轨迹背景,这个灰色轨迹背景我想去掉。麻烦高人指点一下,小第万分感谢!
Panel1.ControlStyle := Panel1.ControlStyle - [csOpaque];
SetWindowLong(Panel1.Handle, GWL_EXSTYLE, GetWindowLong(Panel1.Handle, GWL_EXSTYLE) OR WS_EX_TRANSPARENT);
SetWindowLong(Panel1.Parent.Handle, GWL_STYLE, GetWindowLong(Panel1.Parent.Handle, GWL_STYLE) and not WS_CLIPCHILDREN);
FOldProc := SetWindowLong(Panel1.Handle, GWL_WNDPROC, Longint(@NewWindowProc));
function NewWindowProc(hHwnd, Msg, wParam, lParam: LongWORD): Longint;
stdcall;
var
FoundStyle: TBrushStyle;
R: TRect;
begin
Case Msg of
WM_ERASEBKGND:
Result := 1;
else
CallWindowProc(Pointer(FOldProc), hHwnd, Msg, wParam, lParam);
end;
end;
Panel1.ControlStyle := Panel1.ControlStyle - [csOpaque];
SetWindowLong(Panel1.Handle, GWL_EXSTYLE, GetWindowLong(Panel1.Handle, GWL_EXSTYLE) OR WS_EX_TRANSPARENT);
SetWindowLong(Panel1.Parent.Handle, GWL_STYLE, GetWindowLong(Panel1.Parent.Handle, GWL_STYLE) and not WS_CLIPCHILDREN);
FOldProc := SetWindowLong(Panel1.Handle, GWL_WNDPROC, Longint(@NewWindowProc));
function NewWindowProc(hHwnd, Msg, wParam, lParam: LongWORD): Longint;
stdcall;
var
FoundStyle: TBrushStyle;
R: TRect;
begin
Case Msg of
WM_ERASEBKGND:
Result := 1;
else
CallWindowProc(Pointer(FOldProc), hHwnd, Msg, wParam, lParam);
end;
end;