Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #21  
Old 12-04-2015, 09:57 AM
kolbasz kolbasz is offline
Senior Member
 
Join Date: Nov 2013
Posts: 841
Default

You may also find useful to search VST for a particular data. For example, you want to select a node, where column "Name" it's equal to a specific value:

Code:
function TForm1.FindNode(const AName: String): PVirtualNode;
var
  Node: PVirtualNode;
  Data: PData;
begin
  Result := nil;
  Node := VST.GetFirst;
  while Assigned(Node) do
  begin
    Data := VST.GetNodeData(Node);
    if UpperCase(Data.FName) = UpperCase(AName) then
    begin
      Result := Node;
      Break;
    end;
    Node := VST.GetNext(Node);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Node: PVirtualNode;
begin
  Node := FindNode('test 4');
  if Node <> nil then
  begin
    VST.Selected[Node] := True;
    VST.FocusedNode := Node;
  end;
end;
You can replace the AName with AID or any value you like.
Reply With Quote
  #22  
Old 12-04-2015, 10:05 AM
DavidB3 DavidB3 is offline
Senior Member
 
Join Date: Jul 2013
Posts: 119
Default

Quote:
No need to sync under VST, all the data is available in the internal structure, you can get rid of VMEntries.
Even with VST, I can't get rid of it.
It has more data than the VST columns:

Code:
   VMentry = record
      Name: WideString;
      Ptype: Byte;
      ModeLoadVM: Byte;
      VMID: WideString;
      VMName: WideString;
      VMPath: WideString;
      ExeParams: WideString;
      FirstDriveName: AnsiString;
      FirstDriveFound: Boolean;
      FirstDriveBusType: Byte;
      SecondDriveName: AnsiString;
      SecondDriveFound: Boolean;
      SecondDriveBusType: Byte;
      InternalHDD: WideString;
      CDROMName: WideString;
      CDROMType: Byte;
      Memory: Word;
      Audio: Byte;
      Run: Byte;
      Priority: Byte;
      luIDS: LastUsedIDS;
      VBCPUVirtualization: Byte;
   end;
And this data is needed to properly configure and start a VirtualBox/Qemu VM.
Reply With Quote
  #23  
Old 12-04-2015, 10:11 AM
kolbasz kolbasz is offline
Senior Member
 
Join Date: Nov 2013
Posts: 841
Default

I don't see the problem:
Code:
 PData = ^TData;
 TData = record
      Name: WideString;
      Ptype: Byte;
      ModeLoadVM: Byte;
      VMID: WideString;
      VMName: WideString;
      VMPath: WideString;
      ExeParams: WideString;
      FirstDriveName: AnsiString;
      FirstDriveFound: Boolean;
      FirstDriveBusType: Byte;
      SecondDriveName: AnsiString;
      SecondDriveFound: Boolean;
      SecondDriveBusType: Byte;
      InternalHDD: WideString;
      CDROMName: WideString;
      CDROMType: Byte;
      Memory: Word;
      Audio: Byte;
      Run: Byte;
      Priority: Byte;
      luIDS: LastUsedIDS;
      VBCPUVirtualization: Byte;
   end;
All the fields/properties are stored internally in the VST, you don't have to display it in the tree, just the one you need. Consider VST like a big dynamical array(or TList) with a visual interface. Of course in the case of very large rownumber, you have to consider memory consumption, but in this particular case, I don't think it's(will be) a problem. How many rows do you have? Max 100?

Last edited by kolbasz; 12-04-2015 at 10:52 AM.
Reply With Quote
  #24  
Old 12-05-2015, 01:25 PM
DavidB3 DavidB3 is offline
Senior Member
 
Join Date: Jul 2013
Posts: 119
Default

Sorry for the delay in response, but I had a lot of work to do (this project and in my personal life).

I'm just at half with the implementation of VirtualStringTree. Many things have to be changed so it would be 100% functional.

A question:
The header in the TListView ver 6 and in the TVirtualStringTree is far less "visible" than in TListView 5.8 ver. I think the Windows theme is contributing too...
It's flat like the rows, its color is just a bit different than the row color and the margins are very thin and/or painted with an almost invisible color. It's not so easy to realize there is a header there
Is there a way to make it more "visible" but still letting the Windows theme to change it?
Maybe by making again tridimensional, or by using an OnAfter event to repaint it with a slightly darker color.


LE: found this, maybe it's good xD

Last edited by DavidB3; 12-05-2015 at 02:49 PM.
Reply With Quote
  #25  
Old 12-05-2015, 06:20 PM
kolbasz kolbasz is offline
Senior Member
 
Join Date: Nov 2013
Posts: 841
Default

Quote:
Sorry for the delay in response, but I had a lot of work to do (this project and in my personal life).
No problem, don't worry!

