Jump to content

ConstantGardener

Members
  • Content Count

    52
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by ConstantGardener


  1. Hi Ian,

     

    there is a DEMO TitleBarPanelDemo.dproj in my Installation.

    TLabel has its Problems in this Container. Try a TPanel instead, maybe with a TLabel inside. 

    And if you want a TMainMenu in the Titlebar use a TActionMainMenuBar and a TActionmanager. A normal TMainMenu doesn't work.


  2. procedure CreatePooledConnection;
    var
      oParams: TStrings;
    begin
      oParams := TStringList.Create;
      try
       oParams.Add('Server='+FServerName);
       oParams.Add('Database='+FDatenbank);
       oParams.Add('User_Name='+FUsername);
       oParams.Add('Password='+FPassword);
       oParams.Add('Port='+FPort.ToString);
       oParams.Add('Pooled=True');
       FDManager.AddConnectionDef(CONN_RAM_Pooled, 'MySQL', oParams);
       FDManager.Active:=True;
      finally
       oParams.Free;
      end;

    We use a "PooledConnection" for this! And then in the Thread you only use this Pooled Connection for connecting to the Database, but you must create a new TFDConnection in every thread.

     

     AConnection:=TFDConnection.Create(nil);
     try
      AConnection.ConnectionDefName:=CONN_RAM_Pooled;
      try
       AConnection.Connected:=true;
    .....

     

    • Like 2

  3. 3 hours ago, Mike Torrettinni said:

    I don't have experience with interfaces, but does this actually mean what it says: you just call SetTempCursor that creates Interface and when LongRun procedure is done, it will destroy interface automatically and re-set cursor?

    No need for local variable, no need for Interface=nil or something similar at the end of LongRun procedure that will trigger Destroy method?

    exactly!

    • Thanks 1

  4. unit uTempCursor;
    
    interface
    
    uses
      Vcl.Controls;
    
    type
      ITempCursor = interface(IInterface)
      ['{495ADE0F-EFBE-4A0E-BF37-F1ACCACCE03D}']
      end;
    
      TTempCursor = class(TInterfacedObject, ITempCursor)
      strict private
        FCursor: TCursor;
      public
        constructor Create(const ACursor: TCursor);
        destructor Destroy; override;
        class function SetTempCursor(const ACursor: TCursor = crHourGlass): ITempCursor;
      end;
    
    implementation
    
    uses
      Vcl.Forms;
    
    { TTempCursor }
    constructor TTempCursor.Create(const ACursor: TCursor);
    begin
      inherited Create();
      FCursor := Screen.Cursor;
      Screen.Cursor := ACursor;
    end;
    
    destructor TTempCursor.Destroy;
    begin
      if Assigned(Screen) then
        Screen.Cursor := FCursor;
      inherited Destroy();
    end;
    
    class function TTempCursor.SetTempCursor(const ACursor: TCursor = crHourGlass): ITempCursor;
    begin
      Result := TTempCursor.Create(ACursor);
    end;
    
    end.

    ...using somthing like this for years (the original idea is from Jeroen Pluimer's i think). Use the SetTempCursor-Function in your code, and when the interface get out of scope, the corsur changes back to the old cursor.

     

    uses uTempCursor;
    
    procedure LongRun;
    begin
     SetTempCursor;                         // the default is crHourGlass
     // do the long running stuff
    end;

     

    • Thanks 2

  5.   TfrmBase = class (TForm)
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
    
        class function Execute : boolean; virtual;
      end;
    
    class function TfrmBase.Execute: boolean;
    var Form: TfrmBase;
    begin
     Form:=Create(nil);
     try
      Result:=Form.showModal<>mrCancel;
     finally
      Form.Release;
     end;
    end;

    Inherit your forms from a BaseClass like this on.  If you need an other behavior in the actual class you override the class-function. 

    • Like 2
×