Category: Firemonkey

Android FMX INDY SSL Works on debugging but not from PlayStore download

I'm facing a weird Delphi Indy SSL problem. I developed an app for Android which connects to an Server with SSL encryption. I provided OpenSSL libraries and it works fine on debugging the device (Samsung A 3 2016). But when I upload the .aab file and download the app from the PlayStore (internal Test), my app is unable to load the SSL libraries. So I tested with different devices to reproduce the bug. Unfortunately it worked on all device I downloaded the app (32bit and 64bit). I'm stuck with these particular device where I cannot reproduce the unable to load SSL Library mistake. Successful tested devices - Samsung S4 Mini (32bit) - Samsung S7 Mini - Sony XPeria XA (64Bit) - Sony XPeria XZ1 Compact ( - Huawei P30 (64Bit) Unsuccessful tested devices - Samsung A3 2016 (32bit) => this device is not able to load the SSL Libraries I provide here is the Code I use to set the path depending from the OS and CPU {$region 'Android'} {$IFDEF ANDROID} {$IFDEF CPU64BITS} FAppPath := TPath.Combine(TPath.GetDocumentsPath,'bit64'); MemoText := '64 bit SSL libs: ' + FAppPath ; Synchronize(doMemoAddLine); {$ELSE} FAppPath := TPath.GetDocumentsPath ; MemoText := '32 bit SSL libs: ' + FAppPath ; Synchronize(doMemoAddLine); {$ENDIF} IdOpenSSLSetLibPath(FAppPath); MemoText := 'IdOpenSSLSetLibPath(' + FAppPath +')' ; Synchronize(doMemoAddLine); MemoText := WhichFailedToLoad; Synchronize(doMemoAddLine); {$ENDIF} {$endregion}
Read More

Delphi Cannot change this property when using LiveBindings

Can anybody explain to me what the error message "Cannot change this property when using LiveBindings" is telling me? I am new to FMX / Live Bindings and I had something working, but I changed a few things and now, I am getting this error when trying to bind the fields of a TFDMemTable to a TGrid. I had the same fields from the same table bound to the grid before!
Read More

not showing icon in virtualtreeview node fmx

I'm working on fmx virtualtreeview and trying to load image in nodes using TImageList but unfortunately image is not showing whereas I tested on vcl and it worked. Any help would be appreciated here is my code: procedure TMainForm.VSTGetImageIndex(Sender: TBaseVirtualTree;Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;var Ghosted: Boolean; var ImageIndex: TImageIndex); var Data: PVSTData; begin Data := Sender.GetNodeData(Node); if Kind in [ikNormal , ikSelected] then begin ImageIndex :=Data.ImageIndex; end; end; procedure TMainForm.FormCreate(Sender: TObject); var c: char; s: string; DriveType: integer; i: integer; Data:PVSTData; node:PVirtualNode; begin i:=0; VST:= TVirtualStringTree.Create(Self); VST.Parent:= Self; VST.Images:=ImageList1; VST.BorderStyle:=TFormBorderStyle.bsnone; VST.Fill.Color:= TAlphaColorRec.White; VST.Height:= 262; VST.Align:= TAlignLayout.Top; VST.OnInitNode := VSTInitNode; VST.OnFreeNode := VSTFreeNode; VST.OnGetText := VSTGetText; VST.OnGetImageIndex:=VSTGetImageIndex; VST.NodeDataSize := SizeOf(PVSTData); for c:='A' to 'Z' do begin s:=c+':'; DriveType:=GetDriveType(PChar(s)); if DriveType=1 then continue; System.Inc(i); node:=AddChild(nil, s); VST.HasChildren[node]:=True; Data := Vst.GetNodeData(Node); Data.ImageIndex:= i; //Added 4 icons in accordance with drives end; end;
Read More

How to minimize to the tray on FMX

I am creating a launcher for the apps of my work. I want that when I minimize the app, he goes to the tray. I manage to create the icon with a button (the click call the proc), but I don't know what events I need to call the proc, there is no event like Onminized and the event OnHide does not affect. I see some posts about using a Hook ( i am not pretty sure whats is), I try it, but I got an error: [dcc32 Error] UMain.pas(129): E2036 Variable required. This point here: procedure TfrmMain.FormCreate(Sender: TObject); begin SetWindowsHookEx(WH_CALLWNDPROC, @WndProc, 0, GetCurrentThreadId); end; More specific to @wndProc, i try to remove the @ and I got [dcc32 Error] UMain.pas(129): E2009 Incompatible types: 'regular procedure and method pointer' Type... function WndProc(Code: integer; WParam, LParam: LongInt): LRESULT; stdcall; var WndProcHook: THandle; const WM_TRAYICON =WM_USER+1; ------------------------------------------------------ procedure TfrmMain.FormCreate(Sender: TObject); begin SetWindowsHookEx(WH_CALLWNDPROC, @WndProc, 0, GetCurrentThreadId); .... end; function TfrmMain.WndProc(Code: integer; WParam, LParam: LongInt): LRESULT; stdcall; var msg: TCWPRetStruct; begin; if (Code >= HC_ACTION) and (LParam > 0) then begin msg := PCWPRetStruct(LParam)^; if (msg.Message = WM_SIZE) and (msg.WParam = SIZE_MINIMIZED) then begin criaIcone; end; end; result := CallNextHookEx(WndProcHook, Code, WParam, LParam) end; // procedure TfrmMain.CriaIcone; var NotifyIconData: TNotifyIconData; begin with NotifyIconData do begin cbSize := SizeOf; Wnd := AllocateHWnd(WMTrayIcon); uID := 0; uCallbackMessage:= WM_TRAYICON; uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; hIcon := GetClassLong(FmxHandleToHWND(self.Handle),GCL_HICONSM); szTip := 'Teste TrayIcon'; end; Shell_NotifyIcon(NIM_ADD, @NotifyIconData); end;
Read More

Directory TreeView in Delphi FMX

I made a directory TreeView in Delphi FMX, but when I expand 'C:\Windows\WinSxS' it contains 15000 folders. It took a lot of time, but it doesn't expand. On the other hand, when I tried to do it with a VCL TreeView, it worked fine, as it should. Is there any way to make it fast? Here is my code: function SlashSep(const Path, S: String): String; begin {$IF DEFINED(CLR)} if Path[Length(Path)] <> '\' then {$ELSE} if AnsiLastChar(Path)^ <> '\' then {$ENDIF} Result := Path + '\' + S else Result := Path + S; end; procedure GetDir(const ParentDirectory: string; ParentItem: TTreeViewItem); var Status: Integer; SearchRec: TSearchRec; Node: TTreeViewItem; begin Status := FindFirst(SlashSep(ParentDirectory, '*.*'), faDirectory, SearchRec); try while Status = 0 do begin if (SearchRec.Attr and faDirectory = faDirectory) then begin if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then begin Node := AddChild(ParentItem,ExtractFileName(SearchRec.Name)); Node.HasChildren := True; end; end; Status := FindNext(SearchRec); end; finally FindClose(SearchRec); end; end; procedure TForm1.ItemOnExpanding(Sender: TObject; Node: TTreeViewItem); var i: Integer; begin for i := Node.Count - 1 downto 0 do TreeView1.RemoveObject(Node.Items[i]); Node.BeginUpdate; GetDir(GetPathItem(node),node); Node.EndUpdate; end; It's expanding from here: procedure TCustomTreeView.ItemExpanded(const Item: TTreeViewItem); var I: Integer; Child: TTreeViewItem; AllowExpansion: Boolean; begin InvalidateGlobalList; if Item.IsExpanded then for I := 0 to Item.Count - 1 do begin Child := Item.Items[I]; if not Child.IsInflated then Child.Inflate; end; RealignContent; //end; if Assigned(FOnExpanding) then if Item.IsExpanded then FOnExpanding(Self, Item, AllowExpansion) else if Assigned(FOnCollapsing) then if not Item.IsExpanded then FOnCollapsing(Self, Item, AllowExpansion) end;
Read More

Switch specific colors in a TPathData

I am using Delphi Rio with firemonkey. I generated a polygon form TBitmap that has transparent background and some text in black. I want to change the black color only to red color of the polygon and save the changes to the original Tbitmap? I tried iteration through the points of the TPathData and change the individual pixels, but this process is time consuming. Is there a faster way to do switch the colors of TPathData? This is the procedure that uses iteration through TPathData points the change the color of the pixel. procedure TForm1.ChangePathColor(Npath : TPathData; TopV : Integer; BotV : Integer); var Polygon: TPolygon; Color: TAlphaColor; MyBitmap : TBitmap; BMPD, MBMPD : TBitmapData; MyBitmapCopy: TBitmap; access : TMapAccess; h,v : integer; begin Npath.FlattenToPolygon(Polygon,1); MyBitmap := TBitmap.Create(0, 0); MyBitmap.Assign(Image1.Bitmap); MyBitmapCopy := TBitmap.Create(0, 0); MyBitmapCopy.Assign(MyBitmap); try if (MyBitmap.Map(access, BMPD) and (MyBitmapCopy.Map(access,MBMPD))) then Begin Try for h := 1 to MyBitmap.Width do for v := TopV to BotV do begin if image1.Canvas.PtInPath(pointf(h,v),Npath) then begin Color := BMPD.GetPixel(h,v); if (TAlphaColorRec(Color).R < 50) then MBMPD.SetPixel(h,v, TAlphaColors.Red); end; end; finally MyBitmap.Unmap(BMPD); MyBitmapCopy.Unmap(MBMPD); end; end; Image1.Bitmap := MyBitmapCopy; finally MyBitmapCopy.Free; MyBitmap.Free; end; end; Excuse my poor English for misunderstanding. I will explain my problem in pictures The User choose a verse by click and the verse is sent to color transformation procedure This is option will highlight the verse and is very fast This option will change the color of the verse and is very slow using the ChangePathColor procedure that change pixel by pixel The whole new changed BitMap will be sent back the TImage. I want to speed up the process for the colorizing option.
Read More

When You Don’t Know, What You Don’t Know

I've been in a rut for about the past six months. Not just a Delphi programming rut but a "life rut". What's worse, I knew I was in a rut and thought I was trying to get out of it only to realize I wasn't. Then this morning came and... I now know what I didn't know."I knew I was in a rut and thought I was trying to get out of it..."I was fascinated by a post in the Delphi Developer group on FaceBook written by a long-time VCL developer who is frustrated with making something work on an Android device. Admittedly, this person is not a GUI guy nor an OOP fundamentalist. I can totally relate to this. I have been using Delphi since it was Turbo Pascal 3. I am a traditional "top-down procedural" programmer who has been struggling to wrap my head around OOP fundamentals.One of the comments on this post stopped me dead in my tracks. It simply stated... "Put your login form in a TFrame" and gave a link to a GitHub repository of FMX Cross-Platform-Samples.https://github.com/FMXExpress/Cross-Platform-SamplesI've seen some of this FMXExpress stuff before but never knew about this GitHub repository. At the time of this writing there are 99 well organized Cross Platform Samples available. I've been looking for an excuse to rededicate myself to learning FMX cross application development in Delphi and this GitHub repository looks like the perfect spot for me to learn."I really don't know what GitHub is or how to use it."Now, I've heard of GitHub before and I've been to a few different GitHub repositories, but I really don't know what GitHub is or how to use it. This was the my first acknowledgement of YDKWYDK. So I jumped on lynda.com and looked for a course about GitHub and found this one called "Learning GitHub".About ten minutes into the course the instructor says "Projects allow you to visualize your work with Kanban-style boards." I've never heard of Kanban. What is Kanban? (More YDKWYDK)."What is Kanban?"I do another search within lynda.com and discoverd a course called "Stay Lean with Kanban".Wow, this Kanban stuff is really cool. In it's simplest form Kanban is a way to visualize and prioritize the workload. You visually see what you are doing and what needs to get done. You also eliminate waste by focusing on what's most important. This is done by limiting the work in progress.I'm about a third of the way through this tutorial and paused it to write this blog because of another YDKWYDK episode.As I was getting to understand this Kanban stuff it hit me. Why can't I use Kanban for my personal life?"Why can't I use Kanban for my personal life?"I can and I intend to do just that. There's a website for "Personal Kanban". There's also a book called "Personal Kanban: Mapping Work | Navigating Life".It's safe to say I have climbed out of my rut and I'm getting back at it. What a journey today has been...FB Delphi Developer > FMXExpress > GitHub > KanbanSemper Fi,Gunny Mike
Read More

How to check if a file is locked on macos with delphi?

I work with delphi berlin. I create an application for macos with firemonkey. I need to open a file with an external program (i'm using _system function for that) and then to detect when the file is closed in the external application. So i'd like to check regularly if the file is locked. How to check if the file is locked on macos with delphi ?
Read More

Delphi 10.3.3 and Adroid SDK version

I have a question. I was looking for answers on the net but I found nothing specific. I have Delphi version 10.3.3. What is the highest version of Android SDK I can/should install so that there is no problem? By default Delphi installs version 25 and Google Play requires version 26. It is a bit strange that a new version of Delphi has default such an old version of Android Studio. Now, Version 29 of Android Studio is available!
Read More