📄 wwdbdlg.pas
字号:
// result:= LoadBitmap(HInstance, 'WWDOTS')
// result:= LoadBitmap(HInstance, 'DOTS');
//end;
procedure TwwDBLookupComboDlg.SetOptions(sel: TwwDBLookupDlgOptions);
begin
FOptions:= sel;
end;
procedure TwwDBLookupComboDlg.SetGridOptions(sel: TwwDBGridOptions);
begin
FGridOptions:= sel;
end;
procedure TwwDBLookupComboDlg.DropDown;
type SmallString = string[63];
var MyOnDropDown: TNotifyEvent;
{fromFieldName: String;} {Win95 - formerly SmallString}
MyOnCloseUp: TNotifyCloseUpEvent;
res: boolean;
keyFieldValue: string;
lkupField: TField;
searchText, field1name: SmallString;
curpos: integer;
modified: boolean;
begin
if ReadOnly then exit;
try
{ If calculated field then
1. Find dest link field(s) name
2. Set lookup table to use indexName for calculated field indexName
3. Perform FindKey
4. Switch index of lookupTable to match display of left-most column field
5. After dialog returns, change value of from link field to selection
}
MyOnDropDown:= OnDropDown;
MyOnCloseUp:= OnCloseUp;
if Assigned(MyOnDropDown) then MyOnDropDown(Self);
if (LookupTable=Nil) then begin // 8/29/00 - Move to after event
MessageDlg('No lookup table specified!', mtWarning, [mbok], 0);
RefreshButton;
exit;
end;
{10/7/97 - Check for active after OnDropDown is called }
if (not LookupTable.active) then begin
MessageDlg('No lookup table specified!', mtWarning, [mbok], 0);
RefreshButton;
exit;
end;
{ default to lookup field if no selection }
curPos:= 1;
field1Name:= strGetToken(lookupField, ';', curpos);
if (Selected.count=0) then begin
if isWWCalculatedField then lkupField:= TwwPopupGrid(FGrid).DisplayFld
else lkupField:= lookupTable.findField(field1Name);
if (lkupField<>Nil) then begin
Selected.add(
lkupField.fieldName + #9 + inttostr(lkupField.displayWidth) + #9 +
lkupField.DisplayLabel);
end
end;
{9/19/97 - AutoDropDown with ShowMatchText should copy only selected text }
if AutoDropDown and inAutoDropDown then begin
if ShowMatchText then
SearchText:= copy(Text, 1, selStart)
else
SearchText:= Text
end
else SearchText:= '';
if (dataSource<>Nil) and (dataSource.dataSet<>Nil)
and isWWCalculatedField then begin
{7/20/98}
if not InAutoDropDown then Grid.DoLookup(True); { Called in case lookupTable was moved by another control }
if (not HasMasterSource) and (LookupTable is TwwTable) and OrderByDisplay then
LTable.setToIndexContainingFields(Selected);
res:= ExecuteWWLookupDlg(Screen.ActiveForm, self, Selected, lookupTable, FOptions, FGridOptions,
FGridColor, FGridTitleAlignment, FCaption, FMaxWidth, FMaxHeight, CharCase,
FUserButton1Caption, FUserButton2Caption,
FUserButton1Click, FUserButton2Click, FOnInitDialog, FOnCloseDialog,
FOnSortChange, SearchText, UseTFields,
{$ifdef wwDelphi4Up}
PictureMaskFromField
{$else}
False
{$endif}
);
if (DataSource<>Nil) and (DataSource.dataset<>Nil) then
DataSource.dataSet.disableControls;
if res then begin
InList:= True; { 1/4/99 }
if LookupField<>'' then UpdateFromCurrentSelection; { Updates FValue^ used by wwChangeFromLink }
wwChangefromLink(LookupTable, modified);
Text:= FGrid.DisplayValue; // 12/8/02 - Update text
end
else modified:= false;
if Assigned(MyOnCloseUp) then begin
MyOnCloseUp(Self, LookupTable, dataSource.dataSet, modified);
end;
if (DataSource<>Nil) and (DataSource.dataset<>Nil) then
DataSource.dataSet.enableControls;
end
else begin
{ if (lookupTable.fieldByName(Field1Name).asString <> LookupValue) or}
if (LookupValue='') or isLookupRequired then begin
{ Switch index to lookup field's index }
if (LookupTable is TwwTable) and (LTable.MasterSource=Nil) and (Lookupfield<>'') then
LTable.setToIndexContainingField(LookupField);
if TwwPopupGrid(FGrid).LookupFieldCount<2 then begin
if UseSeqSearch or (LTable.indexFieldCount=0) then { Sequential search }
begin
FindRecord(LookupValue, LookupField, mtExactMatch,
ssoCaseSensitive in SeqSearchOptions)
end
else LTable.wwFindKey([LookupValue])
end
else if TwwPopupGrid(FGrid).LookupFieldCount<3 then
LTable.wwFindKey([LookupValue, Value2])
else LTable.wwFindKey([LookupValue, SetValue2, SetValue3]);
end;
{Switch index back to previous index if not sql}
if (LookupTable is TwwTAble) and (not HasMasterSource) and OrderByDisplay then
LTable.setToIndexContainingFields(Selected);
res:= ExecuteWWLookupDlg(Screen.ActiveForm, self, Selected, lookupTable, FOptions, FGridOptions,
FGridColor, FGridTitleAlignment, FCaption, FMaxWidth, FMaxHeight, CharCase,
FUserButton1Caption, FUserButton2Caption,
FUserButton1Click, FUserButton2Click, FOnInitDialog, FOnCloseDialog,
FOnSortChange, SearchText, UseTFields,
{$ifdef wwDelphi4Up}
PictureMaskFromField
{$else}
False
{$endif}
);
if (DataSource<>Nil) and (DataSource.dataset<>Nil) then
DataSource.dataSet.disableControls;
try
skipDataChange:= True; { Don't update internal lookup values 1/15/96 }
if res then
begin
InList:= True; { 1/4/99 }
if LookupField<>'' then begin
KeyFieldValue:= lookupTable.fieldByName(Field1Name).Text;
FFieldLink.Edit;
if (DataSource=Nil) or (DataSource.dataSet=Nil) then
begin
UpdateFromCurrentSelection;
Text:= TwwPopupGrid(FGrid).DisplayValue;
end;
if (FFieldLink.Field<>Nil) and
(DataSource<>nil) and (DataSource.DataSet<>nil) and
(DataSource.DataSet.State in [dsEdit, dsInsert]) or
isWWCalculatedField then
begin // 8/16/04 - Respect AutoEdit=false
FFieldLink.Modified;
FFieldLink.Field.AsString := KeyFieldValue; { forces calculated fields to refresh }
UpdateFromCurrentSelection; { 8/25/96 - Update internal variables }
Text:= FGrid.DisplayFld.asString; { 8/25/96 }
FFieldLink.UpdateRecord; { 1/22/96 - Update 2nd-3rd fields }
end
end
end
else if InAutoDropDown and (Style=csDropDownList) then
SendMessage(Handle, WM_CHAR, VK_ESCAPE, 0); { 5/28/98 - Restore original text before dialog opened }
if Assigned(MyOnCloseUp) then begin
if DataSource=Nil then MyOnCloseUp(Self, LookupTable, Nil, res)
else MyOnCloseUp(Self, LookupTable, DataSource.dataSet, res);
end;
finally
if (DataSource<>Nil) and (DataSource.dataset<>Nil) then
DataSource.dataSet.enableControls;
end;
end;
finally
if (Style <> csDropDownList) or AutoDropDown then SelectAll;
FLastSearchKey:= '';
RefreshButton;
SkipDataChange:= False;
if modified and LookupTable.active then begin { 5/12/98 check for active lookuptable }
LookupTable.updateCursorPos;
LookupTable.resync([]);
end
end;
end;
Function TwwDBLookupComboDlg.IsLookupDlg: boolean;
begin
result:= True;
end;
procedure TwwDBLookupComboDlg.SetPictureMasks(val: TStrings);
begin
FPictureMasks.assign(val);
end;
procedure TwwDBLookupComboDlg.SetControlType(val: TStrings);
begin
ControlType.assign(val);
end;
procedure Register;
begin
{ RegisterComponents('InfoPower', [TwwDBLookupComboDlg]);}
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -