📄 wwdbigrd.pas
字号:
Grid:=nil;
end;
Function IsChildOfGrid(var Inspector: TwwCustomDBGrid): boolean;
var tc: TWinControl;
grid: TwwCustomDBGrid;
begin
GetwwDBGrid(Grid);
if (Grid=Nil) or Grid.IsDropDownGridFocused then begin
result:= False;
exit;
end;
tc:= screen.activecontrol;
if not (tc is TCustomGrid) then
begin
repeat
tc:= tc.parent;
until (tc=nil) or (tc is TCustomGrid);
end;
result:= (tc is TCustomGrid);
if result and wwIsClass(tc.classtype, 'TwwCustomDBGrid') then
Inspector:= TwwCustomDBGrid(tc)
else begin
Inspector:=nil;
result:= false;
end
end;
function Selection: TSelection;
begin
SendMessage(ac.Handle, EM_GETSEL, Longint(@Result.StartPos), Longint(@Result.EndPos));
end;
Function AllSelected: boolean;
begin
with ac do
with Selection do
Result := (StartPos = 0) and
(EndPos = GetTextLen);
end;
function RightSide: Boolean;
begin
with ac do
with Selection do
Result := ((StartPos = 0) or (EndPos = StartPos)) and
(EndPos = GetTextLen);
end;
function LeftSide: Boolean;
begin
with ac do
with Selection do
Result := (StartPos = 0) and
((EndPos = 0) or (EndPos = GetTextLen) {or (isMasked and (EndPos=1))});
if ac is TwwDBCustomEdit then with TwwDBCustomEdit(ac) do
if isMasked and (Selection.EndPos=1) then result:= True;
end;
function TrueFocusIsGrid: boolean;
begin
result:= IsChild(Grid.Handle, GetFocus) or (GetFocus=Grid.Handle);
end;
begin
ac:= screen.activecontrol;
if ac is TCustomGrid then // inplaceeditor doesn't update ac
begin
if (TwwCustomDBGrid(ac).inplaceeditor<>nil) and
(TwwCustomDBGrid(ac).inplaceeditor.handle = GetFocus) then
begin
ac:= TwwCustomDBGrid(ac).inplaceeditor;
end
end;
// Is in drop-down panel then don't send tab if at first or last control so
// that focus does not leave grid
if GetwwDBgrid(Grid) and Grid.IsDropDownGridFocused then begin
if ((ac.parent is TScrollBox) or (ac.parent is TCustomPanel)) and
((ac.parent<>nil) and (ac.parent.parent=Grid)) then
begin
if wparam = 9 then begin
end;
nextctl:= FindNextControl(ac, GetKeyState(vk_shift)>=0, True, False);
if nextctl=nil then begin
result:= 1;
exit;
end
end
end;
result := CallNextHookEx(KeyHook, nCode, wParam, lParam);
if ac=nil then exit;
if ImmGetOpenStatus(ImmGetContext(ac.handle))=True then exit; // 4/17/03 - Allow IME editor to handle keystrokes
KeyMsg.Msg:= WM_KEYDOWN;
KeyMsg.KeyData:= lparam; // confirmed
KeyMsg.CharCode:=wparam;
if ((wparam = 13) or (wparam = 9)) and
not (GetKeyState(vk_control)<0) and
not (GetKeyState(vk_menu)<0) and
(GetFocus=ac.handle) then
begin
if (lparam and $80000000)=0 then begin
if IsChildOfGrid(Grid) then
begin
if (dgEnterToTab in Grid.KeyOptions) or (wparam=vk_tab) then
begin
// Inspector.SetFocus;
// PostMessage(Grid.handle, WM_KEYDOWN, VK_TAB, 0);
PostMessage(Grid.handle, WM_KEYDOWN, wparam, 0);
result:=1;
end
end
end
// 6/20/01
else if not IsChildOfGrid(Grid) then // Another form is active
result:=0
// else result:=1
else result:=0 // 9/27/01 - Allow KeyUp to fire for grid
end
else if GetwwDBgrid(Grid) and
Grid.IsShortCut(KeyMsg) then //ar Message: TWMKey) then
begin
if ((lparam and $80000000)=0) then // shortcut key pressed
begin
// showmessage('');
result:= 1; // Eat keystroke as its a shortcut
end
end
{ else if (wparam = vk_f2) and
not (GetKeyState(vk_control)<0) and
not (GetKeyState(vk_menu)<0) then
begin
if IsChildOfInspector(Inspector) then
begin
if (lparam and $80000000)=0 then
Inspector.FCustomControlKeyMode:= not Inspector.FCustomControlKeyMode;
end
end}
// Collapse expand button on Ctrl-left
else if (wparam in [vk_left]) and
((lparam and $80000000)=0) and
(GetKeyState(vk_control)<0) and
GetwwDBgrid(Grid) and Grid.IsDropDownGridFocused then begin
Grid.CollapseChildGrid;
result:= 1; // 9/18/02 - Eat keystroke so focus does not jump out of grid
end
// Need obj property to see if we should pass vk_down, vk_up, vk_next, and vk_prior to inspector
// Always pass vk_left, vk_right
else if (wparam in [vk_home, vk_end, vk_right, vk_left, vk_down, vk_up, vk_next, vk_prior,
vk_delete]) and
((lparam and $80000000)=0) and
(GetKeyState(vk_control)<0) then
begin
// So dropped-down combos get keystrokes, check if radio-group is still ok
if wwHaveVisibleChild(ac) then exit;
if IsChildOfGrid(Grid) and (ac<>Grid) then
begin
PostMessage(Grid.handle, WM_KEYDOWN, wparam, 0);
result:=1;
end
end
else if (wparam in [vk_left, vk_right, vk_down, vk_up, vk_next, vk_prior,
vk_insert, vk_home]) and // 1/21/00 - Allow home to go to first column if all selected
not (GetKeyState(vk_control)<0) and
not (GetKeyState(vk_menu)<0) then
begin
if wwHaveVisibleChild(ac) then exit;
if (lparam and $80000000)=0 then begin
// Immediate child used to support radiogroup in TwwDBGrid
// if IsChildOfGrid(Inspector) and // Initialize inspector
// IsImmediateChildOfGrid and (ac<>Inspector) then
if IsChildOfGrid(Grid) then
begin
if not TrueFocusIsGrid then exit;
// if not IsImmediateChildOfGrid and (ac<>Grid) then
if not IsImmediateChildOfGrid and (screen.activecontrol<>Grid) then // 1/21/02 RSW (If inplaceeditor then its not a radiogroiup item so don't geo into this path )
begin
if (wparam in [vk_left, vk_right, vk_up, vk_down]) then exit; // radiogroup item has focus
end;
// Send to inspector navigation keys
if (ac is TCustomEdit) then
begin
case wparam of
VK_HOME: if not LeftSide then exit;
VK_LEFT: if not LeftSide then exit;
VK_RIGHT: if not RightSide then exit;
VK_UP: if not AllSelected then exit; // 1/21/02 -
VK_DOWN: if not AllSelected then exit; // 1/21/02
end
end;
if Grid.Focused then exit
else begin
PostMessage(Grid.handle, WM_KEYDOWN, wparam, 0);
end;
result:=1;
end
end
// 6/20/01
else if not IsChildOfGrid(Grid) then // Another form is active
result:=0
// else result:=1
// 9/12/01 - Allow KeyUp to fire for grid
else result:=0
end
end;
procedure TwwGridHintWindow.Paint;
var
R: TRect;
WriteOptions: TwwWriteTextOptions;
begin
R := ClientRect;
Inc(R.Left, 1);
Inc(R.Top, 2);
Canvas.Font.Color := clInfoText;
if WordWrap then
WriteOptions:= [wtoWordWrap];
// 4/17/03 - Support righttoleft hint
if (Field<>nil) and
TwwCustomDBGrid(Owner).UseRightToLeftAlignmentForField(Field, Alignment) then
begin
R.Right:= R.Right-1;
wwWriteTextLinesT(Canvas, R, 0, 0, PChar(Caption), taRightJustify,
WriteOptions)
end
else
wwWriteTextLinesT(Canvas, R, 0, 0, PChar(Caption), Alignment,
WriteOptions);
// SetBkMode(Canvas.Handle, TRANSPARENT);
// DrawText(Canvas.Handle, PChar(Caption), -1, R,
// DT_LEFT or DT_NOPREFIX {or DT_WORDBREAK });
end;
function TwwCustomDBGrid.UseAlternateBuffering: boolean;
begin
result:= AlternatePaintBuffering or
UseRightToLeftAlignment or (wwInternational.GridPaintStyle = gpsDynamicDeviceContext);
if result and (csPaintCopy in ControlState) then
result:= false;
end;
function TwwCustomDBGrid.GetCanvas: TCanvas;
begin
if useDragCanvas then
result:= CaptureTitleBitmap.Canvas
else if not UseAlternateBuffering then
result:= FPaintCanvas
else
result:= inherited Canvas;
// result:= inherited Canvas;
end;
procedure UpdateSelectedProp(Selected: TStrings;
FieldName: string; val: string;
SelectedProperty: TwwUpdateSelected; Index: integer = -1);
var APos: integer;
FieldWidth, DisplayLabel, ReadOnly, GroupName: wwSmallString;
begin
if Index=-1 then
begin
if not wwFindSelected(Selected, FieldName, index) then exit;
end;
begin
APos:=1;
FieldName:= strGetToken(Selected[index], #9, apos);
FieldWidth:= strGetToken(Selected[index], #9, apos);
DisplayLabel:= strGetToken(Selected[index], #9, apos);
ReadOnly:= strGetToken(Selected[index], #9, apos);
if ReadOnly='' then ReadOnly:= 'F';
GroupName:= strGetToken(Selected[index], #9, apos);
case SelectedProperty of
sptUpdateGroup: GroupName:= val;
sptUpdateWidth: FieldWidth:= val;
sptUpdateLabel: DisplayLabel:= val;
sptUpdateReadOnly: ReadOnly:= val;
end;
Selected[index]:= FieldName + #9 + FieldWidth + #9 +
DisplayLabel + #9 + ReadOnly;
if GroupName<>'' then
Selected[index]:= Selected[index] + #9 + GroupName;
end;
end;
function GetSelectedProp(Selected: TStrings;
FieldName: string;
SelectedProperty: TwwUpdateSelected): string;
var APos, index: integer;
FieldWidth, DisplayLabel, ReadOnly, GroupName: wwSmallString;
begin
if wwFindSelected(Selected, FieldName, index) then
begin
APos:=1;
FieldName:= strGetToken(Selected[index], #9, apos);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -