📄 wwdblook.pas
字号:
and (LookupTable.active or Assigned(FOnPerformCustomSearch)) then begin
try
if FGrid.FNavigatorLink<>nil then
FGrid.FNavigatorLink.OnDataChange:=nil;
if (not FGrid.visible) and (not FAutoDropDown) and
(FShowMatchText) and (Style<>csDropDownList) and { 6/6/98 }
(Text<>'') {and (not skipSearch) }then
begin
UpdateSearchIndex(True);
// InAutoDropDown:= True;
end
else if (not FGrid.visible) and FAutoDropDown and (Text<>'') then
begin
UpdateSearchIndex(True);
// InAutoDropDown:= True;
PerformDropDown:= True;
end;
if UseSeqSearch then begin
if ((ssoEnabled in SeqSearchOptions) or Assigned(FOnPerformCustomSearch)) // 2/25/03
and (FGrid.DisplayFld<>nil) and (FGrid.DisplayFld.FieldName<>'') then // 3/06/03 - Check for blank field name
begin
if FGrid.visible or InAutoDropDown or (CanEdit and ShowMatchText) then { 8/17/96 - Execute code if inAutoDropDown }
begin
inList:= FindRecord(Value, FGrid.DisplayFld.FieldName,
mtPartialMatchStart, ssoCaseSensitive in SeqSearchOptions);
if (not inList) and (FGrid.FDisplayFld=FGrid.FValueFld) then
begin
{ FGrid.FDisplayValue:= OldDisplayValue;
FGrid.FValue:= OldLookupValue;}
FGrid.FValue:= '';
// 5/17/03 - Call DropDown since AutoDropDown case
if PerformDropDown and InAutoDropDown then //InDropDownEvent then
try DropDown finally InAutoDropDown:= False end;
exit;
end
end
else
inList:= FindRecord(Value, FGrid.DisplayFld.FieldName,
mtExactMatch, ssoCaseSensitive in SeqSearchOptions);
TypedInText:= Text;
FGrid.FDisplayValue:= FGrid.FDisplayFld.asString;
{ 7/25/99 - If entered text is not subset of current lookup record,
then set inlist to false. This could happen if a trailing space
was in the entered text }
if inList and (length(FGrid.FDisplayValue)<length(Text)) then
begin
inList:= false;
end;
isFound:= inList;
end
else begin
// 5/17/03 - Call DropDown since AutoDropDown case
if PerformDropDown and InAutoDropDown then //InDropDownEvent then
try DropDown finally InAutoDropDown:= False end;
exit;
end
end
else with (LookupTable as TwwTable) do begin
UpdateSearchIndex(True); // 2/14/03
{ Incrementally search on SearchField }
{ if dBASE then use expression index }
if isDBaseTable and (SearchField<>'') and (IndexDefs.indexof(IndexName)>=0) and
(ixExpression in IndexDefs.Items[IndexDefs.indexof(IndexName)].Options) then
begin
if not wwFieldIsValidValue(FieldbyName(SearchField), text) then exit;
EditKey;
FieldByName(SearchField).asString:= text;
GoToNearest;
FGrid.FDisplayValue:= FieldByName(SearchField).asString;
// 2/12/06 - Use AnsiUpperCase
// isFound:= pos(Uppercase(Text), Uppercase(FieldByName(SearchField).asString))=1;
isFound := AnsiPos(AnsiUppercase(Text), AnsiUppercase(FieldByName(SearchField).asString))=1;
inList:= isFound; { 3/1/98 - For NotInList event }
end
else begin
SearchIndex:= GetSearchIndex;
{ 8/27/99 - Don't search if index doesn't match search field }
if (SearchIndex=0) and (FGrid.DisplayFld<>IndexFields[0]) then
begin
TempSearchField:= FGrid.DisplayFld.FieldName;
if (ssoEnabled in SeqSearchOptions) then
begin
if FGrid.visible or InAutoDropDown then
inList:= DoFindRecord(Text, TempSearchField, mtPartialMatchStart)
else
inList:= DoFindRecord(Text, TempSearchField, mtExactMatch)
end;
// exit; { 3/9/00 - Don't exit but do else if instead }
end
else if (SearchIndex>=0) and
not ((SearchIndex=0) and (FGrid.DisplayFld<>IndexFields[0])) then
begin
if FGrid.visible or InAutoDropDown then
InList := wwFindNearest(text, SearchIndex)
else begin
case searchindex of { Use searchindex for lookup }
1: inList:= wwFindKey([indexFields[0].asString, Text]);
2: inList:= wwFindKey([indexFields[0].asString, indexFields[1].asString, Text]);
else InList:= wwFindKey([Text]);
end;
end;
TypedInText:= Text;
FGrid.FDisplayValue:= IndexFields[SearchIndex].text;
end
else begin {1/22/97}
if FGrid.visible or InAutoDropDown then
inList:= DoFindRecord(Text, SearchField, mtPartialMatchStart)
else
inList:= DoFindRecord(Text, SearchField, mtExactMatch)
end;
isFound:= inList;
end
end;
FGrid.FValue:= FGrid.FValueFld.asString;
if FGrid.FValueFld2<>Nil then
FGrid.FValue2:= FGrid.FValueFld2.asString;
if FGrid.FValueFld3<>Nil then
FGrid.FValue3:= FGrid.FValueFld3.asString;
if (not FGrid.visible) then FGrid.FHiliteRow:= -1; { Reset to -1 for UpdateData method - 4/3/97 }
if FShowMatchText and isFound and
(FLastSearchKey<>'~~~~') then { vk_delete when dropped down so skip }
begin
if selStart>0 then SearchText:= copy(Text, 1, selStart)
else SearchText:= Text;
Text:= FGrid.DisplayFld.asString;
modified:= True;
selStart:= length(SearchText);
selLength:= length(Text)-length(SearchText);
if (not FGrid.visible) then FGrid.FHiliteRow:= 0; { 4/3/97}
end;
FLastSearchKey:= text;
if PerformDropDown and InAutoDropDown then //InDropDownEvent then
try DropDown finally InAutoDropDown:= False end;
{ end}
finally
if FGrid.FNavigatorLink<>nil then
FGrid.FNavigatorLink.OnDataChange:=FGrid.NavigatorDataChange;
end
end;
end;
procedure TwwDBCustomLookupCombo.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (FFieldLink <> nil) then
begin
if (AComponent = DataSource) then
DataSource := nil
else if (FImageList=AComponent) then
FImageList:= nil
end;
if (Operation = opRemove) then begin
if (AComponent = FController) then FController:= nil;
end;
end;
function TwwDBCustomLookupCombo.Editable: Boolean;
begin
if Fgrid.visible then begin
Result:= True
end
else begin
Result := (FStyle <> csDropDownList) or AutoDropDown;
end
end;
function TwwDBCustomLookupCombo.MouseEditable: Boolean;
begin
if Fgrid.visible then begin
Result:= True
end
else begin
Result := (FStyle <> csDropDownList);
end
end;
Function TwwDBCustomLookupCombo.IsLookup: boolean;
begin
{$ifdef win32}
result:= (FFieldLink.Field<>Nil) and FFieldLink.Field.Lookup;
{$else}
result:= False;
{$endif}
end;
Function TwwDBCustomLookupCombo.IsWWCalculatedField: boolean;
Function calcOrLookup: boolean;
begin
result:=
(FFieldLink.dataSource.dataSet.fieldByName(dataField).calculated)
or isLookup;
end;
begin
result:=
((FFieldLink.dataSource <>Nil) and (FFieldLink.dataSource.dataSet<>Nil) and
(dataField<>'') and
(wwDataSetIsValidField(FFieldLink.dataSource.dataSet, dataField)) and
calcOrLookup);
if (result and (wwDBCalcFieldType=cftUnknown)) then begin
if wwDataSetGetLinks(dataSource.dataSet, dataField)='' then
begin
if isLookup then
wwDBCalcFieldType:= cftCalculated
else
wwDBCalcFieldType:= cftNotCalculated
end
else wwDBCalcFieldType:= cftCalculated;
end
end;
function TwwDBCustomLookupCombo.CanEdit: Boolean;
begin
Result := (FFieldLink.DataSource = nil) or (DataField='') or
(FFieldLink.Editing and Editable) or
(isWWCalculatedField and
((datasource.state in [dsEdit, dsInsert]) or (dataSource.autoEdit)));
{ Calculated fields don't allow edit if csDropDownList style}
if (not FGrid.Visible) and
((Style=csDropDownList) and not AutoDropDown) then
Result:= False;
if ReadOnly then Result:= False; {!!! Added 6/8/96}
end;
{ Over-ride tab if owned by a grid }
procedure TwwDBCustomLookupCombo.CNKeyDown(var Message: TWMKeyDown);
var shiftState: TShiftState;
stat: integer;
Function ReturnAsTab: boolean;
var ParentGrid: TwwCustomDBGrid;
begin
if parent is TwwCustomDBGrid then
begin
parentGrid:= TwwCustomDBGrid(parent);
result:= (dgEnterToTab in ParentGrid.KeyOptions) and
(Message.charcode = VK_RETURN);
end
else result:= False;
end;
begin
if not (csDesigning in ComponentState) then
begin
with Message do
begin
if (charcode = VK_ESCAPE) and not (parent is TwwCustomDBGrid) then begin
if FGrid.visible then exit; { 6/4/97}
{ 7/28/97 - If modified then escape restores previous text }
if modified then begin
FGrid.FDisplayValue:= OldDisplayValue; {9/18/97 - Use FGrid.FDisplayValue instead of DisplayValue }
FGrid.FValue:= OldLookupValue;
Text:= OldDisplayValue;
if FFieldLink.Field<>nil then
modified:= True { Leave modified as True so RecordView does not close }
else
modified:= False;
{ 2/5/98 - Resets FFieldLink.modified flag }
SkipDataChange:= True;
FFieldLink.Reset;
SkipDataChange:= False;
exit;
end;
end;
{ Prevent tab from exiting if processing AutoDropDown character }
if InAutoDropDown then exit;
if (charcode = VK_TAB) or ReturnAsTab then
begin
if FGrid.visible then begin { drop-down open, treat tab as CR + Tab }
UpdateFromCurrentSelection;
if InList then GridClick(self); { InfoPower 2.0 addition}
closeUp(True);
DoSelectAll;
end
end;
if (charcode = VK_TAB) or (charcode = VK_RETURN) then begin
if not FGrid.Visible then begin
if parent is TCustomGrid then begin
if (charcode <> VK_TAB) or (goTabs in TCheatGridCast(parent).Options) then
begin
parent.setFocus;
if parent.focused and
(IsInwwObjectView(self) or (charcode=vk_tab) or ReturnAsTab) then
begin
shiftState:= KeyDataToShiftState(KeyData);
TCheatGridCast(parent).KeyDown(charcode, shiftState);
end;
exit;
end
end
end
else exit;
end;
{ 1/4/2000 es_multiline style does not pass carriage return/line feed to form so
we pass it ourselves }
if ((charcode=vk_return) or (charcode=vk_escape)) then
begin
if (not modified) or (charcode = vk_return) then
if (Windows.GetWindowLong(handle, GWL_STYLE) and es_multiline)<>0 then
begin
// 8/22/01 - Don't call inherited if parent processed keystroke.
// Parent could process keystroke in case of popup menu with escape key assigned
stat:= SendMessage(GetParent(Ha
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -