Category: StackOverflow

RestoreCapture FMX – Win32

I took this example of subclassing a Form's HWND as a starting point and then added in jrohde's code from from here that is designed to let you drag a Form by clicking anywhere on it (not on the caption bar). This code fails on the ReleaseCapture()line with this message: E2283 Use . or -> to call '_fastcall TCommonCustomForm::ReleaseCapture() If i comment that line out the code runs and i can move the form by left mouse don and drag, but i can't let go of it. The mouse gets stuck to the form like flypaper. If i replace the ReleaseCapture() with a ShowMessage i can break out but that is obviously not the way to go... What do i need to do allow that RestoreCapture() to run? This is Win32 app. BELOW IS THE CODE i added to the original switch(uMsg) block: // two int's defined above the switch statement static int xClick; static int yClick; // new case added to the switch case WM_LBUTTONDOWN: SetCapture(hWnd); xClick = LOWORD(lParam); yClick = HIWORD(lParam); break; case WM_LBUTTONUP: //ReleaseCapture(); // This is the problem spot <------------------------ ShowMessage("Up"); break; case WM_MOUSEMOVE: { if (GetCapture() == hWnd) //Check if this window has mouse input { RECT rcWindow; GetWindowRect(hWnd,&rcWindow); int xMouse = LOWORD(lParam); int yMouse = HIWORD(lParam); int xWindow = rcWindow.left + xMouse - xClick; int yWindow = rcWindow.top + yMouse - yClick; SetWindowPos(hWnd,NULL,xWindow,yWindow,0,0,SWP_NOSIZE|SWP_NOZORDER); } break; thanks, russ
Read More

Delphi XE (Firemonkey) problem when updating more image on runtime (android)

I cam creating an app for Android with Delphi XE 10.3, Firemonkey. I have tried every possible idea and searched online for days but can't find a solution. I have many PNG images loaded as assets (RT_RCDATA). If I have one button that does the following: .... InStream := TResourceStream.Create(HInstance, 'PngImage_'+inttostr(trunc(TrackBar2.Value)), RT_RCDATA); try Image1.Bitmap.LoadFromStream(InStream); finally InStream.Free; Then every time I click on the button, the image is shown correctly. BUT, If I try to load and show, for example 3 or 4 images,with some delay between them, (like an automatic slideshow), then the image is not updated, so only the last image is shown. I have tried everything, from repaint, refresh methods, hide/show visibility, calling application.processmessages, loading a bitmap and drawing it to form canvas, using a timer, but I can't find a solution. Thanks
Read More

fire event after mouse moves form – FMX C++

I want to run a block of code after my form has been moved on the screen by the traditional "left-mouse down on caption bar and drag to new spot". OnMouseUp only works on the form itself, not for mouse click on the title bar. This is C++ and Win32 app. thanks, russ UPDATE 1: Showing code i implemented based on Remy's answer. I implemented his code from that other post and then added another item to the switch(uMsg) to catch the WM_MOVE message. This didn't work. case WM_MOVE: { ShowMessage("Moved"); } UPDATE 2: I changed the above from WM_MOVE to WM_EXITSIZEMOVE based on Remy's comment and it works great now. Fires 1 time when i get through moving the form. case WM_EXITSIZEMOVE: { ShowMessage("Moved"); } Just what i wanted.
Read More

Firemonkey – How to position a new form under a TComponent

I am developing an application for Windows/Apple with Delphi 10 and Firemonkey. My main form has a TButton. When I press the TButton I would like to create and positioning Form1 exactly under the TButton. Here there is my code: //Transposes the coordinates in the context of the form. myTPointF := TButton.LocalToAbsolute(TButton.Position.Point); //Transposes the coordinates in the context of the screen. myTPointF := ClientToScreen(myTPointF); Form1.Top := FloatToStr(myTPointF.X) + Round(TButton.Height); Form1.Left := FloatToStr(myTPointF.Y); And if the TButton is near the Point(0,0) of the form (not the screen) it works, but the more is away from this point the more Form1 is wrong when i open it. Link for the image: https://ibb.co/85dfr9R https://ibb.co/t2stMHv Thanks in advance for the help.
Read More

IOS: Is their anyway to run a command just after file are deployed?

Is their anyway to run a command just after files are deployed via PASERVER (and before the install/signing process start)? I found some events like pre-build, post-build and pre-link but all those events are fired before the file are deployed. it's related to this bug report: https://quality.embarcadero.com/browse/RSP-22899
Read More

Delphi Firemonkey creating TExpanders and TLabels at runtime

Using Rad Studio 10.3 I am creating TExpanders at runtime based on a FireDAC query. However i am running into an issue setting the Parent of the label to the expander i have just created. I am using the following to create the components procedure TfrmMain.FormCreate(Sender: TObject); var i: integer; begin // Populate previous saved conversions stringgrid FDQuery1.SQL.Clear; FDQuery1.Close; FDQuery1.SQL.Add('SELECT convert from conversions'); FDQuery1.Open; i := 1; while not FDQuery1.Eof do begin // Create Expanders here to display database query to user exp := TExpander.Create(Self); exp.Parent := layoutDBDisplay; exp.Align := TAlignLayout.Top; exp.Name := 'dbExp' + i.ToString; exp.Height := 100; exp.TextSettings.Font.Size := 14; exp.TextSettings.Font.Style := [TFontStyle.fsBold]; // Create TLabel inside of above expander lab := TLabel.Create(Self); lab.Parent := TExpander; lab.Align := TAlignLayout.Top; lab.Name := 'dbResLabel' + i.ToString; inc(i); FDQuery1.Next; end; FDQuery1.Close; end; The issue is lies in this line lab.Parent := expName; Obviously the above won't compile because of the following [dcc32 Error] frmConverter.pas(266): E2010 Incompatible types: 'TFmxObject' and 'class of TExpander' Is there a simple solution to this?
Read More

