Feeds:
Posts
Comments

Archive for the ‘Delphi – Code Gear’ Category

Dear All …

You may create an application for GUI without MDI Form related due to has an animation when creating or resizing like maximize or minimize on it … but :mrgreen: we have another tricky to reduce the animation on MDI Form … another posts … :mrgreen:

Now, we talk about Frame …

Frame is inheritance from TForm class, you may use as usual, but this TFrame doesn’t have event onShow and onHide, so we can tricked it when it created.

Frame is different with Form, when from call using myForm.show event, but how about Frame ??? you never find it when type Frame. (dot) ..

Here … create the frame is :

var
  F: TFrame;
begin
  F := TFrame.Create(Self);
  F.Parent := Panel1;
end;

Now, for example, how about you have one label to make it move into right of Frame when your frame is resized ???

When you trigger the frame when it created, you may never get you want, the label will move into right position when it frame is created, but when you showing it, the label never moving into correct position…

But, don’t be panic if you cannot get what you want… you may get trick at your frame using messages.

Put at private sections :

procedure CMShowingChanged(var M: TMessage); message CM_SHOWINGCHANGED;

then , complete the procedure like this :

procedure TFrame1.CMShowingChanged(var M: TMessage);
begin
  inherited;
  if Showing then
  begin
    // ... put your onShow code here
  end
  else
  begin
    // ... put your onHide code here
  end;
end;

That’s all falks … next posts will how to avoid the animation on MDIChild form

Have a nice coding,
😎
Man’z

Advertisements

Read Full Post »

Dear All,

After we trying the previous technique, we have face the problem … But, Fortunately we found the way to change it and running smoothly … :mrgreen:

Change the step and you will find the (maybe) good solutions … :mrgreen: but still have one problem when handling the big data aware …

First alias ka hiji kieu :

put one procedure at Public Level:

public
 { Public declarations }
 procedure UpdateGambar(AView: TcxGridTableView; ARecordIndex: integer);

kemudian, create the code like shown below, in previous post we put this code at GetProperties event :

procedure TForm8.UpdateGambar(AView: TcxGridTableView; ARecordIndex: integer);
var
 AValue: string;
 APicture: TPicture;
 AFileName : string;
begin
 AView.DataController.PostEditingData;
 AFileName := 'C:\Manz\Projects\Web\hrms\public_html\images\photo\' +
 VarToStr(AView.DataController.Values[ARecordIndex, cxGrid1DBTableView1nip.Index]) + '.jpg';
 if FileExists(aFileName) then
 begin
   APicture := TPicture.Create;
   try
     APicture.LoadFromFile(AFileName);
     SavePicture(APicture, AValue);
   finally
     FreeAndNil(APicture);
   end;
 end
 else AValue := '';

 AView.DataController.Values[ARecordIndex, cxGrid1DBTableView1Column1.Index] := AValue;
end;

next, at event onPropertiesEditValueChanged at column Image on File, put this code like shown below :

procedure TForm8.cxGrid1DBTableView1Column1PropertiesEditValueChanged(
 Sender: TObject);
var
 AIndex: Integer;
begin
 AIndex := cxGrid1DBTableView1.DataController.FocusedRecordIndex;
 UpdateGambar(cxGrid1DBTableView1, AIndex);
end;

next, at event Form Create put this code like shown below :

procedure TForm8.FormCreate(Sender: TObject);
var
 i: integer;
begin
 for i := 0 to cxGrid1DBTableView1.DataController.RecordCount - 1 do
 UpdateGambar(cxGrid1DBTableView1, i);
end;

After that, you may running your project  …. and … tadaaaa…. , smooth scrolling in the grid without knowing the error will be appear :mrgreen:

But, this the problem when handling the big data aware, cause will be loaded slowly …, you may filtering your data table or query with the limit. :mrgreen:

That’s all folks, … gitu azah dach … sekian dan terima kasih .. jangan lupa donat nya ya weekekekekekek :mrgreen:

Salam Coderz,
😎
Man’z

