Tag: firemonkey

How to show GlyphButton in FMX ListView

On Delphi 10.4.2. This is a very simple question. A new multi-device project, Add Listview onto the form. Toggle to design mode, use DynamicAppearance. Add 2 text items and 1 glyphButton (Checkbox),Hook up a datasource. At design time, no checkbox showing although Glyphbotton.visible is true. At run-time, coded a ListView1ItemClick even with single line code AItem.Objects.GlyphButton.Visible:=true; When click an item, it produces error as show in photo. enter image description here Any idea how to show the checkbox when user clicks an item. It should be a very simple function, why cannot even google an answer for this? The sample code is on github https://github.com/tanghzuk/ListView-Test
Read More

Introducing FNC Grid Excel Bridge components

In the last weeks, we’ve been working on a component to allow you to import and export FNC Grids to the xlsx file format. We’ve also used the opportunity to rename the existing “Grid Filters” and “FMX Grid Filters” to “VCL Grid Excel Bridge” and “FNC Grid Excel Bridge” because the word “Filter” has a different meaning in a grid. We hope the new “Bridge” naming proves less ambiguous.

Same as the “Filters” before, the new Bridge components are free, but they require to have both TMS FNC UI Pack and TMS FlexCel licenses.

You can get the components here:

And the documentation is available here:

So what is the state now if you want to export or import a grid to/from Excel?  We have the following choices:

  1. (VCL Only) You can use StringGrid.SaveToXLS and StringGrid.LoadFromXLS. Those methods will use OLE Automation under the hood, and so they require that Excel is installed in the machine. Because they need Excel, they can only work on Windows.
  2. You can use TAdvGridExcelIO (VCL), TTMSFMXGridExcelIO (FMX) and TTMSFNCGridExcelIO (FNC). Those components use an older trimmed-down FlexCel 3 to do their job. Because they use FlexCel 3, which predates the XLSX file format, they can only work with XLS files, not XLSX.
  3. You can use the “TMS Grid Excel Bridge” components. Those components use an existing  FlexCel 7 to do the work, and so they can export to xls and xlsx, but also HTML and PDF.  Because they require a FlexCel license, they can access the full FlexCel behind it, to do extra customization. Just as an an example: You could add conditional formats to the generated files, as shown in the example here: https://doc.tmssoftware.com/grid-excel-bridge/fnc/guides/user-guide.html#customizing-the-export.



Note: FNCGrid already supports exporting to PDF and HTML natively, you don’t need the bridge components for that. But if you are customizing the xlsx output, you might want to have a PDF or HTML exported with those customizations, and that’s where the Bridge’s exporting to HTML and PDF can be useful.

Up to now, the “Bridges” had support for VCL Grids and FMX Grids. With the release of FNC Bridge, we are extending the first-class Excel exporting and importing to FNC.

Note that in FNC, we only support VCL and FMX at the moment (all platforms). We can’t support Lazarus or WebCore because FlexCel doesn’t support them yet.

So to finish this small post, I’d like to show how it works. We’ll try adding export support for the FNC Grid in the “ClientDataset” demo. This is the grid:

We dropped a TTMSFNCGridExcelExportComponent, and wrote the code:

TMSFNCGridExcelExport1.Export('r:\test.xlsx');

And we got this result:

The checkboxes work in Excel, they are not images. But they will be exported as images to HTML and PDF.

Next, we tried with HTML:

  TMSFNCGridExcelExport1.ExportHtml('r:\test.html', THtmlExportMode.SingleSheet);

And we got:

Finally we went for the PDF export. We could also have tried the one-liner, but in this case it would end up with 2 pages. The grid is too wide and the right part of it goes to the second page. But here is where the power of having full access to the FlexCel engine can help. We could export this file to xlsx, then set the print options in the xlsx file to fit to one page, and only then export to PDF:

    
  var xls := TXlsFile.Create(1, true);
  try
    TMSFNCGridExcelExport1.Export(xls);
    var Pdf := TFlexCelPdfExport.Create(xls, true);
    try
      xls.PrintToFit := true;
      xls.PrintNumberOfHorizontalPages := 1;
      xls.PageHeader := '&L FNC Grid Excel Export Demo&RPage &P of &N';
      Pdf.ExportAllVisibleSheets('r:\test.pdf', false, '');
    finally
      Pdf.Free;
    end;
  finally
    FreeAndNil(xls);
  end;

