Bonjour à tous,

Pour notre logiciel disponible sur notre site http://sites.google.com/site/outilsobdfacile/

Je travaille sur un composant graphique qui simulera un afficheur LCD.. Mais voilà j'experimente quelque soucis de lenteur..

Le principe est le suivant je créer un TShape vert et j'ajoute x pixels qui sont eux des TShape (noir) et après je joue sur la propriété visible pour afficher du texte. Celà donne le résultat suivant



Uploaded with ImageShack.us

Jusqu'ici tout va bien, vous me direz, sauf que l'affichage initiale du composant prends environ 10s... ET c'est très long 10s sans rien qui se passe pour un programme

Voici le code qui prends un temps fou
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
void __fastcall TForm1::FormCreate(TObject *Sender)
{
   //Create the green background
   TShape *ShapeBack = new TShape(NULL);
   ShapeBack->Parent = Form1;
   ShapeBack->Top = LCD_TOP_POSITION;
   ShapeBack->Left = LCD_LEFT_POSITION;
   ShapeBack->Width = LCD_PIXEL_WIDTH * LCD_PIXEL_DOT;
   ShapeBack->Height = LCD_PIXEL_HEIGHT * LCD_PIXEL_DOT;
   ShapeBack->Brush->Color = LCD_BACK_COLOR;
   //ShapeBack->Visible = TRUE;
 
   //Now create each pixel
   for(int x = 0; x < LCD_PIXEL_WIDTH ; x++)
   {
      for(int y = 0; y < LCD_PIXEL_HEIGHT ; y++)
      {
         Pixels[x][y] = new TShape(NULL);
         Pixels[x][y]->Parent = Form1;
         Pixels[x][y]->Width = LCD_PIXEL_DOT;
         Pixels[x][y]->Height = LCD_PIXEL_DOT;
         Pixels[x][y]->Top = LCD_TOP_POSITION + (y * LCD_PIXEL_DOT);
         Pixels[x][y]->Left = LCD_LEFT_POSITION + (x * LCD_PIXEL_DOT);
         Pixels[x][y]->Brush->Color = LCD_PIXEL_COLOR;
         //Pixels[x][y]->Visible = TRUE;
      }
   }
 
}
La ligne suivante Pixels[x][y]->Parent = Form1; me semble louche mais je suis un pro du C embarqué et de l'OBD.. mais le C++ je me debrouille, mais sans plus

Je vous remercie d'avance pour votre expertise
Salutations