end;
end;
WM_NCLBUTTONDOWN,WM_NCLBUTTONDBLCLK:
begin
Result := CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);
with TWMNCLButtonDown(message) do
if not HitButton(Point(XCursor, YCursor)) then Exit;
if WParam = 888 then
begin
FButtonDown := True;
Repaint;
SetCapture(FForm.Handle);
end;
end;
WM_NCRBUTTONDOWN,WM_NCRBUTTONDBLCLK:
begin
if WParam = 888 then
begin
if Assigned(FPopup) then
begin
p.x := FForm.Left + BoundsRect.Left;
p.y := FForm.Top + BoundsRect.Bottom;
FPopup.Popup(p.x,p.y);
end;
end
else
Result:=CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);
end;
WM_NCLBUTTONUP,WM_LBUTTONUP :
begin
if FButtonDown then
begin
FButtonDown := False;
RePaint;
ReleaseCapture;
if Assigned(FOnClick) then FOnClick(self);
end
else
Result:=CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);
end;
else
Result := CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);
end;
end
else
Result := CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);
end;
end;
procedure TTitleBarButton.SetGlyph(const Value: TBitmap);
begin
FGlyph.Assign(Value);
SendMessage(FForm.Handle,WM_NCACTIVATE,0,0);
end;
procedure TTitleBarButton.SetRightMargin(const Value: Cardinal);
begin
FRightMargin := Value;
SendMessage(FForm.Handle,WM_NCACTIVATE,0,0);
end;
procedure TTitleBarButton.SetVisible(const Value: Boolean);
begin
FVisible := Value;
SendMessage(FForm.Handle,WM_NCACTIVATE,0,0);
end;
procedure TTitleBarButton.Notification(Component: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (Component = FPopup) then
FPopup := nil;
end;
function TTitleBarButton.GetBoundsRect: TRect;
var
Rec: TRect;
FrameThick: Integer; //窗体框架厚度