Just for fun, we also added a page header, and we could have customized the result a lot more. Like for example setting the PDF author or signing the PDF file.

Here is the PDF we got:

Read More

Read More

Android 10 , WakeUP

got here an App with Messaging support. And while I can download the Messages in the Background , the Vibration does not work if the Screen is off. So I tried this : procedure TMain.doVibration(milisec: Integer); var Vibrator : JVibrator; PowerManager : JPowerManager; begin PowerManager := TJPowerManager.Wrap(TAndroidHelper.Context.getSystemService(TJContext.JavaClass.POWER_SERVICE)); if PowerManager.isInteractive = false then PowerManager.wakeUp(1000); Vibrator := TJVibrator.Wrap((SharedActivityContext.getSystemService(TJContext.JavaClass.VIBRATOR_SERVICE) as ILocalObject).GetObjectID); Vibrator.vibrate(milisec); end; Unfortunately this does not work, most of the time it simply locks up my app . Sometimes I get a permission error . In Delphi I set the permission for WAKE_LOCK to true. I would just like to vibrate even if the Screen is Off , is this possible? Thank you.
Read More

High performance tree list in FMX

Intro

The multi-device, true native app platform The FireMonkey® framework is the app development and runtime platform behind RAD Studio, Delphi and C++Builder. FireMonkey is designed for teams building multi-device, true native apps for Windows, OS X, Android and iOS, and getting them to app stores and enterprises fast.

source: https://www.embarcadero.com/products/rad-studio/fm-application-platform

FMX (FireMonkey) released in 2011 and shortly after we delivered a first set of components. Today, we want to show you the TTMSFNCTreeView component, a component with high performance virtual and collection-based modes able to deal with millions of nodes.

Features

Below is a list of the most important features the TTMSFNCTreeView has to offer. The features are not limited to this list, but this will give you a quick insight on what we offer to be able to create a hierarchical tree list in FireMonkey.

  • Multi-line HTML formatted text
  • Various built-in column editors
  • Multi-column support
  • Fixed and variable node height
  • High performance virtual and collection-based modes
  • Multiple events for custom drawing and customization of default drawing
  • Multiple events for all kinds of interactions such as editing, expand / collapse and selection
  • Auto-sizing and stretching of columns
  • Mouse and keyboard interaction
  • Nodes with checkbox, radiobutton, image, disabled nodes
  • Nodes extending over multiple columns
  • Sorting, Filtering
  • Clipboard support
  • Keyboard lookup
  • Reordering
  • Drag & Drop

Learn More!

Want to learn more about what the TTMSFNCTreeView can do? Here is a video that highlights some of the above features through a demo application.

Download & Explore!

The TTMSFNCTreeView component is part of the TMS FNC UI Pack, which, on top of FMX, also offers the ability to write your code once and target other frameworks (VCL, LCL and WEB). You can download a full featured trial version of the TMS FNC UI Pack and start exploring the capabilities of the TTMSFNCTreeView component.

Coming up

The TTMSFNCTreeView is the third of a series of components that is covered to empower your FMX (FireMonkey) developments. We started the series with a general overview of the most important components that we have to offer, followed by the TTMSFNCRichEditor and the TTMSFNCPlanner. Next up will be the TTMSFNCKanbanBoard component, a highly configurable workflow visualization component.

Read More

Read More

Firemonkey open local file iOS by default application

Delphi 10.4.1 iOS 14.2 I have found different sources, but they do not work. Like this: URL : NSUrl; URL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(StrToNSStr( ExtractFileName(AFileName) ))); if SharedApplication.canOpenURL(URL) then SharedApplication.openURL(URL); URL have a valid data like: file:///var/ ...... and i can open it by WebBrowser1.Navigate( NSUrlToStr(URL) ); but SharedApplication.openURL(URL); do nothing. May be some true work example with TUIDocumentInteractionController ? Any complete working example? File exist. I need write some to info.plist.TemplateiOS.xml ? I need open it in default application (file can be .doc, .jpg, .pdf, etc)
Read More

Convert JInputStream to Base64

I convert a JInputStream to base64 with a MemoryStream as intermediary. I need to do that because JInputStream doesn't extend the base class TStream. I deliberately simplified the code by removing the try/finally block. JStream := TAndroidHelper.ContentResolver.openInputStream(StrToJURI(FSelector.Files[I])); Buffer := TJavaArray<Byte>.Create(JStream.Available); JStream.Read(Buffer); MStream := TMemoryStream.Create; MStream.Write(Buffer.Data^, Buffer.Length); MStream.position := 0; SStream := TStringStream.Create('', TEncoding.ASCII); Soap.EncdDecd.EncodeStream(MStream, SStream); Base64Stream := SStream.DataString; Base64Stream := Base64Stream.Replace(#10, ''); Base64Stream := Base64Stream.Replace(#13, ''); Does a method exist to directly convert the data of my JInputSream to base64?
Read More

Real-world Delphi projects out of this world…

How much of our daily life here on planet Earth is impacted by running Delphi code is beyond imagination. Whether it is controlling trains on the French railway system, contact tracing in the COVID19 pandemic in Poland, salary calculation and reporting in Germany, tax invoice approvals in Brazil,… the list is endless. But Delphi’s impact already reached out beyond planet Earth with several projects of the NASA and this week we stumbled on the social media post from Dave Akerman mentioning it was Delphi based software where several TMS components were involved, that was used to produce the sophisticated coating for the Perseverance parachute that was instrumental in its highly critical but eventually successful and safe landing on Mars on Feb 18:

As we chatted, I found out that David had a similar educational background as me in electronic engineering, also loves car racing, worked together with a very good friend of mine having a company Theys Industrial producing electronic PCB’s 2km away from here and I learned that the fabrics for the Perseverance parachute were produced by the company Picanol that is like 20km driving from where the TMS headquarters are. Talking about coincidences…
Well, that was enough a reason to get in touch with David and have a chat about our passion we all share: software development with Delphi! Our colleague Holger Flick produced this video interview with David, where David tells exciting stories of how he got into software development, how he used Delphi for controlling machines precisely mixing chemicals, how he also uses Delphi for his hobby of tracking weather measurement balloons (where TMS WEB Core plays a role in), how he uses the FireMonkey framework for writing software for a Sony watch and so much more…

I’m sure you will enjoy this video interview between two passionate Delphi software developers and be inspired to also do cool things with Delphi!

Read More

Read More

Real-world Delphi projects out of this world…

How much of our daily life here on planet Earth is impacted by running Delphi code is beyond imagination. Whether it is controlling trains on the French railway system, contact tracing in the COVID19 pandemic in Poland, salary calculation and reporting in Germany, tax invoice approvals in Brazil,… the list is endless. But Delphi’s impact already reached out beyond planet Earth with several projects of the NASA and this week we stumbled on the social media post from Dave Akerman mentioning it was Delphi based software where several TMS components were involved, that was used to produce the sophisticated coating for the Perseverance parachute that was instrumental in its highly critical but eventually successful and safe landing on Mars on Feb 18:

As we chatted, I found out that David had a similar educational background as me in electronic engineering, also loves car racing, worked together with a very good friend of mine having a company Theys Industrial producing electronic PCB’s 2km away from here and I learned that the fabrics for the Perseverance parachute were produced by the company Picanol that is like 20km driving from where the TMS headquarters are. Talking about coincidences…
Well, that was enough a reason to get in touch with David and have a chat about our passion we all share: software development with Delphi! Our colleague Holger Flick produced this video interview with David, where David tells exciting stories of how he got into software development, how he used Delphi for controlling machines precisely mixing chemicals, how he also uses Delphi for his hobby of tracking weather measurement balloons (where TMS WEB Core plays a role in), how he uses the FireMonkey framework for writing software for a Sony watch and so much more…

