Einzelnen Beitrag anzeigen

Benutzerbild von Nighthawk1310
Nighthawk1310

Registriert seit: 22. Feb 2004
Ort: Izmir / Türkei
45 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: Images in VirtualStringTree (VST)

  Alt 8. Jun 2009, 17:59
Hinterlege den ImageIndex für einen Node in Deinen NodeDaten in einer Variable oder mache den
ImageIndex von anderen Variablen in Deinen NodeDaten "abhängig".

Lass dann deine Images im AfterCellPaint des VST zeichnen. Bei der Methode braucht dem VST übrigens
keine Imagelist zugeordnet zu sein.

Bsp:
Delphi-Quellcode:
        //User online
        if (pNodeDataUser.bOnline and (not pNodeDataUser.bPaused)) then
           frmMain.imgMain.Draw(TargetCanvas, CellRect.Left + 4, CellRect.Top + 3, 8);

        //User paused
        if (pNodeDataUser.bOnline and pNodeDataUser.bPaused) then
           frmMain.imgMain.Draw(TargetCanvas, CellRect.Left + 4, CellRect.Top + 3, 9);

        //User sick
        if (pNodeDataUser.bSick and (not pNodeDataUser.bOnline)) then
           frmMain.imgMain.Draw(TargetCanvas, CellRect.Left + 4, CellRect.Top + 3, 26);
        //User holiday

        if (pNodeDataUser.bHoliDay and (not pNodeDataUser.bOnline)) then
            frmMain.imgMain.Draw(TargetCanvas, CellRect.Left + 4, CellRect.Top + 3, 27);
        
        //User idle
        if (pNodeDataUser.bOnline and pNodeDataUser.bIdle) then
           frmMain.imgMain.Draw(TargetCanvas, CellRect.Left + 23, CellRect.Top + 3, 6);
Auf diese Art und Weise kannst du die Images aus eine Imagelist oder aus einem TImage in den VST Zeichnen.
Die Positionsberechnung liegt in dem Fall allerdings bei Dir.


Anbei noch ein Screenshot aus einem meiner Programme.
Die Symbole benutze ich in meinem Beispiel nicht nur als Anzeige, sondern auch als Schaltflächen
Die Abfrage des Klicks erfolgt dabei im MouseUp des VST's:


Delphi-Quellcode:
         //X und Y werden vom VST übergeben
         xNode := vstMainList.GetNodeAt(X, Y);

         if xNode.Dummy = 98 then
            begin
            CellRect := vstMainList.GetDisplayRect(xNode, 0, False);

            //Working/Paused
            if ((X >= CellRect.Left + 2) and (X <= CellRect.Left + 22 )) and
               ((Y >= CellRect.Top + 4) and (Y <= CellRect.Top + 19 )) then
               SetPausedWorking(xNode);

            //CoachingMode
            if ((X >= CellRect.Left + 42) and (X <= CellRect.Left + 60 )) and
               ((Y >= CellRect.Top + 5) and (Y <= CellRect.Top + 19 )) then
               SetCoachingMode(xNode);

            //View
            if ((X >= CellRect.Left + 62) and (X <= CellRect.Left + 80 )) and
               ((Y >= CellRect.Top + 5) and (Y <= CellRect.Top + 19 )) then
               ShowMessage('Nicht implementiert');

            //Talk/Write
            if ((X >= CellRect.Left + 82) and (X <= CellRect.Left + 102 )) and
               ((Y >= CellRect.Top + 5) and (Y <= CellRect.Top + 19 )) then
               ShowMessage('Talk/Write');

            //Refresh
            if ((X >= CellRect.Left + 102) and (X <= CellRect.Left + 120 )) and
               ((Y >= CellRect.Top + 5) and (Y <= CellRect.Top + 19 )) then
               RefreshUser(xNode);
            end;
Je nachdem wie die Variablen in meinen NodeDaten belegt sind lasse ich ein anderes Symbol zeichnen.

Ich hoffe, dass Dir das weiterhilft
Miniaturansicht angehängter Grafiken
vst_865.jpg  
Michael
  Mit Zitat antworten Zitat