Category: StackOverflow

How to LiveBind Firemonkey TListbox that has a Custom Style?

  

By eelias Following the EMB example “Custom List” found in “RAD Studio12.0SamplesFireMonkeyCustomListBox”

It demonstrated by code how to have Items customized on the ListBox.

Inserting one Item on the TListBox by code:

// create custom item
Item := TListBoxItem.Create(nil);
Item.Parent := ListBox1;
Item.StyleLookup := ‘CustomItem’;
Item.Text := ‘item ‘ + IntToStr(Item.Index); // set filename
if Odd(Item.Index) then
Item.ItemData.Bitmap := Image1.Bitmap // set thumbnail
else
Item.ItemData.Bitmap := Image2.Bitmap; // set thumbnail
Item.StylesData[‘resolution’] := ‘1024×768 px’; // set size
Item.StylesData[‘depth’] := ’32 bit’;
Item.StylesData[‘visible’] := true; // set Checkbox value

I want to do the same using LiveBinding exclusively.

I could success show the style and bind some of the items:

And some of the LiveBindings (using a prototype):

And this is a piece of the custom style from the delphi example:

My questions:

How can I access the other 3 defined items to fill up with data?
How can I get the event from the Button and CheckBox (both going to same event handler)
How can I make that works in a frame? There is no working StyleBook component at design time
Bonus question 🙂

Is it possible to have all above working with a StyleBook exclusive for this …read more

Via: StackOverflow

Read More

How loop a sound seamlessly in Firemonkey (FMX)?

  

By Anthony Burg How do you loop a sound seamlessly using the TMediaPlayer in Firemonkey (using XE6, C++ Builder)?

What I am doing so far is using a TTimer which checks

if (MediaPlayer->CurrentTime >= MediaPlayer->Media->Duration)
{
MediaPlayer->CurrentTime = 0;
MediaPlayer->Play ();
}

but this doesn’t create a seamless loop, even when the TTimer’s Interval is set to 1.

Any ideas? …read more

Via: StackOverflow

Read More

TMediaPlayer and TMediaPlayerControl don’t seem to work for Delphi FireMonkey iOS/Android?

  

By DavidMWilliams I have a Delphi XE6 FireMonkey project, intending to play videos on iOS and Android devices.

In my form I have TMediaPlayerControl and TMediaPlayer controls.

My code to play the video (passed in) is

MediaPlayer1.FileName := TPath.GetDocumentsPath + PathDelim + s;
Label1.Text := IntToStr(MediaPlayer1.Media.VideoSize.Truncate.X) + ‘x’ +
IntToStr(MediaPlayer1.Media.VideoSize.Truncate.Y) +
‘px ‘ + IntToStr(MediaPlayer1.Media.Duration div MediaTimeScale) + ‘ms’;
TrackBar1.Max := MediaPlayer1.Media.Duration;

MediaPlayer1.Play;

The intention is that a label will show the resolution of the video and the trackbar will show the length of the video.

Yet, the Label shows as 0x0 and the trackbar has value 0.

Now, if I set the MediaPlayer property of the TMediaPlayerControl, ie

MediaPlayerControl1.MediaPlayer := MediaPlayer1;

the video does not play at all. Nothing happens. If I clear that property, then the video does play but only in an uncontrolled window in the middle of the screen, ignoring the TMediaPlayerControl entirely.

This code works with a FireMonkey Windows app but it seems it does not work for iOS or Android.

Am I doing something fundamentally wrong or is this just broken? In which case how do you play videos in FireMonkey for iOS/Android?

Thank you! …read more

Via: StackOverflow

Read More

How can I create a list of panels that contains fields connect by LiveBinding to a Dataset in FireMonkey?

  

By eelias Delphi XE5 update 2

I am looking for a list of “panels” that will have the same layout (same controls) and each panel is created for each record of the DataSet existent.

I need to use LiveBindings preferably. But if that is not possible I would like to know how to do the list of panels thing.

You can see on this image below an example in a list of contacts (marked in red)

I remember that in Delphi 6 VCL we had a component that were capable of such thing, we only needed to add the required DBEdit’s and other DB Control on the first panel and it created a panel for each record of the table accordingly. …read more

Via: StackOverflow

Read More

Application Mobile in Delphi Error when load from strream

  

By elcharlie I’m doing my first application for mobile in delphi and I have a problem and can not fix it.
I have a procedure running that I load a csv file from the resorce.
When I throw this procedure, on a mobile device (I could only test it on Android) I get this error: ‘No mapping for the Unicode character exists in the Target multi-byte code page’, no error in 32-bit Windows.
Can anyone help me?
Thank you.

Here is the code, Rad Studio XE6:

procedure TContactos.LoadFromResource;
var
FicheroEntero, Linea: TStringList;
rs: TResourceStream;
I, pos: Integer;
contacto : TContacto;
begin
FicheroEntero := TStringList.Create;
Linea := TStringList.Create;
try
rs := TResourceStream.Create(HInstance,’clientes_csv’, RT_RCDATA);
FicheroEntero.LoadFromStream(rs); //Here enter in Exception
for I := 1 to FicheroEntero.Count-1 do
begin
Linea.Delimiter := ‘;’;
Linea.StrictDelimiter := True;
Linea.DelimitedText := FicheroEntero[I];
if Linea.Count >= 2 then
begin
contacto := TContacto.Create;
pos := GDListaContactos.Add(contacto);
contacto.Posicion := pos;
contacto.Codigo := StrToInt(Trim(Copy(Linea[0], 1 ,Length(Linea[0]))));
…read more

Via: StackOverflow

Read More

Mobile Application Error when loading from stream

  

By elcharlie I’m doing my first application for mobile in delphi and I have a problem and can not fix it.

