?? dwinctl.pas
字號:
function TDGrid.MouseUp (Button: TMouseButton; Shift: TShiftState; X, Y: Integer): Boolean;
var
acol, arow: integer;
begin
Result := FALSE;
if mbLeft = Button then begin
if GetColRow (X, Y, acol, arow) then begin
if (SelectCell.X = acol) and (SelectCell.Y = arow) then begin
Col := acol;
Row := arow;
if Assigned (FOnGridSelect) then
FOnGridSelect (self, acol, arow, Shift);
end;
Result := TRUE;
end;
ReleaseDCapture;
end;
end;
function TDGrid.Click (X, Y: integer): Boolean;
var
acol, arow: integer;
begin
Result := FALSE;
{ if GetColRow (X, Y, acol, arow) then begin
if Assigned (FOnGridSelect) then
FOnGridSelect (self, acol, arow, []);
Result := TRUE;
end; }
end;
procedure TDGrid.DirectPaint (dsurface: TDirectDrawSurface);
var
i, j: integer;
rc: TRect;
begin
if Assigned (FOnGridPaint) then
for i:=0 to FRowCount-1 do
for j:=0 to FColCount-1 do begin
rc := Rect (Left + j*FColWidth, Top + i*FRowHeight, Left+j*(FColWidth+1)-1, Top+i*(FRowHeight+1)-1);
if (SelectCell.Y = i) and (SelectCell.X = j) then
FOnGridPaint (self, j, i, rc, [gdSelected], dsurface)
else FOnGridPaint (self, j, i, rc, [], dsurface);
end;
end;
{--------------------- TDWindown --------------------------}
constructor TDWindow.Create (AOwner: TComponent);
begin
inherited Create (AOwner);
FFloating := FALSE;
FEnableFocus := TRUE;
Width := 120;
Height := 120;
end;
procedure TDWindow.SetVisible (flag: Boolean);
begin
FVisible := flag;
if Floating then begin
if DParent <> nil then
DParent.ChangeChildOrder (self);
end;
end;
function TDWindow.MouseMove (Shift: TShiftState; X, Y: Integer): Boolean;
var
al, at: integer;
begin
Result := inherited MouseMove (Shift, X, Y);
if Result and FFloating and (MouseCaptureControl=self) then begin
if (SpotX <> X) or (SpotY <> Y) then begin
al := Left + (X - SpotX);
at := Top + (Y - SpotY);
if al+Width < WINLEFT then al := WINLEFT - Width;
if al > WINRIGHT then al := WINRIGHT;
if at+Height < WINTOP then at := WINTOP - Height;
if at+Height > BOTTOMEDGE then at := BOTTOMEDGE-Height;
Left := al;
Top := at;
SpotX := X;
SpotY := Y;
end;
end;
end;
function TDWindow.MouseDown (Button: TMouseButton; Shift: TShiftState; X, Y: Integer): Boolean;
begin
Result := inherited MouseDown (Button, Shift, X, Y);
if Result then begin
if Floating then begin
if DParent <> nil then
DParent.ChangeChildOrder (self);
end;
SpotX := X;
SpotY := Y;
end;
end;
function TDWindow.MouseUp (Button: TMouseButton; Shift: TShiftState; X, Y: Integer): Boolean;
begin
Result := inherited MouseUp (Button, Shift, X, Y);
end;
procedure TDWindow.Show;
begin
Visible := TRUE;
if Floating then begin
if DParent <> nil then
DParent.ChangeChildOrder (self);
end;
if EnableFocus then SetDFocus (self);
end;
function TDWindow.ShowModal: integer;
begin
Visible := TRUE;
ModalDWindow := self;
if EnableFocus then SetDFocus (self);
end;
{--------------------- TDWinManager --------------------------}
constructor TDWinManager.Create (AOwner: TComponent);
begin
inherited Create (AOwner);
DWinList := TList.Create;
MouseCaptureControl := nil;
FocusedControl := nil;
end;
destructor TDWinManager.Destroy;
begin
inherited Destroy;
end;
procedure TDWinManager.ClearAll;
begin
DWinList.Clear;
end;
procedure TDWinManager.AddDControl (dcon: TDControl; visible: Boolean);
begin
dcon.Visible := visible;
DWinList.Add (dcon);
end;
procedure TDWinManager.DelDControl (dcon: TDControl);
var
i: integer;
begin
for i:=0 to DWinList.Count-1 do
if DWinList[i] = dcon then begin
DWinList.Delete (i);
break;
end;
end;
function TDWinManager.KeyPress (var Key: Char): Boolean;
var
i: integer;
begin
Result := FALSE;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then begin
with ModalDWindow do
Result := KeyPress (Key);
exit;
end else
ModalDWindow := nil;
Key := #0; //ModalDWindow啊 KeyDown闌 芭摹擱輯 Visible=false肺 函竅擱輯
//KeyPress甫 促矯芭媚輯 ModalDwindow=nil撈 等促.
end;
if FocusedControl <> nil then begin
if FocusedControl.Visible then begin
Result := FocusedControl.KeyPress (Key);
end else
ReleaseDFocus;
end;
{for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
if TDControl(DWinList[i]).KeyPress (Key) then begin
Result := TRUE;
break;
end;
end;
end; }
end;
function TDWinManager.KeyDown (var Key: Word; Shift: TShiftState): Boolean;
var
i: integer;
begin
Result := FALSE;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then begin
with ModalDWindow do
Result := KeyDown (Key, Shift);
exit;
end else MOdalDWindow := nil;
end;
if FocusedControl <> nil then begin
if FocusedControl.Visible then
Result := FocusedControl.KeyDown (Key, Shift)
else
ReleaseDFocus;
end;
{for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
if TDControl(DWinList[i]).KeyDown (Key, Shift) then begin
Result := TRUE;
break;
end;
end;
end; }
end;
function TDWinManager.MouseMove (Shift: TShiftState; X, Y: Integer): Boolean;
var
i: integer;
begin
Result := FALSE;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then begin
with ModalDWindow do
MouseMove (Shift, LocalX(X), LocalY(Y));
Result := TRUE;
exit;
end else MOdalDWindow := nil;
end;
if MouseCaptureControl <> nil then begin
with MouseCaptureControl do
Result := MouseMove (Shift, LocalX(X), LocalY(Y));
end else
for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
if TDControl(DWinList[i]).MouseMove (Shift, X, Y) then begin
Result := TRUE;
break;
end;
end;
end;
end;
function TDWinManager.MouseDown (Button: TMouseButton; Shift: TShiftState; X, Y: Integer): Boolean;
var
i: integer;
begin
Result := FALSE;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then begin
with ModalDWindow do
MouseDown (Button, Shift, LocalX(X), LocalY(Y));
Result := TRUE;
exit;
end else ModalDWindow := nil;
end;
if MouseCaptureControl <> nil then begin
with MouseCaptureControl do
Result := MouseDown (Button, Shift, LocalX(X), LocalY(Y));
end else
for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
if TDControl(DWinList[i]).MouseDown (Button, Shift, X, Y) then begin
Result := TRUE;
break;
end;
end;
end;
end;
function TDWinManager.MouseUp (Button: TMouseButton; Shift: TShiftState; X, Y: Integer): Boolean;
var
i: integer;
begin
Result := TRUE;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then begin
with ModalDWindow do
Result := MouseUp (Button, Shift, LocalX(X), LocalY(Y));
exit;
end else ModalDWindow := nil;
end;
if MouseCaptureControl <> nil then begin
with MouseCaptureControl do
Result := MouseUp (Button, Shift, LocalX(X), LocalY(Y));
end else
for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
if TDControl(DWinList[i]).MouseUp (Button, Shift, X, Y) then begin
Result := TRUE;
break;
end;
end;
end;
end;
function TDWinManager.DblClick (X, Y: integer): Boolean;
var
i: integer;
begin
Result := TRUE;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then begin
with ModalDWindow do
Result := DblClick (LocalX(X), LocalY(Y));
exit;
end else ModalDWindow := nil;
end;
if MouseCaptureControl <> nil then begin
with MouseCaptureControl do
Result := DblClick (LocalX(X), LocalY(Y));
end else
for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
if TDControl(DWinList[i]).DblClick (X, Y) then begin
Result := TRUE;
break;
end;
end;
end;
end;
function TDWinManager.Click (X, Y: integer): Boolean;
var
i: integer;
begin
Result := TRUE;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then begin
with ModalDWindow do
Result := Click (LocalX(X), LocalY(Y));
exit;
end else ModalDWindow := nil;
end;
if MouseCaptureControl <> nil then begin
with MouseCaptureControl do
Result := Click (LocalX(X), LocalY(Y));
end else
for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
if TDControl(DWinList[i]).Click (X, Y) then begin
Result := TRUE;
break;
end;
end;
end;
end;
procedure TDWinManager.DirectPaint (dsurface: TDirectDrawSurface);
var
i: integer;
begin
for i:=0 to DWinList.Count-1 do begin
if TDControl(DWinList[i]).Visible then begin
TDControl(DWinList[i]).DirectPaint (dsurface);
end;
end;
if ModalDWindow <> nil then begin
if ModalDWindow.Visible then
with ModalDWindow do
DirectPaint (dsurface);
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -