Changeset 23 for branches/Xvcl/Xvcl.Forms.pas
- Timestamp:
- May 8, 2013, 1:52:33 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Xvcl/Xvcl.Forms.pas
r22 r23 8 8 type 9 9 TForm = class(TWinControl) 10 private 11 FFocused: Boolean; 12 procedure SetFocused(const Value: Boolean); 10 13 protected 11 14 function GetVideoDevice: TVideoDevice; override; 12 15 public 16 const 17 TitleBarHeight = 24; 18 var 13 19 Screen: TObject; // TScreen; 14 20 Caption: string; 21 function HandleMessage(Message: TMessage): Boolean; override; 15 22 procedure Paint; override; 23 property Focused: Boolean read FFocused write SetFocused; 16 24 end; 17 25 … … 50 58 end; 51 59 60 function TForm.HandleMessage(Message: TMessage): Boolean; 61 var 62 TitleBarBounds: TRectangle; 63 begin 64 Result := False; 65 if Message is TMessageMouseDown then 66 with TMessageMouseDown(Message) do begin 67 TitleBarBounds := TRectangle.Create(0, 0, Bounds.Width, TitleBarHeight); 68 if TitleBarBounds.Contains(ScreenToClient(Position)) then begin 69 Focused := True; 70 Result := True; 71 Move.StartControlPos := Bounds.TopLeft; 72 Move.StartMousePos := Position; 73 Move.Active := True; 74 end; 75 end else 76 if Message is TMessageMouseUp then 77 with TMessageMouseUp(Message) do begin 78 Move.Active := False; 79 end else 80 if Message is TMessageMouseMove then 81 with TMessageMouseUp(Message) do begin 82 if Move.Active then begin 83 Bounds.TopLeft := Move.StartControlPos + (Position - Move.StartMousePos); 84 TScreen(Screen).Paint; 85 end; 86 end; 87 if not Result then inherited; 88 end; 89 52 90 procedure TForm.Paint; 53 const54 TitleBarHeight = 24;55 91 begin 56 inherited;57 92 with Canvas do begin 93 Canvas.Brush.Color := clWhite; 94 Canvas.FillRect(TRectangle.Create(0, TitleBarHeight, Size.X, Size.Y)); 95 if Focused then Brush.Color := clLightBlue else 96 Brush.Color := clSilver; 97 FillRect(TRectangle.Create(0, 0, Bounds.Width - 1, TitleBarHeight)); 58 98 MoveTo(TPoint.Create(0, 0)); 59 99 LineTo(TPoint.Create(Bounds.Width - 1, 0)); … … 66 106 (TitleBarHeight - GetTextSize(Caption).Y) div 2), Caption); 67 107 end; 108 inherited; 109 end; 110 111 procedure TForm.SetFocused(const Value: Boolean); 112 begin 113 FFocused := Value; 114 Paint; 68 115 end; 69 116
Note:
See TracChangeset
for help on using the changeset viewer.