I'm developing a unit for a biometric reader. When giving the CREATE, the unit create several objects in runtime within TabSheet. Everything is running perfectly, but by loading the objects you can see blinking / drawing on the screen. Has anyone had the similar problem? Any ideas on how to do this in a more elegant way?
The Code:
constructor TFingerprint.Create (ATab : TTabSheet; AInix, AIniy : Integer);
begin
VTab := ATab;
// Create image
ComImage := TImage.Create(ATab);
Finix := AInix;
Finiy := AIniy;
L1 := TStringList.Create;
L2 := TStringList.Create;
L1.Clear;
L2.Clear;
FlagSync := False;
with ComImage do
begin
Parent := ATab;
Left := (VTab.ClientWidth-128*4-24-217) div 2;
Top := 8;
Height := 128;
Width := 128;
Picture.LoadFromFile('conn_off.png');
end;
FP_IDS := TStringList.Create;
// ComPort
ComPortA := TComPort.Create(ATab);
with ComPortA do
begin
BaudRate := br115200;
Port := 'COM5';
Buffer.InputSize := 2048;
Buffer.OutputSize := 2048;
OnAfterOpen := ComPortAAfterOpen;
OnBeforeOpen := ComPortABeforeClose;
OnError := ComPortAError;
//OnRxChar := ComPortARxChar;
end;
// ComDataPacket
ComDataPacketA := TComDataPacket.Create(ATab);
with ComDataPacketA do
begin
ComPort := ComPortA;
StartString := MD_STX;
StopString := MD_ETX;
OnPacket := COmDataPacket1Packet;
end;
// Buttons
btnCaptureFP := TBitBtn.Create(ATab);
with btnCaptureFP do
begin
Parent := ATab;
Caption := ' Capturar '#13#10'Digital';
Width := 217;
Height := 97;
Left := VTab.ClientWidth-Width-8;
Top := 16;
Font.Height := -23;
Font.Name := 'Tahoma';
NumGlyphs := 2;
Glyph.LoadFromFile('glyph-fingerprint.bmp');
OnClick := OnClickCaptureFP;
Enabled := False;
end;
btnDeleteFP := TBitBtn.Create(ATab);
with btnDeleteFP do
begin
Parent := ATab;
Caption := ' Apagar '#13#10'Digital';
Width := 217;
Height := 97;
Left := VTab.ClientWidth-Width-8;
Top := 129;
Font.Height := -23;
Font.Name := 'Tahoma';
NumGlyphs := 2;
Glyph.LoadFromFile('glyph-fingerprint-delete.bmp');
OnClick := OnClickDeleteFP;
end;
btnSyncFP := TBitBtn.Create(ATab);
with btnSyncFP do
begin
Parent := ATab;
Caption := ' Sincronizar '#13#10'Digital';
Width := 217;
Height := 97;
Left := VTab.ClientWidth-Width-8;
Top := 242;
Font.Height := -23;
Font.Name := 'Tahoma';
NumGlyphs := 2;
Glyph.LoadFromFile('glyph-sync.bmp');
OnClick := OnClickSyncFP;
Enabled := False;
end;
btnExitFP := TBitBtn.Create(ATab);
with btnExitFP do
begin
Parent := ATab;
Caption := ' Sair ';
Width := 217;
Height := 97;
Left := VTab.ClientWidth-Width-8;
Top := 355;
Font.Height := -23;
Font.Name := 'Tahoma';
NumGlyphs := 2;
Glyph.LoadFromFile('exit.bmp');
end;
// StringGrid
FPGrid := TStringGrid.Create(ATab);
with FPGrid do
begin
Parent := ATab;
FixedCols := 0;
Font.Name := 'Tahoma';
Font.Size := 12;
ColCount := 4;
Left := 8;
Top := 144;
Width := ATab.ClientWidth-24-217;
Height := (VTab.ClientHeight-ComImage.Top-ComImage.Height-16);
Cells[0,0] := 'Nome';
Cells[1,0] := 'ID';
Cells[2,0] := 'Grupo';
Cells[3,0] := 'Leitor ID';
Cells[4,0] := 'Level';
Cells[5,0] := 'Status';
ColWidths[0] := 210;
ColWidths[1] := 100;
ColWidths[2] := 190;
ColWidths[3] := 90;
ScrollBars := ssVertical;
Options := Options + [goRowSelect];
OnClick := OnClickFPGrid;
end;
// ProgressBar
prgBar := TProgressBar.Create(ATab);
with prgBar do
begin
Parent := ATab;
Width := 217;
Height := 16;
Left := VTab.ClientWidth-Width-8;
Top := 468;
Position := 0;
end;
SendMessage(prgBar.Handle, PBM_SETBARCOLOR,0,clLime);
// Label
lblBar := TLabel.Create(ATab);
with lblBar do
begin
Parent := ATab;
Left := prgBar.Left;
Top := prgBar.Top + prgBar.Height + 8;
Font.Name := 'Tahoma';
Font.Color := clWhite;
end;
// Load Users
LoadUsers2;
// Check first empty FP
FPGrid.Row := 1;
while not(FPGrid.Cells[3,FPGrid.Row] = '') and (FPGrid.Row < FPGrid.RowCount-1) do
FPGrid.Row := FPGrid.Row + 1;
ComPortA.Open;
// GetUsers
SendTelegram(GET_USERS);
ComImage.Visible := True;
end;
In the middle is the loading of Glyphs between 17K and 20K.