I’m sure you will enjoy this video interview between two passionate Delphi software developers and be inspired to also do cool things with Delphi!

Read More

Read More

File to Base64 with Kastri TFilesSelector [closed]

I want to allow the user to select a file on his mobile device. Since TOpenDialog is for PC only, I use the library Kastri. But TFilesSelector returns the filenames selected by the user like this: content://com.android.providers.downloads.documents/document/4728 How I can Get the real filename (ex: "test.pdf")? Get the content as TStream to convert it to Base64 and then upload it to the server?
Read More

Delphi 10.3 Android APK crashes on start [closed]

My application is created with Delphi 10.3. When I compile and start my app on my Android tablet, it crashes. The message says that the app has stopped. This is the logcat information: I/GLConsumer( 132): [Starting com.embarcadero.gestion](this:0xb8acdfd0,api:0) destroying EGLImage dpy=0x1 img=0x1000000d W/ADB_SERVICES( 162): terminating JDWP 4430 connection: Try again D/ADB_SERVICES( 162): remove pid 4430 to jdwp process list D/GraphicBuffer( 649): close handle(0x631a4fe0) (w:800 h:1217 f:1) D/IPCThreadState( 649): [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x6379f058 D/OpenGLRenderer( 943): prepareDirty (0.00, 0.00, 800.00, 1280.00) opaque 0 <0x63298b28> D/OpenGLRenderer( 943): clear (0.00, 1280 - 1280.00 = 0.00, 800.00 - 0.00 = 800.00, 1280.00 - 0.00 = 1280.00) opaque 0 <0x63298b28> D/OpenGLRenderer( 943): finish <0x63298b28> I/BufferQueue( 132): [com.android.launcher3/com.android.launcher3.Launcher](this:0xb8ada0e8,id:60,api:1,p:943,c:132) [queue] fps:0.44, dur:2263.37, max:2263.37, min:2263.37 I/BufferQueue( 132): [Starting com.embarcadero.gestion](this:0xb8ab15e8,id:58,api:0,p:-1,c:-1) consumerDisconnect I/BufferQueue( 132): [Starting com.embarcadero.gestion](this:0xb8ab15e8,id:58,api:0,p:-1,c:-1) ~BufferQueue I/GraphicBuffer( 132): free buffer (w:800 h:1217 f:1) handle(0xb8ad81b8) W/MALI ( 132): MTK_AUX_isMTKFormat:162: int MTK_AUX_isMTKFormat(ANativeWindowBuffer_t*): format=1 I/GLConsumer( 132): [com.android.launcher3/com.android.launcher3.Launcher](this:0xb8ac0100,api:1) [void* android::GLConsumer::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&, const android::Rect&)] D/GLConsumer( 132): GraphicBuffer: gb=0xb8abccc8 handle=0xb8ad7ce0 fmt=1 D/GLConsumer( 132): EGLImage: dpy=0x1, img=0x1000000d I/BufferQueue( 132): [com.android.launcher3/com.android.launcher3.Launcher](this:0xb8ada0e8,id:60,api:1,p:943,c:132) [release] fps:0.68, dur:2933.74, max:2250.86, min:682.88 W/MALI ( 132): MTK_AUX_isMTKFormat:162: int MTK_AUX_isMTKFormat(ANativeWindowBuffer_t*): format=1 I/GLConsumer( 132): [com.android.systemui.ImageWallpaper](this:0xb8abc700,api:0) [void* android::GLConsumer::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&, const android::Rect&)] D/GLConsumer( 132): GraphicBuffer: gb=0xb8aa64e0 handle=0xb8add868 fmt=1 D/GLConsumer( 132): EGLImage: dpy=0x1, img=0x10000010 W/InputReader( 649): inCount:16, pointer count:0 W/MALI ( 132): MTK_AUX_isMTKFormat:162: int MTK_AUX_isMTKFormat(ANativeWindowBuffer_t*): format=1 I/GLConsumer( 132): [com.android.systemui.ImageWallpaper](this:0xb8abc700,api:0) [void* android::GLConsumer::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&, const android::Rect&)] D/GLConsumer( 132): GraphicBuffer: gb=0xb8aa64e0 handle=0xb8add868 fmt=1 D/GLConsumer( 132): EGLImage: dpy=0x1, img=0x10000010 W/MALI ( 132): MTK_AUX_isMTKFormat:162: int MTK_AUX_isMTKFormat(ANativeWindowBuffer_t*): format=1 I/GLConsumer( 132): [com.android.systemui.ImageWallpaper](this:0xb8abc700,api:0) [void* android::GLConsumer::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&, const android::Rect&)] D/GLConsumer( 132): GraphicBuffer: gb=0xb8aa64e0 handle=0xb8add868 fmt=1 D/GLConsumer( 132): EGLImage: dpy=0x1, img=0x10000010 W/MALI ( 132): MTK_AUX_isMTKFormat:162: int MTK_AUX_isMTKFormat(ANativeWindowBuffer_t*): format=1 I/GLConsumer( 132): [com.android.systemui.ImageWallpaper](this:0xb8abc700,api:0) [void* android::GLConsumer::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&, const android::Rect&)] D/GLConsumer( 132): GraphicBuffer: gb=0xb8aa64e0 handle=0xb8add868 fmt=1 D/GLConsumer( 132): EGLImage: dpy=0x1, img=0x10000010 D/GraphicBuffer( 649): close handle(0x631b7910) (w:640 h:167 f:1) D/GraphicBuffer( 649): close handle(0x63bb4a20) (w:640 h:167 f:1) I/BufferQueue( 132): [Application Error: com.embarcadero.gestion](this:0xb8adac70,id:59,api:2,p:-1,c:132) disconnect: api=2 I/BufferQueue( 132): [Application Error: com.embarcadero.gestion](this:0xb8adac70,id:59,api:0,p:-1,c:132) getReleasedBuffers: returning mask 0xffffffff I/GLConsumer( 132): [Application Error: com.embarcadero.gestion](this:0xb8ad3668,api:0) destroying EGLImage dpy=0x1 img=0x10000003 I/GraphicBuffer( 132): free buffer (w:640 h:167 f:1) handle(0xb8aceeb8) I/GLConsumer( 132): [Application Error: com.embarcadero.gestion](this:0xb8ad3668,api:0) destroying EGLImage dpy=0x1 img=0x1000000b I/GLConsumer( 132): [Application Error: com.embarcadero.gestion](this:0xb8ad3668,api:0) destroying EGLImage dpy=0x1 img=0x1000000e I/GraphicBuffer( 132): free buffer (w:640 h:167 f:1) handle(0xb8ac9d80) D/IPCThreadState( 132): [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0xb8ad5e90 D/GraphicBuffer( 649): close handle(0x66d698d8) (w:640 h:167 f:1) I/BufferQueue( 132): [Application Error: com.embarcadero.gestion](this:0xb8adac70,id:59,api:0,p:-1,c:-1) consumerDisconnect I/BufferQueue( 132):
Read More

FMX rotate bitmap flickers

I want to draw with FMX 2D a TImage, loaded with a sun. This sun should be rotated in a paintbox. Therefor the following procedure is used: var src, dest: TRectF; bmp: TBitmap; myAngle: single; begin bmp := TBitmap.Create(round(Right-Left), round(Bottom-Top)); try if bmp.Canvas.BeginScene(nil) then begin src := RectF(PatternIndex * PatternWidth, 0, (PatternIndex + 1) * PatternWidth, PatternHeight); dest := RectF(Left, Top, Right, Bottom); bmp.Canvas.DrawBitmap(figbig[ImageIndex].Bitmap, src, bmp.BoundsF, 1, false); bmp.Rotate(myAngle); // <-- if I deactivate the rotate then the bitmap is shown the right way bmp.Canvas.EndScene; myCanvas.DrawBitmap(bmp, bmp.BoundsF, dest, 1, false); end; finally bmp.Free; end; end; For the painting i use application idle. The frame rate is about 1000 per sec. The sun is shown very shortly (perhaps 1-2 seconds), disappears (1-3 seconds) and so on = flickering. When the bmp.rotate is deactivated the sun is shown permanent. What is wrong?
Read More