Quote:
The header in the TListView ver 6 and in the TVirtualStringTree is far less "visible" than in TListView 5.8 ver. I think the Windows theme is contributing too...
It's flat like the rows, its color is just a bit different than the row color and the margins are very thin and/or painted with an almost invisible color. It's not so easy to realize there is a header there
Personally I hate win10, but maybe some people like it just the way it is. I don't think it's a good idea to change the default behaviour of the listview/vst. Anyway if you still want to change it, you should owner draw the header. Please open HeaderCustomDraw unit from the Advanced project(VST Demo folder). It's quite amazing what VST can achieve. The link you provided it's also a good example for owner drawing.
Reply With Quote
  #26  
Old 12-05-2015, 11:05 PM
DavidB3 DavidB3 is offline
Senior Member
 
Join Date: Jul 2013
Posts: 119
Default

Actually my description was from Windows 8.1 default theme.

Looks like that code works

Before:



After:

Code:
Alpha := 40;
Color := clGray;
Reply With Quote
  #27  
Old 12-06-2015, 09:12 AM
kolbasz kolbasz is offline
Senior Member
 
Join Date: Nov 2013
Posts: 841
Default

Quote:
Actually my description was from Windows 8.1 default theme.
Same as win10 in my opinion.

Quote:
Looks like that code works
Alpha := 40;
Color := clGray;
If you ask me looks 10x better.

@DavidB3 I have a request!.
After you finish the implementation, please replace the icons with png's. Although TImageList theoretically supports PngImages, in reality that's not true. You should download PngComponents(https://github.com/TurboPack/PNGComponents) and replace TImageList with TPngImageList. You don't have to change a single line of code, it looks and works exactly like TImageList, but it has full png support. The problem is, those icons in your application looks ugly(take this as constructive criticism) :


You can download a lot of free Png icon set from the net.
Reply With Quote
  #28  
Old 12-06-2015, 10:42 AM
DavidB3 DavidB3 is offline
Senior Member
 
Join Date: Jul 2013
Posts: 119
Default

I made the header code a little more "adaptable":

Code:
//global var
   ColorToBlend: TColor = clBlack;
   isBlendColorAssigned: Boolean = False;
...........
   function GetColorToBlend(const BaseColor: TColor): TColor;

      procedure MinMax3(const i, j, k: Integer; var Min, Max: Integer);
      begin
         if i > j then
         begin
            if i > k then
               Max := i
            else
               Max := k;

            if j < k then
               Min := j
            else
               Min := k
         end
         else
         begin
            if j > k then
               Max := j
            else
               Max := k;

            if i < k then
               Min := i
            else
               Min := k
         end
      end;

   var
      MinValue: Integer;
      r, g, b, c, v: Integer;
   begin
      c := ColorToRGB(BaseColor);
      r := GetRValue(c);
      g := GetGValue(c);
      b := GetBValue(c);
      MinMax3(r, g, b, MinValue, v);
      if v <= 127 then
         Result := clWhite
      else
         Result := clBlack;
   end;
...........
Alpha := 15;
...........
          if not isBlendColorAssigned then
          begin
             isBlendColorAssigned := True;
             ColorToBlend := GetColorToBlend(PaintInfo.TargetCanvas.Pixels[(R.Right - R.Left) div 2,
                (R.Bottom - R.Top) div 2]);
          end;
          ColorBlend(PaintInfo.TargetCanvas, R, ColorToBlend, Alpha);
This way it will brighten dark colors or it will darken bright colors.

I know some of the icons look ugly but so far couldn't find better ones. Yes, on internet you can find a lot, but most of them are highres and look very bad in 16x16.
Using png won't improve their look, just the memory usage. But the difference will be too low to worth.
I know those components, I used them a lot in other apps. Unfortunately they aren't compatible with D10 (25 compilation errors)...

Last edited by DavidB3; 12-06-2015 at 10:52 AM.
Reply With Quote
  #29  
Old 12-06-2015, 11:38 AM
kolbasz kolbasz is offline
Senior Member
 
Join Date: Nov 2013
Posts: 841
Default

Ok, you don't like png's, it's perfectly fine, but even after five minute of google search you can find better looking icons(ico).
Reply With Quote
  #30  
Old 12-06-2015, 11:59 AM
DavidB3 DavidB3 is offline
Senior Member
 
Join Date: Jul 2013
Posts: 119
Default

It makes no difference for me if they are bmp, ico, png or anything else.
Like I said, I chose ico because it was the ONLY WAY to load them without losing something from image. In the Delphi 7 version I had bmp because, same, was the ONLY WAY to load them and show them correctly.
In my other apps I used pngs stored in resources and loading them using those components.

Have you looked where I said "25 compilation errors"?
Btw, the latest versions of Delphi can load pngs. I tried load png into a TPNGImage then into a TBitmap and then in TImageList. But the images were shown grayed.

And I spent countless hours looking in the hundreds of thousands icons on internet. Like I said, most of them look crappy in 16x16 res. And english in not my native language so I don't know all the word "variations" so I can search them.

LE: for "not found" (red circle) I found this one: https://www.iconfinder.com/icons/144...t_icon#size=16
But I'm not sure is much better.

Last edited by DavidB3; 12-06-2015 at 12:04 PM.
Reply With Quote
Reply

Tags
64 bit, delphi 10, delphi 7, listview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:35 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.