delphi/IOS: How with PASERVER sign dynamic libraries before to deploy them?

To include a dynamic library in your iOS app, this dynamic library must be signed. When you deploy an app, Delphi automatically signs the app through the PASERVER. Is their anyway to order PASERVER to also sign the included dynamic libraries? (that are in the subfolder Frameworks/ of the app). Or is there any other way to automate this task? Exactly i need to execute this line before to deploy the app : "/usr/bin/codesign" -s "<myProfile>" "/Users/me/PAServer/scratch-dir/ALLiveVideoChatClient.app/Frameworks/WebRTC.framework/WebRTC"
Read More

onMouseMove override keeps onMouseUp from working

I have a TreeViewItem which its onMouseUp is not fired, I tried shrinking my complicated class and I was able to produce a working example of a onMouseUp not working, it seems the onMouseMove override is causing this behavior which is a mystery because I am using onMouseUp and I'm not overriding the onMouseMove! How can I fix this code? unit Unit2; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts, FMX.TreeView; type TForm2 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } procedure MouseMove(Shift: TShiftState; X, Y: Single); override; procedure onItemMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); public { Public declarations } end; var Form2: TForm2; implementation {$R *.fmx} procedure TForm2.FormCreate(Sender: TObject); var treeView: TTreeView; treeViewItem: TTreeViewItem; begin treeView := TTreeView.Create(nil); treeView.Position.X := 0; treeView.Position.Y := 0; treeView.Width := 200; treeView.Height := 300; treeView.Parent := form2; treeViewItem := TTreeViewItem.Create(nil); treeViewItem.Parent := treeView; treeViewItem.Text := 'This is a test'; treeViewItem.OnMouseUp := onItemMouseUp; end; procedure TForm2.onItemMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Single; Y: Single); begin ShowMessage('onItemMouseUp'); end; procedure TForm2.MouseMove(Shift: TShiftState; X: Single; Y: Single); begin end; end.
Read More

Delphi Error creating form: Error reading PastMovesGrid.OnClick: Property OnClick does not exist

Migrating a project from Delphi XE7 to 10.3 Rio. Delphi Rio gives this error: Error creating form: Error reading PastMovesGrid.OnClick: Property OnClick does not exist. PastMovesGrid is a TStringGrid. Sure enough, OnClick is no longer part of TStringGrid in the latest FMX. I've opened the DFM for the form and there is no reference to OnClick for the PastMovesGrid. When I tell Delphi to Ignore the missing property, the form does open, but when I run the app I get a runtime error about the "Property OnClick does not exist." I get the same results with Delphi 10.2.3. How do I get Delphi 10.3 to forget about this missing property?
Read More

How use OpenSSL in delphi and php properly?

I have a fmx project as client and use nginx as server. For efficiency i just want to encrypt my username and password. The rest of the information is sent in raw form. I generated keys in php web server but i can't encrypt user&pass in client side by Delphi fmx client. <?php // Configuration settings for the key $config = array( "digest_alg" => "sha512", "private_key_bits" => 4096, "private_key_type" => OPENSSL_KEYTYPE_RSA, ); $res = openssl_pkey_new($config); openssl_pkey_export($res, $private_key); $public_key = openssl_pkey_get_details($res); $public_key = $public_key["key"]; ?> I get $public_key as string in delphi but i can't encrypt data properly.
Read More

Form location/size FMX – Win32

i'm building an FMX app for Win32 (one form only) with C++ Builder. I'd like the program to remember where it's form was located on the users screen and it's size (it is resizeable) for the next time the user runs it. Can someone point me in the right direction? thanks, relayman UPDATE: Thanks Sam. I did what you said but wrote the position info to an SQLite db instead of text file. The db has a table named "pos" with 5 integer fields. 4 are the positions and 1 is named "item" and is just to facilitate my update query (I'm not sql expert by long shot). Note, the code below needs try/catch improvements and some tests to make sure form coordinates are valid. This code is in the form OnShow event: TFDQuery *query2; query2 = new TFDQuery(NULL); query2->Connection = Form1->FDConnection1; query2->SQL->Text = "SELECT * FROM pos"; query2->Open(); Form1->Left = query2->FieldByName("left")->AsInteger; Form1->Top = query2->FieldByName("top")->AsInteger; Form1->Width = query2->FieldByName("width")->AsInteger; Form1->Height = query2->FieldByName("height")->AsInteger; query2->Close(); query2->DisposeOf(); This code is in the form OnClose event: TFDQuery *queryUPDATE; queryUPDATE = new TFDQuery(NULL); queryUPDATE->Connection = Form1->FDConnection1; queryUPDATE->SQL->Text = "UPDATE pos set left = '" + IntToStr(Form1->Left) + "', top = '" + IntToStr(Form1->Top) + "', width = '" + IntToStr(Form1->Width) + "', heigth = '" + IntToStr(Form1->Height) + "' WHERE item = '1'"; queryUPDATE->ExecSQL(); queryUPDATE->Close(); queryUPDATE->DisposeOf();
Read More