working on it ...

Filters

Explore Public Snippets

Sort by

Found 11 snippets matching: firemonkey

    public by FMXExpress modified Nov 13, 2014  9029  92  7  1

    Non Blocking Message Dialog For Delphi XE7 Firemonkey

    MessageDlg(‘Do you want to press yes or no?’, System.UITypes.TMsgDlgType.mtInformation,
      [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
        procedure(const AResult: TModalResult)
        begin
          case AResult of
            { Detect which button was pushed and show a different message }
            mrYes:
                begin
                // pressed yes
                end;
            mrNo:
                begin
                // pressed no
                end;
          end;
        end
      );
    // code here would get executed right away

    public by FMXExpress modified Nov 12, 2014  7125  9  9  4

    Install A Shortcut On Android With Delphi XE5 Firemonkey

    http://www.fmxexpress.com/install-shortcuts-on-the-android-home-screen-with-delphi-xe5-firemonkey/
    //Android permission required:
    //<uses-permission android:name=”com.android.launcher.permission.INSTALL_SHORTCUT”/>
        
    Uses
    Androidapi.JNI.GraphicsContentViewText, FMX.Helpers.Android,
    Androidapi.JNI.JavaTypes, FMX.Platform.Android, AndroidApi.JniBridge, AndroidApi.Jni.App,
    AndroidAPI.jni.OS;
    
    {$IFDEF ANDROID}
    var
    ShortcutIntent: JIntent;
    addIntent: JIntent;
    wIconIdentifier : integer;
    wIconResource : JIntent_ShortcutIconResource;
    {$ENDIF}
    begin
    {$IFDEF ANDROID}
    
    ShortcutIntent := TJIntent.JavaClass.init(SharedActivityContext, SharedActivityContext.getClass);
    ShortcutIntent.setAction(TJIntent.JavaClass.ACTION_MAIN);
    
    addIntent := TJIntent.Create;
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_INTENT, TJParcelable.Wrap((shortcutIntent as ILocalObject).GetObjectID));// here we need to cast the intent as it’s not done in delphi by default, not like java
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_NAME, StringToJString(Application.Title));
    addIntent.setAction(StringToJString(‘com.android.launcher.action.INSTALL_SHORTCUT’));
    // get icon resource identifier
    wIconIdentifier := SharedActivity.getResources.getIdentifier(StringToJString(‘ic_launcher’), StringToJString(‘drawable’), StringToJString(‘com.embarcadero.HeaderFooterApplication’)); // if the app name change, you must change the package name
    wIconResource := TJIntent_ShortcutIconResource.JavaClass.fromContext(SharedActivityContext, wIconIdentifier);
    // set icon for shortcut
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_ICON_RESOURCE, TJParcelable.Wrap((wIconResource as ILocalObject).GetObjectID));
    
    SharedActivityContext.sendBroadcast(addIntent);
    
    {$ENDIF}
     

    public by FMXExpress modified Nov 12, 2014  4230  17  6  1

    Decode GZIP Content From TRESTClient In Delphi XE7 Firemonkey

    RESTClient.AcceptEncoding := 'gzip, deflate';
    RESTClient.Execute;
    
    if RESTResponse.ContentEncoding=’gzip’ then
    DecodeGZIPContent(RESTResponse.RawBytes) // decode and do something with the content
    else
    RESTResponse.Content; // do something with the content
    
    function DecodeGZIPContent(RawBytes: System.TArray<System.Byte>): String;
    var
    MSI: TMemoryStream;
    MSO: TStringStream;
    begin
    MSI := TMemoryStream.Create;
    MSO := TStringStream.Create;
    MSI.WriteData(RawBytes,Length(RawBytes));
    MSI.Seek(0,0);
    // Zlib is a TIdCompressorZlib
    Zlib.DecompressGZipStream(MSI,MSO);
    MSI.DisposeOf;
    MSO.Seek(0,0);
    Result := MSO.DataString;
    MSO.Free;
    end;

    public by FMXExpress modified Nov 12, 2014  4682  2  7  1

    Process Strings Using A Parallel For Loop In Delphi XE7 Firemonkey

    TParallel.For(0,1000,
     procedure(I: Integer)
      begin
       TThread.Queue(TThread.CurrentThread,
        procedure
         begin
          Memo1.Lines.Append(I.ToString);
         end);
      end);

    external by Haruyuk Mohri modified Jul 24, 2015  662  0  3  0

    C++Builder XE8 (Win32) FireMonkey Form->Sort() template

    C++Builder XE8 (Win32) FireMonkey Form-Sort() template: form_sort_template.cpp
    //typedef int __fastcall TFmxObjectSortCompare(TFmxObject* Item1, TFmxObject* Item2);
    enum _DummyType{};
    template <typename INTF, typename Sorty,
    	typename R,
    	typename P1 = _DummyType,
    	typename P2 = _DummyType>
    class TAho : public TCppInterfacedObject<INTF>
    {
    private:
    	Sorty callback;
    public:
    	TAho(Sorty _callback){}// : callback(_callback) {}
    	INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
    
    	R __fastcall Invoke(P1* p1, P2* p2)
    	{
    		return callback(p1,p2);
    	}
    };
    
    
    

    external by Horácio Filho (Fofofly) modified Feb 23, 2016  185  0  2  0

    Delphi FireMonkey

    Delphi FireMonkey: gistfile1.txt
    http://www.gesource.jp/weblog/?tag=delphi
    
    

    external by ortuagustin modified Aug 21, 2016  148  0  2  0

    Firemonkey constraint

    Firemonkey constraint: FMX.Layout.Constraint.pas
    // Source: http://delphiaccess.com/foros/index.php/topic/12206-alguien-conoce-algo-análogo-a-constraint-de-vcl/
    // Author: @genriquez
    
    unit FMX.Layout.Constraint;
    
    type
      TLayout = class(FMX.Layouts.TLayout)
      private
        FConstraint: TPoint;
        procedure SetConstraint(const Value: TPoint);
      protected
         procedure HandleSizeChanged; Override;
      public
         Property Constraint: TPoint read FConstraint write SetConstraint;
      end;
    
    implementation
    
    { TLayout }
     
    procedure TLayout.HandleSizeChanged;
    begin
      If (FConstraint.X > 0) and (Width < FConstraint.X) then
         Width := FConstraint.X;
     
      If (FConstraint.Y > 0) and (Height < FConstraint.Y) then
         Height := FConstraint.Y;
     
      inherited;
    end;
     
    procedure TLayout.SetConstraint(const Value: TPoint);
    begin
      FConstraint := Value;
    end;
    
    

    external by plxhelpme_kindofuser modified Sep 29, 2016  1  0  2  0

    TListView DynamicAppearance with TImageObjectAppearance will not view image when using LiveBindingsDesigner with TFDMemTable

    I am welcoming Embarcaderos efforts to make TListView more dynamically, and was exited to see Sarina Duponts post here where you could just link the imageindex to the TListView properties in LiveBindings Designer, and even the image property to a datafield (integer) when using DynamicAppearance and TImageObjectAppearance. But... I tried, and did
    /* 
    I usually try to avoid LiveBindings. The fastest, most stable and easiest way is to add items using code. 
     */
        ListView1->BeginUpdate();
    
    try {
        for (int i = 0; i <   arrayOfThings->item.Length; i++) {
            TListViewItem* item = ListView1->Items->Add();
    
            item->Text = arrayOfThings->item[i]->item_name;
            item->Data["itemName"]  = TValue::From<UnicodeString>( arrayOfThings->item[i]->item_name);
            item->Data["itemId"]        = TValue::From<UnicodeString>( IntToStr( arrayOfThings->item[i]->id ));
            item->Data["itemDate"]      = TValue::From<UnicodeString>(arrayOfThings->item[i]->item_date);
    // adding the image - imgClock is name of the image field [TImageObjectAppearance ] added to items in ItemAppearance in the TListView object that uses DynamicAppereance
            const UnicodeString imgClock = L"imgClock";
            dynamic_cast<TListItemImage*>(item->Objects->FindDrawable(imgClock))->Bitmap = //bitmap source;
        }
    } catch (...) {
    
    }
    ListView1->EndUpdate();
    
    
    /* 
    
     */
    

    external by Sean B. Durkin modified Jan 13, 2015  1  0  2  0

    Lockbox 3 for Android with XE7 not working

    I just found that lockbox 3.6.0 should support Android. However when i look in my palette i see that the codec only supports win32 and win64. How can i make it work for my android apps also? Im using Delphi XE7 and have already followed the installation instructions supplied in the package. For a windows app it works just fine.
    /* 
    You have two options:
    
    (1) Run-time
    
    You can always create the components at run-time. There is an example on the website on how to do it, and I copy a fragment of this example below. Just replace the ShowMessage() functions with whatever is appropriate ...
     */
    procedure EncryptAStream( Plaintext, Ciphertext: TStream);
    var
     Codec1: TCodec;
     CryptographicLibrary1: TCryptographicLibrary;
    begin
    ShowMessage( 'Demonstration of How to Encrypt a Stream with TurboPower LockBox 3.');
    Codec1 := TCodec.Create( nil);
    CryptographicLibrary1 := TCryptographicLibrary.Create( nil);
    Codec1.CryptoLibrary  := CryptographicLibrary1;
    Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
    Codec1.BlockCipherId  := 'native.AES-256';
    Codec1.ChainModeId    := uTPLb_Constants.CBC_ProgId;
    Codec1.Password := 'my utf-16le password';
    
    // Codec1.Reset;  Reset if you are continuing from a previous encryption operation.
    Codec1.EncryptStream( Plaintext, Ciphertext);
    // Codec1.Burn;   Burn if you need to purge memory of sensitive data.
    
    Ciphertext.Position := 0;
    
    ShowMessageFmt(
     'The ciphertext for AES-256 with CBC chaining'#13#10 +
     ' of plaintext ''banana'' (UTF-8 encoding),'#13#10 +
     ' and password ''my utf-16le password'' (UTF-16LE encoding),'#13#10 +
     ' prepended by 64 bit nonce, (being the IV),'#13#10 +
     ' and rendered for display in base64 is ...'#13#10 +
     '%s', [Stream_to_Base64( Ciphertext)]);
    
    Codec1.Free;
    CryptographicLibrary1.Free;
    end;
    
    
    /* 
    (2) Design-time
    
    A little bit of tweaking is required to get the components onto the palette for Android. This will be done for you in the next version of TPLockbox 3 to be released, but for now, here is the procedure ...
    
    
    Remove vcl, vclimg and dbrtl from the TPLB3 run-time requirements.
    For the run-time package, add the Android target platform, and make it the active one. But of course, don't add this platform to the design-time package.
    The binary product for the run-time should be named libTP_LockBox3_XE7.so, where XE7 is a place-marker for your compiler version.
    Preface the declarations for the two components (TCodec and TCryptographicLibrary) with
     */
    [ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator or pidiOSDevice or pidAndroid)]
    TCodec = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher,
                     { etc. }
    
    
    /* 
    This is the key to the whole thing. The ComponentPlatformsAttribute attribute declares what platforms should the component be displayed for, on the palette. If not declared, I believe that the default is pidWin32 or pidWin64, but I cannot point to any official documentation to support this.
    
    
    Recompile the run-time package. Remember that if your are compiling with MS-BUILD, on certain compiler versions, you need to save-all before you can successfully compile.
    Go to the IDE Tools | Options and open the Library Path for the Android platform. Make sure that this path include the location of where you put the dcu files for the Android case. For example, on my installation it is ...
    
    C:\Dev\TPLB\work-products\ephemeral\dcu\XE6\Android
    
    
    You should physically check this directory. It should have a file named TPLB3.AES.dcu and another named TPLB3.AES.so for example.
    
    
    Recompile and re-install the design-time package
    Open your mobile project. Slap design-time components for TCodec and TCryptographicLibrary on your Android forms. Proceed as you would for a windows application.
     */
    

    external by StackOverflow modified Feb 24, 2016  1  0  2  0

    TFDMemTable and ListView

    I created a firemonkey (XE8) application. My app reads data from XML file and populate a memTable from this. The memTable is binding a ´ListView´. All works fine, but this process is very slow. I try using a progressbar, but when run the repeat loop, "freezes the application" and back to work when the ListView is completely filled. How I can f
    /* 
    Live Binding is not quick, especially when a multi-row GUI component like a listview is involved. And loading the data into the dataset via the listview is a particularly inefficient way of doing it. 
    
    What I'd try is disconnecting the bindings (in code) from the FDMemTable, loading the data directly into the FDMemTable, rather than into the listview, and then re-connecting the bindings to the FDMemTable.
     */
    
    • Public Snippets
    • Channels Snippets