Subject Re: MS Money shortcuts in ib_date
Author bamberger_monjaude
--- In IBObjects@yahoogroups.com, "Marco Menardi" <mmenaz@m...>
wrote:
> --- In IBObjects@yahoogroups.com, "bamberger_monjaude"
<knoerzer@b...>
> wrote:
> > Hi,
> > i like to give my programms date shortcuts like ms money
shortcuts.
> > It means '*' for today, '+' for date + 1, '-' for date -1.
> >
> > I could do it in IB_Grid with changing then procedure
> > TIB_GridInplaceEdit.KeyPress( var Key: Char ).
> > I added then following lines:
> >
> > if (SelectedField.IsDateTime) and (Key = '*') then
> > SelectedField.Value := now;
> > if (SelectedField.IsDateTime) and (Key = '+') then
> > SelectedField.Value := SelectedField.Value+1;
> > if (SelectedField.IsDateTime) and (Key = '-') then
> > SelectedField.Value := SelectedField.Value-1;
> >
> > But i couldn't find a solution for IB_Date. Has anyone an idea,
> > where i can change the behavior of IB_Date to do this ?
> >
> > Thanks Elmar
> I suggest you to modify IBO source, looking at:
> procedure TIB_CustomDate.KeyPress(var Key: Char);
> in the file:
> IBC_Date.IMP.
> I've seen that, when you have the calendar dropped down, "+" and "-
"
> shortcuts are supported. For current date, right now the shortcuts
is
> "space bar".
> If Jason agrees, since seems a trivial patch, I could add your
> proposed shortcuts, so for current date both spacebar and "*" will
> work, and "+" and "-" will work also when calendar is not dropped.
> BTW, would be nice have IBO shortcuts configurable with an,
optional,
> external file to be read at runtime...
> Best regards
> Marco Menardi


Hello Marco,
thanks for your hint. I added the keys with the following code in the
procedure TDatePick.ProcessKeyDown(var Message: TWMKeyDown)

begin //...not active
if ShiftState = [] then
begin
case CharCode of
VK_MULTIPLY:
begin
FDate := SysUtils.Date;
DoChange(dpOK);
CharCode := 0;
Result := 1;
end;
VK_SUBTRACT:
begin
FDate := FDate -1;
DoChange(dpOK);
CharCode := 0;
Result := 1;
end;
VK_ADD:
begin
FDate := FDate + 1;
DoChange(dpOK);
CharCode := 0;
Result := 1;
end;
end;

and it works. Thanks a lot and with best regards
Elmar