Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   General (http://www.delphipages.com/forum/forumdisplay.php?f=2)
-   -   problems porting an app from Delphi 7 to 10 (http://www.delphipages.com/forum/showthread.php?t=217319)

kolbasz 12-04-2015 09:57 AM

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.

DavidB3 12-04-2015 10:05 AM

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.

kolbasz 12-04-2015 10:11 AM

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?

DavidB3 12-05-2015 01:25 PM

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 :D
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

kolbasz 12-05-2015 06:20 PM

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 :D
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.

DavidB3 12-05-2015 11:05 PM

Actually my description was from Windows 8.1 default theme.

Looks like that code works :)

Before:

http://i411.photobucket.com/albums/p...pshbqsginv.jpg

After:

Code:

Alpha := 40;
Color := clGray;

http://i411.photobucket.com/albums/p...psnldqzzmk.jpg

kolbasz 12-06-2015 09:12 AM

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) :

http://i1270.photobucket.com/albums/...basz/Icons.png
You can download a lot of free Png icon set from the net.

DavidB3 12-06-2015 10:42 AM

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)...

kolbasz 12-06-2015 11:38 AM

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). :)

DavidB3 12-06-2015 11:59 AM

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.


All times are GMT. The time now is 02:43 PM.

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