ptlycldy 1 Posted November 27, 2022 (edited) I'm new to FMX (VCL is easier) but I've encountered a problem and all the Embarcadero wiki's don't seem to help. I have a FMX TEdit box with text. I can position the text to "Center" in the box at design time by going to TextSettings->HorzAlign->Center in the object inspector and all goes well. It compiles. But I would like to change the alignment at runtime in the code when a button is clicked. The code I use is : Edit1->TextSettings->HorzAlign = Leading ; //Leading means left justified and the error message on compiling is: use of undeclared identifier 'Leading' I have included the file FMX.Types.hpp which should (does: I checked) tell the compiler about Leading. Where Leading is given as "enum class DECLSPEC_DENUM TTextAlign : unsigned int { Center, Leading, Trailing }; " in the embarcadero wiki at FMX.Types.TTextAlign - RAD Studio API Documentation (embarcadero.com) (Sorry folks-- I'm a C++ guy but this should be the same problem for you Delphi folks as well) So I added the code: unsigned int Center, Leading, Trailing; Center = 0; Leading = 1; Trailing = 2; And get error: cannot initialize a parameter of type 'FMX::Types::TTexAlign' with an lvalue of type 'unsigned int' What am I doing wrong? But more important, how can I get the Edit box to change alignment during runtime? Thanks for your ideas. Ptlycldy Edited November 27, 2022 by ptlycldy Share this post Link to post
Serge_G 87 Posted November 27, 2022 Hi, You need to give the type of the enumeration, use Edit1->TextSettings->HorzAlign =TTextAlign.Leading Edit1.TextSettings.HorzAlign :=TTextAlign.Leading 28 minutes ago, ptlycldy said: I'm new to FMX (VCL is easier) It's only some ways to change. I use Delphi from D3 version, my new applications are all FMX, it took me 1-2 years to take the plunge, but now I much prefer FMX 1 Share this post Link to post
programmerdelphi2k 237 Posted November 27, 2022 (edited) some "enumerates" needs "spacenames" for use, or you can have a "conflict" between same "enumerate name" in many others units! then, try always use "enumarateNameSpaces.enumerateValue", like: TMyEnumX.meTwo other way to use enumerates, if no "out of range" from enumerate in usage, is: implementation /// DELPHI code {$R *.dfm} type TMyEnumX = (meOne, meTwo); // <------- procedure ShowMePlease; var MyEnumX : TMyEnumX; MyVarInt: integer; begin MyVarInt := 4; // <------- it will 5º element, if exists on enumerate type above! // MyEnumX := TMyEnumX( MyVarInt ); // <------- OUT OF RANGE here, but not error! // ShowMessage( Ord(MyEnumX).ToString ); // no errors here!! end; end. Edited November 27, 2022 by programmerdelphi2k Share this post Link to post