Search the Community
Showing results for tags 'devx'.
Found 1 result
-
I am using an ancient version (17.1.5) of the ExpressEditors and have a simple frame in which I am attempting to validate one editor based on the contents of two others. From what I have found on-line and in the help it seems to me that accessing the EditValue of a TcxCustomEdit descendant should be fine at run-time, but I get an AV or other error in the debugger (Berlin) and the application does not behave correctly. i have explored all other public properties as well, and none seem appropriate. Anyone know the cause without tracing through all the DevExpress code? In the TFrameDailyHours.editHoursPropertiesValidate method I am attempting to make sure the Hours edit does not contain a value that exceeds the difference of the two other time edit controls: unit UnitFrameDailyHours; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit, cxSpinEdit, cxTextEdit, cxMaskEdit, cxTimeEdit, Vcl.StdCtrls, Vcl.ExtCtrls; type TFrameDailyHours = class(TFrame) PanelDay7: TPanel; labelDayofWeek: TStaticText; CheckBoxOvernight: TCheckBox; TimeEditStart: TcxTimeEdit; TimeEditStop: TcxTimeEdit; editHours: TcxSpinEdit; procedure TimeEditStartPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure TimeEditStopPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure editHoursPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); public end; implementation {$R *.dfm} procedure TFrameDailyHours.TimeEditStartPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); begin ErrorText := ''; //Start Date is a required field Error := VarIsNull(DisplayValue); if Error then ErrorText := 'Start of Time Range cannot be Empty'; Exit; //if we have a StopTime then the StartTime must be < StopTime Error := (DisplayValue >= TimeEditStop.EditValue); if Error then ErrorText := 'Start of Time Range must precede End of Time Range'; end; procedure TFrameDailyHours.TimeEditStopPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); begin ErrorText := ''; if not (DisplayValue = EmptyStr) then begin Error := (DisplayValue < TimeEditStart.EditValue); if Error then ErrorText := 'End of Time Range must be Empty or after Start of Time Range'; end; end; procedure TFrameDailyHours.editHoursPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); begin ErrorText := ''; Error := False; if not (TimeEditStart.DisplayValue = '00:00:00') and not (TimeEditStop.DisplayValue = '00:00:00') then begin Error := VarIsNull(DisplayValue); if Error then begin ErrorText := 'Hours cannot be Empty'; Exit; end; Error := (DisplayValue < 0) or (DisplayValue > 24); if Error then begin ErrorText := 'Hours must be > 0 and < 24'; Exit; end; //check that Hours does not exceed duration between Start and Stop Times if TimeEditStop.EditValue > TimeEditStart.EditValue then begin Error := (TimeEditStop.EditValue - TimeEditStart.EditValue) * 24 < DisplayValue; if Error then begin ErrorText := 'Hours exceeds duration between Start and End Times'; Exit; end; end; end; end; end.