Subject | Re: [IBO] Re: Date mask |
---|---|
Author | Ales Kahanek |
Post date | 2003-09-02T16:19:59Z |
Hi Marco,
actually I found a solution to this. The problem does not concern to
IB_Date only but generally to all DATE and DATETIME fields. I do not
want to use _any_ date and datetime mask because the entered value is
appropriatelly changed by my own datetime processing function. I
commented out a portion of function TIB_Column.GetEditMask: string; in
the IBA_Column.imp
it looks like this:
if ( FMaskIntf = nil ) and ( Length( FEditMask ) >= 6 ) and
( Copy( FEditMask, 1, 2 ) = '::' ) then
SetEditMask( FEditMask );
Result := FEditMask;
if Result = '' then
begin
if IsDateTime then
begin
// if IsDateOnly then
// begin
// tmpS := UpperCase( FDateOnlyFmt );
// tmpInt := Pos( 'DD' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 3 );
// tmpInt := Pos( 'D' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// tmpInt := Pos( 'MM' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 3 );
// tmpInt := Pos( 'M' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// tmpInt := Pos( 'YY', tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// tmpInt := Pos( 'YY', tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// if tmpS = '' then
// Result := '!99' + DateSeparator + '99' + DateSeparator +
'9999;1; ';
// end
// else
// if IsTimeOnly then
// Result := '!99' + TimeSeparator + '99' + TimeSeparator + '99;1; ';
end;
then in the
procedure TIB_ColumnDateTime.SetAsString( const NewValue: string );
I added the following lines:
if Assigned( FProcessDateStringProc ) then
FProcessDateStringProc( tmpVal, IsTimeOnly or ( SQLType =
SQL_TYPE_TIME ) or ( SQLType = SQL_TYPE_TIME_ ) );
In the IB_Components.pas I added these lines
type
TProcessDateStringProc = procedure(var AStr: string; const
IsTimeOnly: boolean);
var
FProcessDateStringProc: TProcessDateStringProc;
and in my application I define my own procedure of type
TProcessDateStringProc and assign it to the FProcessDateStringProc
variable.
Something similar (I mean the datetime processing function) can be found
in the excellent Enhanced components from Geoff Worboys.
Now I am happy with this solution, little bit nasty but users are satisfied.
Thank you for your help.
Ales
Marco Menardi wrote:
actually I found a solution to this. The problem does not concern to
IB_Date only but generally to all DATE and DATETIME fields. I do not
want to use _any_ date and datetime mask because the entered value is
appropriatelly changed by my own datetime processing function. I
commented out a portion of function TIB_Column.GetEditMask: string; in
the IBA_Column.imp
it looks like this:
if ( FMaskIntf = nil ) and ( Length( FEditMask ) >= 6 ) and
( Copy( FEditMask, 1, 2 ) = '::' ) then
SetEditMask( FEditMask );
Result := FEditMask;
if Result = '' then
begin
if IsDateTime then
begin
// if IsDateOnly then
// begin
// tmpS := UpperCase( FDateOnlyFmt );
// tmpInt := Pos( 'DD' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 3 );
// tmpInt := Pos( 'D' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// tmpInt := Pos( 'MM' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 3 );
// tmpInt := Pos( 'M' + DateSeparator, tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// tmpInt := Pos( 'YY', tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// tmpInt := Pos( 'YY', tmpS );
// if tmpInt > 0 then
// System.Delete( tmpS, tmpInt, 2 );
// if tmpS = '' then
// Result := '!99' + DateSeparator + '99' + DateSeparator +
'9999;1; ';
// end
// else
// if IsTimeOnly then
// Result := '!99' + TimeSeparator + '99' + TimeSeparator + '99;1; ';
end;
then in the
procedure TIB_ColumnDateTime.SetAsString( const NewValue: string );
I added the following lines:
if Assigned( FProcessDateStringProc ) then
FProcessDateStringProc( tmpVal, IsTimeOnly or ( SQLType =
SQL_TYPE_TIME ) or ( SQLType = SQL_TYPE_TIME_ ) );
In the IB_Components.pas I added these lines
type
TProcessDateStringProc = procedure(var AStr: string; const
IsTimeOnly: boolean);
var
FProcessDateStringProc: TProcessDateStringProc;
and in my application I define my own procedure of type
TProcessDateStringProc and assign it to the FProcessDateStringProc
variable.
Something similar (I mean the datetime processing function) can be found
in the excellent Enhanced components from Geoff Worboys.
Now I am happy with this solution, little bit nasty but users are satisfied.
Thank you for your help.
Ales
Marco Menardi wrote:
> --- In IBObjects@yahoogroups.com, Ales Kahanek <akahanek@a...> wrote:
>
>>Hi,
>>when editing DATE column, there is a default mask ' . . ' (it is
>>the dd.mm.yyyy mask by default). I do not want any edit mask to show
>>while entering the date value, because I use my own entered value
>>processing (I want to enter for example +14d - this mean + 14 days
>>from today and my processing procedure changes this string
>>appropriately). This scenario has worked perfectly but now users
>>complain that due to the default mask they are not able to enter the
>>plus sign etc. I do not know when and what was changed in the
>>sources. How to achieve IBO not showing default date mask? I must
>>add, that I do not use any FieldsEditMask or FieldsDisplayFormat
>>property.
>>
>>Using D7, IBO 4.2e, WinXP Pro
>>
>>This is second attempt, the previous question 7 weeks ago nobody
>>answered. I really appreciate your attention.
>>
>>Thank you
>>Ales Kahanek
>
>
>
> mmm don't know, but just to try a fix (I've not tried this, sorry,
> hope it will work): edit IBC_Date.imp and try:
> procedure TIB_CustomDate.UpdateMask( UnboundMask: string );
> begin
> if UnboundMask = '' then
> UnboundMask := '!99' + DateSeparator + '99' + DateSeparator +
> '9999;1; ';
> inherited UpdateMask( UnboundMask );
> end;
>
> has to became:
> procedure TIB_CustomDate.UpdateMask( UnboundMask: string );
> begin
> if (not Assigned( Field )) and (UnboundMask = '') then
> UnboundMask := '!99' + DateSeparator + '99' + DateSeparator +
> '9999;1; ';
> inherited UpdateMask( UnboundMask );
> end;
>
> Let me know. If it's Ok, we can sent this patch to Jason for inclusion
> in the official IBO tree.
> regards
> Marco Menardi
>