Read Full Post »

Dear All,

Met ketemu lagi dalam acara Delphi Coderz … :mrgreen:

Kemarin, ada dari temen bro @ImanD mengenai bagaimana memunculkan gambar bukan dari database saja, akan tetapi dari file juga, soalnya kita pengguna Developer Express Quantum Grid.

Setelah membaca dan mengurai dari keterangan Knowledge Basenya Developer Express. Akhirnya bisa ditampilkan apa yang diinginkan … sebelumnya mah udah jalan tapi gak bisa munclu gambarnya :mrgreen:

Nah, sekarang daripada ngomong gak karuan langsung saja, kita buat project baru dan simpan deh komponen yang diperlukan seperti zConnection, zTable (karena pake ZeosLib), DataSource dan cxGridnya.

Untuk di gridnya ditambahkan 1 column unbound, jadi dikenal dengan column cxGrid1DBTableView1Column1, dengan set properties :

cxGrid1DBTableView1Column1.Properties := Images
.Properties.Images.GraphicClassName := TJPEGImage
.Properties.Images.ImmediatePost := true

sekarang untuk Databindingnya di set ke:

cxGrid1DBTableView1Column1.DataBinding.ValueType := string

untuk DataBinding.FieldName nya di kosyonk an saja, karena ini tidak dipakai, jadi column ini disebut unbound data-aware.

Sekarang … Codingz , tadi nya saya pikir bisa disimpan pada event onCustomDrawCell, karena untuk masalah beda warna tiap baris bisa digunakan event ini, tapi ternyata terjadi infinite-loop pada event Paint nya DevexGrid.

Jadi, saya tempatkan pada event : onGetProperties dari cxGrid1DBTableView1Column1 dengan isi :

procedure TForm8.cxGrid1DBTableView1Column1GetProperties(
  Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
  var AProperties: TcxCustomEditProperties);
var
  AFileName, AValue: String;
  APicture: TPicture;
begin
  AFileName := 'C:\Manz\Projects\Web\hrms\public_html\images\photo\' +
               VarToStr(ARecord.Values[cxGrid1DBTableView1nip.Index]) + '.jpg';
  if (fileexists(AFileName)) then
  begin
    APicture := TPicture.Create;
    try
      APicture.LoadFromFile(AFileName);
      SavePicture(APicture, AValue);
    finally
      freeAndNil(APicture);
    end;
  end
  else AValue := '';

  cxGrid1DBTableView1.DataController.Values[ARecord.RecordIndex, Sender.Index] := AValue;
end;


Dengan hasil snap-shot diatas .. maka hasil yang di-inginkan keluar seperti ini :mrgreen:

ImageLoad

ada 2 field tertera diatas, yaitu from DB dan from File, nah yang from File inilah yang disebut dengan unbounded data-aware.

Dikau temanz .. bisa mencoba nya … any error, any mistake (salah), access denied or error yang laindon’t ask … alias jangan tanya … silahkan trace sendiri sajah yah … :mrgreen:

Seperti biasa, kalau code ini berguna untuk kalian teman-temanz, teman-temanz bisa donate kepadaku ya ya ya :mrgreen: for keep this blog live and given the some tricky … :mrgreen:

Salam Coderz,
😎
Man’z

procedure TForm8.cxGrid1DBTableView1Column1GetProperties(
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AProperties: TcxCustomEditProperties);
var
AFileName, AValue: String;
APicture: TPicture;
begin
AFileName := ‘C:\Manz\Projects\Web\hrms\public_html\images\photo\’ +
VarToStr(ARecord.Values[cxGrid1DBTableView1nip.Index]) + ‘.jpg’;
if (fileexists(AFileName)) then
begin
APicture := TPicture.Create;
try
APicture.LoadFromFile(AFileName);
SavePicture(APicture, AValue);
finally
freeAndNil(APicture);
end;
end
else AValue := ”;

cxGrid1DBTableView1.DataController.Values[ARecord.RecordIndex, Sender.Index] := AValue;
end;

Read Full Post »