working on it ...

Filters

Explore Public Snippets

Sort by

Found 596 snippets

    public by FMXExpress modified Nov 13, 2014  9405  95  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  7741  10  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  4501  20  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  4910  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 Michalis Kamburelis modified Feb 19, 2018  17  0  1  0

    Test TCastleImageControl

    Test TCastleImageControl: testing_img.lpr
    uses CastleControls, CastleWindow, CastleFilesUtils, CastleColors;
    var
      Window: TCastleWindowCustom;
      Bg: TCastleSimpleBackground;
      Image: TCastleImageControl;
    begin
      Window := TCastleWindowCustom.Create(Application);
      Window.Open;
    
      Bg := TCastleSimpleBackground.Create(Application);
      Bg.Color := Yellow;
      Window.Controls.InsertFront(Bg);
    
      Image := TCastleImageControl.Create(Application);
      Image.URL := ApplicationData('Input.png');
      Window.Controls.InsertFront(Image);
    
      Application.Run;
    end.
    
    
    

    external by Github modified Feb 16, 2018  24  0  1  0

    dosya açıklaması

    dosya açıklaması: dosya_adi.pas
    Türkçe içerik
    
    

    external by saymeenm modified Feb 16, 2018  5  0  1  0

    C Triangulo de pascal

    C Triangulo de pascal: Triangulo de pascal
    /*  { n!/(n-p)!p! }
    Elaborar um algoritmo que imprima um triangulo de pascal baseado em
    um modelo dado na aula. Usando vetor dinamico e melhorando a função fat.
    */
    #include<stdio.h>
    #include<stdlib.h>
    	
    	int coluna, **pm, diag, vet, quant, n;
    	//FATORAÇÃO
    	int fat (int i, int j){
    		int m, f1, f2, f3;
    		for (m=i;m>=1;m--){
    			int f1=f1*m;
    		}
    		for (m=j;m>=1;m--){
    			int f2=f2*m;
    		}
    		for (m=(i-j);m>=1;m--){
    			int f3=f3*m;
    		}
    	m=f1/(f2*f3);
    	}	
    		int matriz(int linha){
    			int i, j;
    		for(i=1;i<=linha;i++){
    			for(j=1;j<=linha;j++){
    				pm[i][j];
    			}
    			pm[i][j]=fat (i,j);
    		}
    	}
    	//Quantidade de linhas do triangulo.
    	int entrar (int pm[n]){
    		int linha;
    		printf("Digite a ultima linha do triangulo a qual deseja:  /n ");
    		scanf("%d", &linha);
    		//Alocar vetor principal
    		pm= (int **) malloc(linha*sizeof(sizeof(int*)));
    		//Alocor cada vetor linha
    		for(int n=0;n>linha;n++){
    			pm[n]=(int*)malloc(linha*sizeof(int));
    		}
    		//Chamando a matriz
    		for(int x=0;x<=linha;x++){
    			matriz(linha);
    		}
    	}
    	
    	int main(){
    		int linha;
    	for(int i=0;i<linha;i++){
    		for(int j=0;j<linha;j++)
    			cout << pm[i][j] << ".";
    		/*  1.
    			1.2.1
    			1.2.2.1*/
    		cout << endl;
    	}	
    	return 0;
    }
    
    
    

    external by freeonterminate modified Feb 7, 2018  16  0  1  0

    TStringGrid をソートするサンプルコード

    TStringGrid をソートするサンプルコード: PK.StringGrid.Helper.pas
    (*
     * TStringGrid をソートするサンプルコード
     *
     * Copyright (c) 2018 HOSOKAWA Jun.
     *
     * HOW TO USE:
     *   1. Add PK.StringGrid.Helper to uses block.
     *   2. Call StringGrid.SortByColumn(Column)
     *
     * EXAMPLE:
     *   uses
     *     PK.StringGrid.Helper;
     *
     *   procedure TForm1.FormCreate(Sender: TObject);
     *   begin
     *     StringGrid1.RowCount := 4;
     *
     *     StringGrid1.Cells[0, 0] := '222';
     *     StringGrid1.Cells[0, 1] := '333';
     *     StringGrid1.Cells[0, 2] := '111';
     *     StringGrid1.Cells[0, 3] := '000';
     *
     *     StringGrid1.Cells[1, 0] := 'ddd';
     *     StringGrid1.Cells[1, 1] := 'ccc';
     *     StringGrid1.Cells[1, 2] := 'aaa';
     *     StringGrid1.Cells[1, 3] := 'bbb';
     *
     *     StringGrid1.Cells[2, 0] := 'DDD';
     *     StringGrid1.Cells[2, 1] := 'BBB';
     *     StringGrid1.Cells[2, 2] := 'CCC';
     *     StringGrid1.Cells[2, 3] := 'AAA';
     *   end;
     *
     *   procedure TForm1.StringGrid1HeaderClick(Column: TColumn);
     *   begin
     *     StringGrid1.SortByColumn(Column);
     *   end;
     *
     * LICENSE:
     *   本ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、
     *   何らの保証もなく提供されます。
     *   本ソフトウェアの使用によって生じるいかなる損害についても、
     *   作者は一切の責任を負わないものとします。
     *
     *   以下の制限に従う限り、商用アプリケーションを含めて、本ソフトウェアを
     *   任意の目的に使用し、自由に改変して再頒布することをすべての人に許可します。
     *
     *   1. 本ソフトウェアの出自について虚偽の表示をしてはなりません。
     *      あなたがオリジナルのソフトウェアを作成したと主張してはなりません。
     *      あなたが本ソフトウェアを製品内で使用する場合、製品の文書に謝辞を入れて
     *      いただければ幸いですが、必須ではありません。
     *
     *   2. ソースを変更した場合は、そのことを明示しなければなりません。
     *      オリジナルのソフトウェアであるという虚偽の表示をしてはなりません。
     *
     *   3. ソースの頒布物から、この表示を削除したり、表示の内容を変更したりしては
     *      なりません。
     *
     *   This software is provided 'as-is', without any express or implied warranty.
     *   In no event will the authors be held liable for any damages arising from
     *   the use of this software.
     *
     *   Permission is granted to anyone to use this software for any purpose,
     *   including commercial applications, and to alter it and redistribute
     *   it freely, subject to the following restrictions:
     *
     *   1. The origin of this software must not be misrepresented;
     *      you must not claim that you wrote the original software.
     *      If you use this software in a product, an acknowledgment in the product
     *      documentation would be appreciated but is not required.
     *
     *   2. Altered source versions must be plainly marked as such,
     *      and must not be misrepresented as being the original software.
     *
     *   3. This notice may not be removed or altered from any source distribution.
     *)
    
    unit PK.StringGrid.Helper;
    
    interface
    
    uses
      FMX.Grid;
    
    type
      TStringGridHelper = class helper for TStringGrid
      public
        procedure SortByColumnNo(const iCol: Integer);
        procedure SortByColumn(const iColumn: TColumn);
      end;
    
    implementation
    
    uses
      System.SysUtils;
    
    { TStringGridHelper }
    
    procedure TStringGridHelper.SortByColumnNo(const iCol: Integer);
    
      procedure QuickSort(iLo, iHi: Integer);
      var
        Min, Max, Mid: Integer;
        tmpStr: String;
        i: Integer;
      begin
        repeat
          Min := iLo;
          Max := iHi;
          Mid := (iLo + iHi) shr 1;
    
          repeat
            while CompareStr(Cells[iCol, Min], Cells[iCol, Mid]) < 0 do
              Inc(Min);
    
            while CompareStr(Cells[iCol, Max], Cells[iCol, Mid]) > 0 do
              Dec(Max);
    
            if (Min <= Max) then
            begin
              for i := 0 to ColumnCount - 1 do
              begin
                tmpStr := Cells[i, Min];
                Cells[i, Min] := Cells[i, Max];
                Cells[i, Max] := tmpStr;
              end;
    
              if (Mid = Min) then
                Mid := Max
              else if (Mid = Max) then
                Mid := Min;
    
              Inc(Min);
              Dec(Max);
            end;
          until (Min > Max);
    
          if (iLo < Max) then
            QuickSort(iLo, Max);
    
          iLo := Min;
        until (Min >= iHi);
      end;
    
    begin
      QuickSort(0, RowCount - 1);
    end;
    
    procedure TStringGridHelper.SortByColumn(const iColumn: TColumn);
    var
      Col: Integer;
      i: Integer;
    begin
      // ソート元になるコラムを探す
      Col := -1;
      for i := 0 to ColumnCount - 1 do
        if (Columns[i] = iColumn) then
        begin
          Col := i;
          Break;
        end;
    
      if (Col < 0) then
        Exit;
    
      SortByColumnNo(Col);
    end;
    
    end.
    
    

    external by unilecs modified Feb 2, 2018  21  0  1  0

    Задача 66: Степень двойки (@jinxonik)

    Задача 66: Степень двойки (@jinxonik): GetN.pas
    {$APPTYPE CONSOLE}
    //{$DEFINE ENTERLEN}
    const
      HugeNumber = 1E4000;
    
    var
    {$IFNDEF ENTERLEN}
      SourceStr: String;
    {$ENDIF}
      Power, SourceLen, CurValLen, TotalLen: Integer;
      CurValue, ControlVal: Extended;
    
    begin
    {$IFNDEF ENTERLEN}
      Write('Enter source string: ');
      ReadLn(SourceStr);
      SourceLen := Length(SourceStr);
    {$ELSE}
      Write('Enter source string length: ');
      ReadLn(SourceLen);
    {$ENDIF}
      if SourceLen <= 0 then WriteLn('String is empty!')
      else
      begin
        Power := 1;
        CurValLen := 1;
        TotalLen := 1;
        CurValue := 2;
        ControlVal := 10;
        while TotalLen < SourceLen do
        begin
          CurValue := CurValue * 2;
          if CurValue >= ControlVal then
          begin
            Inc(CurValLen);
            if ControlVal >= HugeNumber then
            begin
              CurValue := CurValue / HugeNumber;
              ControlVal := ControlVal / HugeNumber;
            end;
            ControlVal := ControlVal * 10;
          end;
          Inc(Power);
          Inc(TotalLen, CurValLen);
        end;
        WriteLn('Power of last number is ', Power, ' (last power value length is ', CurValLen, ' digits)');
      end;
    end.
    
    

    external by Github modified Jan 30, 2018  3  0  1  0

    The United States <a href=" http://yourpetscomfort.com/index.php?valium-suppositories-for-pelvic-floor-dysfunction ">diazepam with food</a> Pascal, in a statement on Thursday, apologized and said heremails were "insensitive and inappropriate." She tol...

    The United States diazepam with food Pascal, in a statement on Thursday, apologized and said heremails were "insensitive and inappropriate." She told theHollywood Reporter she reached out to Sharpton and ReverendJesse Jackson and wanted to start "a healing process." : Titus
    The United States <a href=" http://yourpetscomfort.com/index.php?valium-suppositories-for-pelvic-floor-dysfunction ">diazepam with food</a>  Pascal, in a statement on Thursday, apologized and said heremails were "insensitive and inappropriate." She told theHollywood Reporter she reached out to Sharpton and ReverendJesse Jackson and wanted to start "a healing process."
     
    
    
    • Public Snippets
    • Channels Snippets