Jump to content

programmerdelphi2k

Members
  • Content Count

    1406
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by programmerdelphi2k

  1. programmerdelphi2k

    Beep for Firemonkey

    a little fix: procedure TViewMainForm.MyPianoKeyboardMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); begin if LUseMouseMoveEvent and (ssCtrl in Shift) then MyPlayIt(X, Y); end; function TViewMainForm.MyPlayIt(const X, Y: Single): Single; var Xint : integer; Yint : integer; LBitmap : TBitmap; LBitmapData: TBitmapData; LPixelColor: TAlphaColor; LPlayMyTone: Single; begin result := -1; Xint := Trunc(X); Yint := Trunc(Y); // LBitmap := MyPianoKeyboard.Fill.Bitmap.Bitmap; // if (LBitmap <> nil) then begin if LBitmap.Map(TMapAccess.Read, LBitmapData) then try begin LPixelColor := LBitmapData.GetPixel(Xint, Yint); // LPlayMyTone := MyFindColorTone(LPixelColor); // if LUseMouseMoveEvent and (LPlayMyTone = LLastTonePlayed) then exit; // if (LPlayMyTone > 0) then begin LLastTonePlayed := LPlayMyTone; // <---- result := LPlayMyTone; TTone.Play(LPlayMyTone, LPlayDuration); end; end; finally LBitmap.Unmap(LBitmapData); end; end; end;
  2. programmerdelphi2k

    Beep for Firemonkey

    hi @david berneda my contribution for your project, if it's possible! Keyboard colored to find your Musical Notes ( no "IF" anymore ) Play with mouse click Play with mouse moviment... (Ctrl + Mouse moving) Play your song notes (type your notes and play it) FMX_Piano_Keyboard_with_code_by_David_Berneda.zip
  3. programmerdelphi2k

    Adding phone numbers in addressbook

    It's right! because if you "Free it" your reference on "phones list" would be "null"... provocating a "AV"!
  4. programmerdelphi2k

    Corean write in explorer popup menu

    maybe, the "dcu-to-resources-strings" from suite was compiled using "Corean / ???", then, the text showed will be in this language! if yes, try use the ".inc"/".pas" files to your language and recompile the JV suite! understood?
  5. programmerdelphi2k

    How to have a component that follows Mouse Pointer

    in your case, you are trying to do this:
  6. programmerdelphi2k

    How to have a component that follows Mouse Pointer

    Normally, the "event" (like OnClick) is type: procedure(....) OF OBJECT; Which means it belongs to an instance of an object. That is, it will be defined to the class that instantiates the object. I don't know what type of object the "Earth" is? So I'll give an example of the general form of use: type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure MyHello(Sender: TObject); public end; var Form1: TForm1; implementation {$R *.dfm} type TMyEventNofitication = procedure(Sender: TObject) of object; TMyClass = class private FMyEvent: TMyEventNofitication; public property MyEvent: TMyEventNofitication read FMyEvent write FMyEvent; end; procedure TForm1.Button1Click(Sender: TObject); var MyClass: TMyClass; begin MyClass := TMyClass.Create; try MyClass.MyEvent := MyHello; // MyHello is a "procedure" of a Object/Instance (in case, "Form1") = compatible! // // MyClass.MyEvent := true; // not compatible, because "true" is a boolean type, not a "procedure of a object" finally MyClass.Free; end; end; procedure TForm1.MyHello(Sender: TObject); begin // ... end;
  7. programmerdelphi2k

    How to have a component that follows Mouse Pointer

    Sorry, but my "Math" it's not so good than Eistein... you can move your Form for any place and my code can find the "Form-center"... in fact, you dont need use all code... it's only a sample! NOTE: use CallOutPanel .HitTest = false... then, you can to click on form! type TForm1 = class(TForm) CalloutPanel1: TCalloutPanel; LineVert: TLine; LineHorz: TLine; procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} uses Winapi.Windows {SetCursorPos(...) on screen-center-form ... to Mobile can not works } , System.Math; var LCalculatingMouseAngle: boolean = false; LCrossPos : TPointF; procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); var LCalloutPanelPointF : TPointF; LCalloutPanelCenterF: TPointF; LFormCenter : TPointF; A, B : TPointF; C : TPointF; begin LCalloutPanelPointF := CalloutPanel1.Position.Point; // // find Form center in any place on the screen... LFormCenter := TPointF.Create((Width / 2), (Height / 2)); LFormCenter := ClientToScreen(LFormCenter); // A := TPointF.Create(LFormCenter.X, LFormCenter.Y - (LineVert.Height / 2)); A := ScreenToClient(A); LineVert.Position.X := A.X; LineVert.Position.Y := A.Y; // B := TPointF.Create(LFormCenter.X - (LineHorz.Width / 2), LFormCenter.Y); B := ScreenToClient(B); LineHorz.Position.X := B.X; LineHorz.Position.Y := B.Y; // // center found! LCrossPos.X := LineVert.Position.X; LCrossPos.Y := LineHorz.Position.Y; // // cursor position C := ClientToScreen(TPointF.Create(LCrossPos.X, LCrossPos.Y)); SetCursorPos(Trunc(C.X), Trunc(C.Y)); // // CalloutPanel on form-center LCalloutPanelCenterF.X := CalloutPanel1.Width / 2; LCalloutPanelCenterF.X := LineVert.Position.X - LCalloutPanelCenterF.X; // LCalloutPanelCenterF.Y := CalloutPanel1.Height / 2; LCalloutPanelCenterF.Y := LineHorz.Position.Y - LCalloutPanelCenterF.Y; // CalloutPanel1.Position.X := LCalloutPanelCenterF.X; CalloutPanel1.Position.Y := LCalloutPanelCenterF.Y; // LCalculatingMouseAngle := true; end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); var LArcTan2 : Double; LMousePos : TPointF; LCalloutPanelCenterF: TPointF; begin if LCalculatingMouseAngle then begin LMousePos := TPointF.Create(X, Y); LArcTan2 := ArcTan2(LMousePos.Y - LCrossPos.Y, LMousePos.X - LCrossPos.X); // if (LArcTan2 < 0) then begin if (LArcTan2 > -1.5) then CalloutPanel1.RotationAngle := 225 // 45 else if (LArcTan2 < -1.5) then CalloutPanel1.RotationAngle := 135; // 315; end else if (LArcTan2 > 0) then begin if (LArcTan2 < 1.5) then CalloutPanel1.RotationAngle := 315 // 135 else if (LArcTan2 > 1.5) then CalloutPanel1.RotationAngle := 45; // 225; end; // LCalloutPanelCenterF.X := CalloutPanel1.Width / 2; LCalloutPanelCenterF.X := X - LCalloutPanelCenterF.X; // LCalloutPanelCenterF.Y := CalloutPanel1.Height / 2; LCalloutPanelCenterF.Y := Y - LCalloutPanelCenterF.Y; // CalloutPanel1.Position.Y := LCalloutPanelCenterF.Y; // CalloutPanel1.Position.X := LCalloutPanelCenterF.X; end; end; procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin LCalculatingMouseAngle := false; end; end.
  8. *.jar is in: ...\lib\android\debug ...\lib\android\release
  9. programmerdelphi2k

    Adding phone numbers in addressbook

    All permissions... was checked on Project-Options? https://docwiki.embarcadero.com/Libraries/Sydney/en/FMX.AddressBook.TCustomAddressBook.RequestPermission https://delphiaball.co.uk/2016/04/22/accessing-address-book-ios-android-taddressbook/
  10. programmerdelphi2k

    VM and Legacy apps

    try to do a "snapshot" before quit! My Win7 installation with "only" Windows 7 files - none other software installed each "snapshot" take +/-200MBytes + VDI file datas (?? MBytes)
  11. programmerdelphi2k

    Adding phone numbers in addressbook

    do you try some like this: var Contact: TAddressBookContact; Phones: TContactPhones; begin Contact := AddressBook1.CreateContact(AddressBook1.DefaultSource); try // Add a mobile phone number Phones := TContactPhones.Create; try Phones.AddPhone(TContactPhone.TLabelKind.Mobile, '+33-6-46-51-3531'); Contact.Phones := Phones; finally Phones.Free; end; // Save the newly created contact AddressBook1.SaveContact(Contact); finally Contact.Free; end; end;
  12. John look, StringGrid (FMX/VCL) /Grids (in FMX) works like a mem-Repository! All data, in fact, will be "string" values! Then, if you need export data to "FDTable", you'll go needs a "converter"! You can use "TBatchMove" components: BatchMove, BatchMove(Dataset/Text)Writer, BatchMove(Dataset/Text)Reader to work "directly" on Datasets: TFDMemTable and FDTables! So, in FDMemTable you create the same "fields" that you need export to FDTable: same names (or not), same types. BatchMove do the magic: read data-sources on FDMemtable and write on target-FDTable see sample on https://en.delphipraxis.net/topic/7991-batchmove-using-firedac-missing-fieldnames-and-tablename-solved/?tab=comments#comment-67218 NOTE: FDMemTable can store your data in XML, JSON and FD binary... and you can define it using property: ResourceOptions ->PersistentFileName .... (check the property Persistent[x] ) and right-click on component and save to file... (before, you need create your fields)
  13. use only 1 TCameraComponent, and before activate your scanning... change your cam. the Buffer image should run in Thread-secondary context, not in main thread.
  14. programmerdelphi2k

    Android 13 ask permission for push notification

    by Android Developer link above
  15. programmerdelphi2k

    Android 13 ask permission for push notification

    in fact, you DONT NEED any reference to "RequestPermissionsResult" or "DisplayRationale" procedures! Only in special case where you need process something more specific for you app Only "permissions strings" it's enough to conclude the OS requirement implementation {$R *.fmx} uses System.Permissions, Androidapi.Jni.Os, Androidapi.Helpers; const MyPermissionsRequired: array [0 .. 0] of string = ('android.permission.POST_NOTIFICATIONS'); procedure TForm1.FormCreate(Sender: TObject); begin // Place where the first call of the app 's requests will be made. Put where the verification will be carried out // PermissionsService.RequestPermissions( { } [MyPermissionsRequired[0]], { } nil, { TRequestPermissionsResultEvent proc not really necessary at all} nil { TDisplayRationaleEvent) proc not really necessary at all } ); // ------------ // // if the Permissions have already been given or not, so that later you can execute the desired procedure.E.g.send a notification! // NOTE: this command calls Android permissions dialog if not granted yet! // // all if PermissionsService.IsEveryPermissionGranted([MyPermissionsRequired[0]]) then // send my notification procedure ; // just one if PermissionsService.IsPermissionGranted(MyPermissionsRequired[0]) then // send my notification procedure ; end;
  16. programmerdelphi2k

    Using VK_XXX numeric part of keyboard

    {$R *.dfm} procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key in [VK_ADD, VK_MULTIPLY { ,...] } ]) then begin Key := 0; Memo1.Lines.Add('OnKeyDown: VK_ADD, VK_MULTIPLY, ... pressed'); end; end; procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if CharInSet(Key, ['+', '-', '/', '*']) then begin Key := #0; Memo1.Lines.Add('OnKeyPress: VK_ADD, VK_.... pressed'); end; end; end.
  17. programmerdelphi2k

    Android 13 ask permission for push notification

    you tryed: Project->Options->Entitlement List->Receive push notifications [x] requirement on app code: and Android recommendations: https://developer.android.com/develop/ui/views/notifications/notification-permission
  18. I dont know like ICS works, but if you use a "var-Flag" to controls the time send.. like: the error appears on "LOG save"? then, not on "send" in fact?
  19. programmerdelphi2k

    lire fichier binaire hexadecimal en delphi

    in fact, you can use "RAD Studio by Embarcadero" IDE: - Edit-> Compare -> Launch Beyound Compare!!! or you can do it yourself: TFileStream (or any other) class to open 2 files read bytes from files in the same offset compare it the idea is:
  20. programmerdelphi2k

    iOS Launch Image 2x, 3x?

    here a online generator fo iOS screens https://hotpot.ai/blog/ios-1x-2x-3x-generator
  21. programmerdelphi2k

    iOS Launch Image 2x, 3x?

    https://stackoverflow.com/questions/30049544/what-should-image-sizes-be-at-1x-2x-and-3x-in-xcode https://www.appypie.com/image-scaling-ios-how-to
  22. hello girls and boys, RAD 11.2 Alexandria FMX project / 32bits Button1 is on Form1 (directly); Button1.HitTest = false; I'm having a little problem with something that would, shall we say, not be a problem... I need to get control over the mouse cursor to perform some extra tasks. However, I'm not understanding why the result is always "nil" for the "ObjectAtPoint" function. According to the code below, I believe that it should have the intended return, that is, the control "Button1" (IControl representing it)... however, the function is returning "nil"... and, how can be seen on the printscreen, everything goes well until the line number "101", after it, the "result" is again used to check if "ITSELF" has an "object (children... but does not )" in the given coordinates... this part seems strange to me, however, the code is from Embarcadero... so there was even more doubt! So, if anyone can say something that helps me, I thank you in advance. here my code for tests... type TForm1 = class(TForm) Button1: TButton; // <---- my control into form, "Button1.HitTest := false" ... procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: single); var LPointF: TPointF; LIControl: IControl; begin LPointF := TPointF.Create(X, Y); // LIControl := ObjectAtPoint(LPointF); = it's nil // or LIControl := ObjectAtPoint(ClientToScreen(LPointF)); = it's nil ... end; NOTE: on screenshot is "TEDIT" but in fact is "TButton"... ok == I pasted old printscreen ! SORRY!
  23. programmerdelphi2k

    Form ObjectAtPoint() does not working or "me" not working :)

    Now I can find "control" under mouse cursor .... of course, needs verify if "AControl" is valid / not nil , etc..... type TMyHack = class(TControl); // to avoid hack the TControl class.... just copy this function and changes last line to "dont verify HitTest property" function MyObjectAtPoint(const AControl: TControl; AScreenPoint: TPointF): IControl; var // I : Integer; // NewObj : IControl; // Control: TControl; LP: TPointF; begin if not AControl.ShouldTestMouseHits then Exit(nil); // LP := AScreenPoint; // if AControl.Scene <> nil then LP := AControl.Scene.ScreenToLocal(LP); // if (AControl.ClipChildren or TMyHack(AControl).SmallSizeControl) and not AControl.PointInObject(LP.X, LP.Y) then Exit(nil); // (* I dont need it, in my usage! I just want first layer!!! if AControl.ControlsCount > 0 then for I := TMyHack(AControl).GetLastVisibleObjectIndex - 1 downto TMyHack(AControl).GetFirstVisibleObjectIndex do begin Control := TMyHack(AControl).Controls[I]; if not TMyHack(Control).GetVisible then Continue; // // pay attention if needs look at "into controls...", then, I should use "MyObjectAtPoint(...') recursivelly" // not in "TMyHack(Control).ObjectAtPoint(AScreenPoint);" NewObj := TMyHack(Control).ObjectAtPoint(AScreenPoint); // if NewObj <> nil then Exit(NewObj); end; *) result := nil; if TMyHack(AControl).PointInObject(LP.X, LP.Y) then // and TMyHack(AControl).CheckHitTest(AControl.HitTest) then result := AControl; end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); var LControl : IControl; LControlAtPoint: IControl; LMousePos : TPointF; begin LMousePos := Screen.MousePos; Memo1.Text := Format('%s -> Mouse cursor at: %f x %f', [TimeToStr(now), LMousePos.X, LMousePos.Y]); // LControl := Self.ObjectAtPoint(LMousePos); // if (LControl <> nil) then Memo1.Lines.Add('LControl = ' + TControl(LControl).ToString) // else // trying find TControls (TButton in this case) with "HitTest = false or true" begin for var I: Integer := 0 to (Self.ChildrenCount - 1) do begin if not(Self.Children[I] is TButton) then Continue; // if Supports(Children[I], IControl, LControl) and (LControl <> nil) then begin LControlAtPoint := MyObjectAtPoint(TControl(LControl), LMousePos); // if (LControlAtPoint <> nil) then Memo1.Lines.Add('Control at Point = ' + TControl(LControlAtPoint).ToString); end; end; end; end;
  24. programmerdelphi2k

    Form ObjectAtPoint() does not working or "me" not working :)

    nope! nope!
  25. programmerdelphi2k

    StringGrid - possible to make a drag/move of rows feature?

    hi @JohnLM first, in FMX StringGrid/Grid all values is a "string" by default! each column is independent each other there is not "row concept", but "Cols with lines"... Then, you has many "lines" in a column! you can try using "mouse event" or drag'n'drop! here my sample using "mouse event": Here, I'm not testing if the values are OK, or if it's the same line, etc... just showing a general idea of the process! The rest is up to you! // FMX StringGrid using mouse event to "move" content of each "row" in all columns type TMyCellsData = TArray<string>; TRecRowContent = record FRow: integer; // what is the row? FData: TMyCellsData; // what is the data? = all in string representation end; var LRowSrcContent: TRecRowContent; LRowTrgContent: TRecRowContent; LRowMoving : boolean = false; procedure TForm1.FormCreate(Sender: TObject); begin StringGrid1.OnMouseDown := MyOnMouseDown; StringGrid1.OnMouseUp := MyOnMouseUp; // StringGrid1.Options := StringGrid1.Options + [TGridOption.RowSelect]; // avoid "edit cell" on click! end; // simulating a rowwwwwwwwwwwwwwwwwwww....... in col1 + col2 + col3 + ... procedure MyGetWholeRow(AStringGrid: TStringGrid; ARow: integer; out AMyCellsData: TRecRowContent); begin AMyCellsData.FRow := ARow; // what is the row? AMyCellsData.FData := []; // clear old-datas // for var i: integer := 0 to (AStringGrid.ColumnCount - 1) do AMyCellsData.FData := AMyCellsData.FData + [AStringGrid.Cells[i, ARow]]; end; procedure TForm1.MyOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin inherited; // if (ssCtrl in Shift) then // using "Ctrl" just for test begin MyGetWholeRow(StringGrid1, StringGrid1.RowByPoint(X, Y), LRowSrcContent); // LRowMoving := true; end; end; procedure TForm1.MyOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); var LRow: integer; begin inherited; // if LRowMoving and (ssCtrl in Shift) then begin LRow := StringGrid1.RowByPoint(X, Y); // MyGetWholeRow(StringGrid1, LRow, LRowTrgContent); // before override row-datas // for var i: integer := 0 to high(LRowSrcContent.FData) do // move data StringGrid1.Cells[i, LRowTrgContent.FRow] := LRowSrcContent.FData[i]; // for var i: integer := 0 to high(LRowTrgContent.FData) do // restore row-datas StringGrid1.Cells[i, LRowSrcContent.FRow] := LRowTrgContent.FData[i]; end; // LRowMoving := false; LRowSrcContent.FRow := -1; LRowSrcContent.FData := []; LRowTrgContent.FRow := -1; LRowTrgContent.FData := []; end;
×