Jump to content

Ronak

Members
  • Posts

    123
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by Ronak

  1. Hello,

     

    If we show mask on form, Form1.BitBtn_Dummy1.showMask('....Wait...', Form1.FormPanel), the form will be disabled, showing the mask...

     

    I used Dummy button..

     

    First Grid->ClientEvents

    Ext.grid.EditorGridPanel

     

    function OnAfterEdit(value, originalValue, row, column)

    {

    Form1.BitBtn_Dummy1.showMask('....Wait...', Form1.UniDBGrid1 );

    }

     

    Second Grid->ClientEvents

    Ext.grid.EditorGridPanel

    function OnAfterEdit(value, originalValue, row, column)

    {

    Form1.BitBtn_Dummy1.hideMask();

    }

  2. Hello,

     

    I put a timer, but does not start at the time indicated.

    Timer triggers repetitively, it starts when enabled, not for time indicated, if so let know..

     

    Now about TimeOut.., See UniGui Demos SessionTimeout

    Try

    begin
     UniMainModule.AllowTerminate:=False;
     ProcessForm.ProcessSale();
     UniMainModule.AllowTerminate:=True;
     showmsg;
    end;

    procedure TUniMainModule.UniGUIMainModuleSessionTimeout(ASession: TObject; var ExtendTimeOut: Integer);
    begin
     if not AllowTerminate then
     begin
       ExtendTimeOut:=15000;  // extend session for another 15 seconds
     end;
    end;

  3. During design-time UniScrollBox is not showing the scrollbars, even when the controls inside the UniScrollBox are not within the box..

    it just shows the scrollbar at run-time.

    Standard TScrollBox do show the scrollbars at designtime, if required.

    if will be nice if UniScrollBox can..

  4. Jesus people, you are writing for a web browser. Just drop an image file somewhere and link to it with <img src=...> tag, thats all. Browser knows about image formats way more than you.

    That ShowImage procedure is the worst piece of code for web. So much mess for doing so little.

    It's only usefulness is when app needs to work with both web and VCL the same way. If it is not your aim, don't do that.

     

    Thanks Zilav, this is very good hint for me, I just set the UniImage.URL, fantastic property.

    procedure TMainForm.SetImageUrl(BlobFld: TField; UniImage: TUniImage; fileName: String);
    var
      Tmp,TmpFile:String;
    begin
      Tmp:= 'Tmp_' +UnitName +IntToStr(BlobFld.DataSet.RecNo) +fileName;
      TmpFile:= UniServerModule.LocalCachePath +Tmp;
      if (not FileExists(PChar(TmpFile))) then
         TBlobField(BlobFld).SaveToFile(PChar(TmpFile));
      try
         UniImage.Url:= '';
         UniImage.Refresh;
         UniImage.Url:= UniServerModule.LocalCacheURL +Tmp;
      except
      end;
    end;

  5. very good. thank you. but on the main module used for the scroll event adotable work. Can you help?

    (I use sql server database)

    if so, then you may update the Image on some other Event like UniFormCreate, OnCellClick or BtnClick by calling procedure like ShowImage above,

    here, ShowImage dose nothing but just displays the picture if possible. AfterScroll event is one good event to update the controls and if your Query/Table is on MainModule you need to find when the image can be loaded/displayed and where the procedure can be called.

     

    now, if in the MainModule, AfterScroll event is not in use and is nil then you can try like :

    unit Unit1;
    interface
    uses
    type
     TUniForm1 = class(TUniForm)
       UniImage1: TUniImage;
    
       procedure UniFormClose(Sender: TObject; var Action: TCloseAction);
       procedure UniFormCreate(Sender: TObject);
       procedure myAfterScroll(DataSet: TDataSet);  // Attn.
     private
     public
     end;
    implementation
    {$R *.dfm}
    uses MainModule, uniGUIApplication;
    
    procedure TUniForm1.myAfterScroll(DataSet: TDataSet);
    begin
      ShowImage(UniMainModule.QryMainImg1, UniImage1);
    end;
    procedure TUniForm1.UniFormClose(Sender: TObject; var Action: TCloseAction);
    begin
      UniMainModule.QryMain.AfterScroll:=nil;
    end;
    procedure TUniForm1.UniFormCreate(Sender: TObject);
    begin
      UniMainModule.QryMain.AfterScroll:=myAfterScroll;
    end;
    end.

  6. Could this produce a memory leak? I Think so, if i read this note from embarcadero:

     

     

     

    TPicture seems to use assign to make a copy (and not take ownership) of the created JpegImage-Object so that this is never be freed?!

     

     

    you are correct, I too think so, ShowImage procedure corrected.., G : TGraphic; G:= ...Create; G.Free;

     

    Thanks

  7. Dear Mediv,

     

    ERROR: Bitmap image is not valid

    is due to TUniDbImage, if the blob field do not contain BMP, or if the blob field contain other img files like JPG or PNG,

    or if the blob field contain other binary files which do not have Bitmap image, and hence the ERROR: Bitmap image is not valid.

     

    Try using TUniImage and display the Picture using ShowImage Procedure below, may call in AfterScroll event of the DS.

    I have used ShowImage Procedure in my BlobField demo project.

     

    procedure TMainForm.ShowImage(BlobFld: TField; UniImage: TUniImage);
    var
      m: TStream;
      G: TGraphic;
      FirstBytes: AnsiString;
      bValidImg:Boolean;
      Icon: TIcon ;
    begin
      UniImage.Picture.Graphic := nil;
      if BlobFld.IsNull then begin
         Exit;
      end;
      m := BlobFld.DataSet.CreateBlobStream(BlobFld, bmRead);
      if m <> nil then begin
         G := nil; 
         bValidImg:=True;
         try
            SetLength(FirstBytes, 8);
            m.Read(FirstBytes[1], 8);
            if Copy(FirstBytes, 1, 2) = 'BM' then
               G := TBitmap.Create
            else if FirstBytes = #137'PNG'#13#10#26#10 then
               G := TPngImage.Create
            else if Copy(FirstBytes, 1, 3) = 'GIF' then
               G := TGIFImage.Create
            else if Copy(FirstBytes, 1, 2) = #$FF#$D8 then
               G := TJPEGImage.Create
            else
               bValidImg:=False;
            if bValidImg then begin
               try
                  UniImage.Picture.Graphic := G;
                  m.Seek(0,0);
                  UniImage.Picture.Graphic.LoadFromStream(m);
               finally
                  G.Free;
               end;
            end else begin
               if Copy(FirstBytes, 1, 4) = #0#0#1#0 then begin
                  Icon := TIcon.Create;
                  try
                     m.Seek(0,0);
                     Icon.LoadFromStream(m);
                     UniImage.Picture.Bitmap.Width := Icon.Width;
                     UniImage.Picture.Bitmap.Height:= Icon.Height;
                     UniImage.Picture.Bitmap.Canvas.Draw(0,0,Icon);
                  finally
                     Icon.Free;
                  end;
               end;
            end;
         finally
            m.Free;
         end;
      end;
    end;

     

    Regards

  8. Dear Mediv

     

    In your test project....

     

    
    unit FormAddRecord;
    .
    .
    type
     TAddRecordForm = class(TUniForm)
     .
     .
     private
       IsImage  : Boolean;
       FDSourse : TDataSource;
       pStream: TMemoryStream; // pStream: TFileStream;
     public
     end;
    implementation
    {$R *.dfm}
    uses
     uniGUIVars, MainModule, ServerModule,  DateUtils, EncdDecd;
    
    function AddRecordForm: TAddRecordForm;
    begin
     Result := TAddRecordForm(UniMainModule.GetFormInstance(TAddRecordForm));
    end;
    
    // Load
    procedure TAddRecordForm.UniFileUploadCompleted(Sender: TObject; AStream: TFileStream);
    begin
     if IsImage then
       begin
         UniImage.Picture.LoadFromFile(AStream.FileName);
    
    //    pStream := AStream;
         pStream:=TMemoryStream.Create;
         pStream.CopyFrom(AStream,AStream.Size);
       end;
    end;
    
    // Save record
    procedure TAddRecordForm.SaveButtonClick(Sender: TObject);
    var
      BlobField: TBlobField;
    begin
    if pStream<>nil then begin
         FDSourse.DataSet.Append;
         .
         .
         BlobField := FDSourse.DataSet.FieldByName('IMG');
         BlobField.LoadFromStream(pStream);
         FDSourse.DataSet.Post;
         .
         .
         pStream.Free;
         pStream:=nil;
    end;
    end;
    
    end.
    

  9. Hi,

     

    Here I attached complete demo for, image in the database with dataControls as well as with using non-dataControls...

     

    Also, this Saves any file in a database field, displays the image if it is img,

     

    Image Supports BMP, JPG, ICO, PNG, GIF.

     

    any other binary files are saved without display....

    BlobField.rar

  10. Hi,

     

    I need ColorPicker,

     

    In the attached project, I made an attempt to use jscolor.js, I worked partially.. I mean to say worked in mainform, but not in child form,

    aslo, it starts working after I refresh the page in Browser

     

     

    Please someone help me how I can use jscolor.js ...

     

    Thanks

    JsColorPicker.rar

  11. if I have to have call delphi method then I can try something like...

     

    Demo Attached.

     

     

    // HTML CODE in UniHtmlFrame

     

    <!DOCTYPE html>

    <html>

    <head>

    <script type="text/javascript">

    function myFunction()

    {

    var bool1= MainForm.UniCheckBox1.getValue();

    if (bool1)

    {

    MainForm.UniCheckBox1.setValue('0');

    } else {

    MainForm.UniCheckBox1.setValue('1');

    }

    }

    </script>

    </head>

    <body>

     

    <input type="button" onclick="myFunction()" value="Click me" />

     

    </body>

    </html>

     

     

    ***************

     

    procedure TMainForm.UniCheckBox1Click(Sender: TObject);

    begin

    ShowMessage('UniCheckBox1Click');

    end;

     

    ***************

    methods.rar

  12. I haven't faced any problem with FastReport. Works Fine.

     

    I used Datamodule as placeholder for FrxPdfExport, frxRichObject,.......

     

    in the MainForm, just create the datamodule

    FrTools := TDataFrTools.Create(UniApplication);

     

    FrxReport component I used to put in Forms.

     

    Regards.

    post-595-0-39634700-1343109928_thumb.jpg

×
×
  • Create New...