I have a procedure running in which I load a csv file from the resource.
When I throw this procedure, on a mobile device (I could only test it on Android) I get this error: ‘No mapping for the Unicode character exists in the Target multi-byte code page’, no error in 32-bit Windows.

Here is the code, Rad Studio XE6:

procedure TContactos.LoadFromResource;
var
FicheroEntero, Linea: TStringList;
rs: TResourceStream;
I, pos: Integer;
contacto : TContacto;
begin
FicheroEntero := TStringList.Create;
Linea := TStringList.Create;
try
rs := TResourceStream.Create(HInstance,’clientes_csv’, RT_RCDATA);
FicheroEntero.LoadFromStream(rs); //Here enter in Exception
for I := 1 to FicheroEntero.Count-1 do
begin
Linea.Delimiter := ‘;’;
Linea.StrictDelimiter := True;
Linea.DelimitedText := FicheroEntero[I];
if Linea.Count >= 2 then
begin
contacto := TContacto.Create;
pos := GDListaContactos.Add(contacto);
contacto.Posicion := pos;
contacto.Codigo := StrToInt(Trim(Copy(Linea[0], 1 ,Length(Linea[0]))));
…read more

Via: StackOverflow

Read More

The TEdit.Height is fixed on MetropolisUI Firemonkey Style, How to change it?

  

By eelias I am using a regular Firemonkey HD application and decided to use only the
style that comes with MetropolisUI (just the style, it is not Metropolis app/form since I need it to be cross platform)

The problem is that TEdit is set to a fixed size, that is for me too big.

I have played to change the style by StyleBook, was not successful. I am
newbie with styles and firemonkey.

Have tested other option incluing Chris Holliston using the interposer
class.

However I need to reduce the height at design time, since I have many fields
and the positioning is critical

Please, I would like to know the steps to change that (I was using the
editstyle on TEdit.LookupStyle from MetropoliUIBlue) …read more

Via: StackOverflow

Read More

The TEdit.Height is fixed on Firemonkey Style, How to change it?

  

By eelias I am using a regular Firemonkey HD application and decided to use only the
style that comes with MetropolisUI (just the style, it is not Metropolis app/form since I need it to be cross platform)

The problem is that TEdit is set to a fixed size, that is for me too big.

I have played to change the style by StyleBook, was not successful. I am
newbie with styles and firemonkey.

Have tested other option incluing Chris Holliston using the interposer
class.

However I need to reduce the height at design time, since I have many fields
and the positioning is critical

Please, I would like to know the steps to change that (I was using the
editstyle on TEdit.LookupStyle from MetropoliUIBlue) …read more

Via: StackOverflow

Read More

My aplication shows nothing except a black screen

  

By user3665067 Hy, my first Adrod aplication generates number based on a key provided by the user, so it has 2 Editboxes and a litle code. It is working on all android 4.x devices I’ve tested, except the person’s tablet I made the aplication for. It doesn show anything, just a black screen. It’s an Android 4.2, Cortex A7, 1,2GHz QUAD Core tablet.

I’ve put a ShowMessage dialog in the Main Windows’s “OnPaint” event and it shows it on runtime, I click “Ok”, screen stays black and after a minute or so if I toch “Back” I get “Aplication is not responding”. On my Android phone, if I run my aplication, it keps showing the ShowMessage dialog as the main windows is redrawn, but it’s working fine.

I don’t know how to find the problem if I don’t have an error.

I am working on Delphi XE5 Update 2. Thanks, The code is below:

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
IdGlobal, IdHash, IdHashMessageDigest, FMX.Edit;

type
TMainWindow = class(TForm)
Label1Key: TLabel;
Key: TEdit;
numar: TEdit;
LabelNumber: TLabel;
PanelCentrare: TPanel;
procedure …read more

Via: StackOverflow

Read More

My application shows nothing except a black screen [on hold]

  

By user3665067 Hy, my first Android application generates a number based on a key provided by the user, so it has 2 editboxes and a little code. It is working on all Android 4.x devices I’ve tested, except the person’s tablet I made the aplication for. It doesn show anything, just a black screen. It’s an Android 4.2, Cortex A7, 1,2GHz QUAD Core tablet.

I’ve put a ShowMessage dialog in the Main Windows’s “OnPaint” event and it shows it on runtime, I click “Ok”, but the screen stays black and after a minute or so if I touch “Back” I get “Application is not responding”. On my Android phone, if I run my application, it keeps showing the ShowMessage dialog as the main windows is redrawn, but it’s working fine.

I don’t know how to find the problem if I don’t have an error.

I am working on Delphi XE5 Update 2. Thanks, The code is below:

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
IdGlobal, IdHash, IdHashMessageDigest, FMX.Edit;

type
TMainWindow = class(TForm)
Label1Key: TLabel;
Key: TEdit;
numar: TEdit;
LabelNumber: TLabel;
PanelCentrare: TPanel;
…read more

Via: StackOverflow

Read More

Form border color and thickness on Firemonkey

  

By eelias XE5, I am using the MetropolisUIBlue style in this case (not the app template just the style) and I would like to get the same effect that office 2013, where you have a very thin application form border, the title bar is there with the standard icons (close, minimize) with everything following the same form background color.

The result in office 2013 is very nice presentation (for me), that looks visually
clean and light. and you still have the border to resize the form. This border is just
a simple thin black line around the form and the windows theme selected does not interfere.

Right now by default Firemonkey has a dark huge border frame that follows windows theme. (I am in windows 8)

How can I have the color following the same form background color?
How can I reduce to minimum (if possible just a thin line) the form border?
How can I block windows to apply its themes on the form border? …read more

Via: StackOverflow

Read More