Jump to content

f.m

Members
  • Content Count

    16
  • Joined

  • Last visited

Everything posted by f.m

  1. f.m

    TListView first and last item visible

    Hello, This could be a way to determine the first and last visible items: procedure GetStartEndItemsIndex(const AListView : TListView; out AStartItemIndex : Integer; out AEndItemIndex : Integer); var LViewportStart, LViewportEnd, LItemAbsEnd : Single; LItemIndex : Integer; begin AStartItemIndex := -1; AEndItemIndex := -1; LViewportStart := AListView.ScrollViewPos; LViewportEnd := AListView.Height + LViewportStart; for LItemIndex := 0 to AListView.Items.Count - 1 do begin LItemAbsEnd := AListView.GetItemRect(LItemIndex).Bottom + AListView.ScrollViewPos; if (AStartItemIndex < 0) and (LItemAbsEnd >= LViewportStart) then begin AStartItemIndex := LItemIndex; end; if (AStartItemIndex >= 0) and (AEndItemIndex < 0) and (LItemAbsEnd >= LViewportEnd) then begin AEndItemIndex := LItemIndex; Break; end; end; if (AEndItemIndex < 0) and (AListView.Items.Count > 0) then begin AEndItemIndex := AListView.Items.Count - 1; end; end; // Example: procedure TFormMain.ListView1ScrollViewChange(Sender: TObject); var LStartItemIndex, LEndItemIndex : Integer; begin GetStartEndItemsIndex(ListView1, LStartItemIndex, LEndItemIndex); Text1.Text := Format('%d, %d', [LStartItemIndex, LEndItemIndex]); end; Please note that - this is linear, not suitable if the ListView contains a large number of items; - when TListView's SearchVisible property is set to True, it will be necessary to change the starting position of the viewport; A better algorithm, which probably also takes into account any animations in progress on mobiles platforms, and make use of binary search, can be found in procedure TListViewBase.DrawListItems(..) in FMX.ListView unit, next to the comment: "// Determine starting and final elements that are currently visible.".
  2. f.m

    FireDAC / ODBC Parameter size error?

    I have no specific information, just some hints here: ODBC driver should be the same on your system and production systems. It may be that an error is fixed in some driver versions. Try to set parameter value using .AsWideString() instead of .AsString() qry.ParamByName('ADVERCODE').AsWideString := String.Empty; It would be hepful to know the field data type, e.g. nvarchar(255), and whether it is nullable. If database field is nullable, a null value could be used instead of an empty string qry.ParamByName('ADVERCODE').DataType := ftWideString; // or ftFixedWideChar, etc... qry.ParamByName('ADVERCODE').Clear(); If field data type is CHAR, trailing spaces should be ignored, a space may be used instead of a empty string qry.ParamByName('ADVERCODE').AsWideString := ' ' {SPACE}; It should be possible to bind an empty string to a type CHAR field having parameter size set to 1. A space will be stored. This would be like: qry.ParamByName('ADVERCODE').Size := 1; qry.ParamByName('ADVERCODE').AsWideString := String.Empty; Hope this helps
  3. Please note that, as mentioned, a membership to Apple Developer Program would be needed to have your app on the App Store. This is also indicated here (RAD Studio 10.4 wiki, page Joining the Apple Developer Program) http://docwiki.embarcadero.com/RADStudio/Sydney/en/Joining_the_Apple_Developer_Program Regarding Apple Developer Program, it would be beneficial also to read this page, section Distribution https://developer.apple.com/programs/whats-included/ Then, once logged-in at https://developer.apple.com, you should find item "Certificates, IDs & Profiles" under Program Resources, please see screenshot. Once "Certificates, IDs & Profiles" is selected, a page regarding pertinent items (e.g. Certificates, Identifiers, Devices, Profiles) is shown. For additional information please also consider: http://docwiki.embarcadero.com/RADStudio/Sydney/en/IOS_Mobile_Application_Development
  4. @Alex Texera In macOS, run KeyChain and from the menu (should be under the first menu item, and then under Certificate Assistant) select command Request a Certificate from a Certificate Authority. Fill in the fields (enter a description and your email), then press the button to save the certificate signing request file on your computer. You might want to prepare more than one request, eg. for iOS development, iOS distribution, macOS development, macOS distribution, and so on. Log in at https://developer.apple.com. A membership to Apple Developer Program would be needed to have your software on the App Store. On that website: section Certificates: upload the certificate signing request file (i.e. the file created with Keychain). Once a certificate is generated, you should download it and install it (double click) on your Mac. This step should be repeated for each certificate needed (e.g. iOS Development, iOS Distribution). Please upload a different certificate signing request file (i.e. a file generated with Keychain) each time. section Identifiers: enter a an app identifier section Devices: enter the UUIDs of your Apple devices section Profiles: select the type of provisioning profile (e.g. iOS Development) and select (as defined in previous steps) app identifier, certificate, and devices. Download this file and install it (double click) on your Mac. Hope this helps.
  5. f.m

    Choose a Folder dialog

    Perhaps SelectDirectory() from FMX.Dialogs could be beneficial. It is implemented for Windows and macOS platforms. It is not implemented for Android nor iOS. var LDirectory : String; if SelectDirectory('Test' {Title}, '' {Root}, LDirectory {out}) then begin // selected.. ShowMessage(LDirectory); end;
  6. f.m

    [bug] Camera + Effects

    Thank you. Here is the stack trace: The exception occurs in the original version of the code. By protecting the UpdatePreview () method with a flag, this exception does not occur.
  7. f.m

    [bug] Camera + Effects

    Hi, This exception occurs in the FMX.Canvas.D2D file on the line 1996 .
  8. f.m

    [bug] Camera + Effects

    Hi, I add some information. I tested your project in the following configuration: - 10.3.2, Windows 10; - I have not removed the comment to any of the Global.. flags in DPR file; - I didn't use FastMM4. I performed two tests: A) Without using TVideoCaptureDevice. I used a timer and some images: The program works. It is possible to change effects, and use effects options without errors. This leads me to believe that the problem is TVideoCaptureDevice: B) Using TVideoCaptureDevice. Generates exception, which is removed if I use the flag ("if FUpdatePreviewExecuting..") in the SampleBufferReady () method. Test procedure: 1) [Play] 2) [Effect] 3) Click on effect 4) Changing effect parameters 5) Repeat from step 3.
  9. f.m

    How to wait for a file compression to finish?

    Using the code in the link below it is possible to observe that during compression or decompression, the file is locked by one of the following processes: 'explorer' (if compression or decompression is started automatically), 'compact' (if compression or decompression is started using the compact.exe command). When the compression or decompression is finished, the process lock ('explorer' or 'compact') is removed. Note: the code is in c#. http://csharphelper.com/blog/2017/01/see-processes-file-locked-c/
  10. f.m

    [bug] Camera + Effects

    procedure TForm1.SampleBufferReady(Sender: TObject; const ATime: TMediaTime); begin if FUpdatePreviewExecuting then Exit; .. end; procedure TForm1.SetEffect(const AFilterName: string); begin if FUpdatePreviewExecuting then Exit; ... end; procedure TForm1.UpdatePreview; begin FUpdatePreviewExecuting := True; try FFilter.ValuesAsBitmap[ 'Input' ] := FRawBitmap; if not FTargetBitmap.IsEmpty then FFilter.ValuesAsBitmap[ 'Target' ] := FTargetBitmap; imgCam.Bitmap := FFilter.ValuesAsBitmap[ 'Output' ]; finally FUpdatePreviewExecuting := False; end; end; SampleBufferReady() is probably synchronized via TThread.Synchronize(). Try to protect UpdatePreview() with a flag.
  11. f.m

    [FireDAC] Query.MergeDataset - how to use?

    To write changes to the database, try this: LQueryDest.CachedUpdates := True; LQueryDest.MergeDataSet( LQuerySource, TFDMergeDataMode.dmDeltaMerge ); LQueryDest.Connection.StartTransaction(); Assert( 0 = LQueryDest.ApplyUpdates() ); LQueryDest.Connection.Commit(); LQueryDest.CommitUpdates(); LQueryDest.CachedUpdates := False; A record will be saved if its UpdateStatus is Inserted or Modified.
  12. f.m

    TFlowLayout

    TFlowLayout is for FMX, while TFlowPanel is for VCL. At design time, it is possible to change (quite) the position using menu item Control|Bring to front/Send to back. Or, expose the control's index property: uses System.Classes, FMX.StdCtrls; type TButtonIndex = class (TButton) published property Index; end; procedure Register; implementation procedure Register; begin {System.Classes}RegisterComponents('With index', [TButtonIndex]); end; Or, use LiveBinding to bind the control's index property. I've never used LiveBinding and can't show an example.
  13. f.m

    ZXing Delphi not function in 10.3.2

    Hi, I tested the demo at https://github.com/Spelt/ZXing.Delphi/blob/v_3.0/demo/advancedTestApp/main.pas To make it work, I had to apply the following changes // 1) Moved this code from FormCreate to FormActivate {$IFDEF ANDROID} FPermissionCamera := JStringToString(TJManifest_permission.JavaClass.CAMERA); {$ENDIF} PermissionsService.RequestPermissions([FPermissionCamera], AccessCameraPermissionRequestResult, DisplayRationale); // 2) Commented this code in FormCreate, because it is called before the CAMERA permission has been granted. Moved in AccessCameraPermissionRequestResult(). UpdateCaptureSettings(TCameraKind.BackCamera); // 3) Changed AutoFocus to ContinuousAutoFocus. CameraComponent1.FocusMode := TFocusMode.ContinuousAutoFocus; // 4) Modified the SampleBufferReady event: procedure TForm1.CameraComponent1SampleBufferReady(Sender: TObject; const ATime: TMediaTime); begin // TThread.Synchronize(TThread.CurrentThread, SyncBitmap); // ParseBitmap(); TThread.Queue(nil, procedure () begin SyncBitmap(); ParseBitmap(); end); end; Also, changed TBarcodeFormat.Auto to TBarcodeFormat.QR_CODE.
  14. f.m

    TFlowLayout

    Hi, Try this: procedure TForm1.FormCreate(Sender: TObject); var LIndex: Integer; LRect : TRectangle; LText : TText; begin for LIndex := 0 to 10-1 do begin LRect := TRectangle.Create( FlowLayout1 ); LRect.Parent := FlowLayout1; LRect.Fill.Color := TAlphaColor($FF000000 or Random($00FFFFFF)); LText := TText.Create( LRect ); LText.Parent := LRect; LText.Align := TAlignLayout.Contents; LText.Text := IntToStr( LIndex ); LText.TextSettings.FontColor := TAlphaColors.White; LText.HitTest := False; end; end; procedure TForm1.ButtonSwap5_6Click(Sender: TObject); var LRect : TRectangle; begin FlowLayout1.BeginUpdate(); LRect := FlowLayout1.Controls[6] as TRectangle; FlowLayout1.Controls.Remove( LRect ); FlowLayout1.Controls.Insert( 5, LRect ); FlowLayout1.EndUpdate(); end;
  15. f.m

    Firedac option MergeDataMode incomprehensibility

    TFDMergeDataMode.dmDeltaMerge mantains source record UpdateStatus: Source Record UpdateStatus Primary key exists ? Dest Record UpdateStatus usInserted No usInserted usInserted Yes usModified After MergeDataSet(dmDeltaMerge), UpdatesPending is true, so it is possible to use ApplyUpdates(). TFDMergeDataMode.dmDataMerge changes UpdateStatus to usUnmodified: Source Record UpdateStatus Primary key exists ? Dest Record UpdateStatus usInserted No usUnmodified usInserted Yes usUnmodified After MergeDataSet(dmDataMerge), UpdatesPending is false.
  16. f.m

    TEdit with a background color

    Hi, Try Result.Locked := True;
×