VB Code to Delphi translation

Can someone help me ho to translate this VB code to Delphi the bIsDirectory is a Treeview

Private Sub DVDWriterPro1_ISODestPathChanged(ByVal sOldDestPath As String, ByVal sNewDestPath As String, ByVal bIsDirectory As Boolean)
'When a Path has changed (via renaming a directory or file), its
'Destination path is modified to reflect the new image tree.
'this event allows you to update image items with thier new destination
'paths. Since the paths are used as the keys for our tree and list, these need
'to be updated. We will change directory keys, and reload the file list.
If bIsDirectory = True Then
'Update the directory's key after the renaming
tvwDirectories.Nodes(sOldDestPath).Key = sNewDestPath
End If

End Sub


Thanks

Comments

  • [b][red]This message was edited by Josh Code at 2004-5-4 9:32:23[/red][/b][hr]
    // Can someone help me ho to translate this VB code to Delphi the bIsDirectory is a Treeview
    [code]
    // I left this as CLASSNAME but you should use the name of the class this method is a private member of.
    [b]procedure[/b] CLASSNAME.DVDWriterPro1_ISODestPathChanged(sOldDestPath: String, sNewDestPath: String, bIsDirectory: Boolean)
    [b]begin[/b]
    //When a Path has changed (via renaming a directory or file), its
    //Destination path is modified to reflect the new image tree.
    //this event allows you to update image items with thier new destination
    //paths. Since the paths are used as the keys for our tree and list, these need
    //to be updated. We will change directory keys, and reload the file list.
    [b]If[/b] bIsDirectory = True [b]Then[/b]
    [b]begin[/b]
    //Update the directory's key after the renaming
    //tvwDirectories.Nodes(sOldDestPath).Key = sNewDestPath;
    ( not sure how to translate this properly because I can't think of an equivalent component in Delphi. There is a tTreeView component but I couldn't find the same methods as you used.)
    [b]End[/b];
    [b]end[/b];
    [/code]


  • : [b][red]This message was edited by Josh Code at 2004-5-4 9:32:23[/red][/b][hr]
    : // Can someone help me ho to translate this VB code to Delphi the bIsDirectory is a Treeview
    : [code]
    : // I left this as CLASSNAME but you should use the name of the class this method is a private member of.
    : [b]procedure[/b] CLASSNAME.DVDWriterPro1_ISODestPathChanged(sOldDestPath: String, sNewDestPath: String, bIsDirectory: Boolean)
    : [b]begin[/b]
    : //When a Path has changed (via renaming a directory or file), its
    : //Destination path is modified to reflect the new image tree.
    : //this event allows you to update image items with thier new destination
    : //paths. Since the paths are used as the keys for our tree and list, these need
    : //to be updated. We will change directory keys, and reload the file list.
    : [b]If[/b] bIsDirectory = True [b]Then[/b]
    : [b]begin[/b]
    : //Update the directory's key after the renaming
    : //tvwDirectories.Nodes(sOldDestPath).Key = sNewDestPath;
    : ( not sure how to translate this properly because I can't think of an equivalent component in Delphi. There is a tTreeView component but I couldn't find the same methods as you used.)
    : [b]End[/b];
    : [b]end[/b];
    : [/code]
    :
    :
    As far as I can see the Nodes() property is similar to the Items[] property of the TTreeView, except that it takes the Caption as its index. For this you need to iterate through the tree until you encounter the correct node. Here is a function for it:
    [code]
    function FindTreeNode(NodeToFind: string; Nodes: TTreeNodes): TTreeNode;
    var
    i: integer;
    begin
    if Nodes.Count = 0 then
    Result := nil
    else
    for i := 0 to Nodes.Count-1 do
    if CompareText(NodeToFind, Nodes[i]) = 0 then
    begin
    Result := Nodes[i];
    Break;
    end;
    end;
    [/code]
    So the last line might read:
    [code]
    FindTreeNode(sOldDestPath, tvwDirectories.Nodes).Caption = sNewDestPath;
    [/code]
    although I'm note sure about it, either the translation or the code itself (it's untested).
  • : : [b][red]This message was edited by Josh Code at 2004-5-4 9:32:23[/red][/b][hr]
    : : // Can someone help me ho to translate this VB code to Delphi the bIsDirectory is a Treeview
    : : [code]
    : : // I left this as CLASSNAME but you should use the name of the class this method is a private member of.
    : : [b]procedure[/b] CLASSNAME.DVDWriterPro1_ISODestPathChanged(sOldDestPath: String, sNewDestPath: String, bIsDirectory: Boolean)
    : : [b]begin[/b]
    : : //When a Path has changed (via renaming a directory or file), its
    : : //Destination path is modified to reflect the new image tree.
    : : //this event allows you to update image items with thier new destination
    : : //paths. Since the paths are used as the keys for our tree and list, these need
    : : //to be updated. We will change directory keys, and reload the file list.
    : : [b]If[/b] bIsDirectory = True [b]Then[/b]
    : : [b]begin[/b]
    : : //Update the directory's key after the renaming
    : : //tvwDirectories.Nodes(sOldDestPath).Key = sNewDestPath;
    : : ( not sure how to translate this properly because I can't think of an equivalent component in Delphi. There is a tTreeView component but I couldn't find the same methods as you used.)
    : : [b]End[/b];
    : : [b]end[/b];
    : : [/code]
    : :
    : :
    : As far as I can see the Nodes() property is similar to the Items[] property of the TTreeView, except that it takes the Caption as its index. For this you need to iterate through the tree until you encounter the correct node. Here is a function for it:
    : [code]
    : function FindTreeNode(NodeToFind: string; Nodes: TTreeNodes): TTreeNode;
    : var
    : i: integer;
    : begin
    : if Nodes.Count = 0 then
    : Result := nil
    : else
    : for i := 0 to Nodes.Count-1 do
    : if CompareText(NodeToFind, Nodes[i]) = 0 then
    : begin
    : Result := Nodes[i];
    : Break;
    : end;
    : end;
    : [/code]
    : So the last line might read:
    : [code]
    : FindTreeNode(sOldDestPath, tvwDirectories.Nodes).Caption = sNewDestPath;
    : [/code]
    : although I'm note sure about it, either the translation or the code itself (it's untested).
    :


    Thanks for the help.

    Willem
  • : : : [b][red]This message was edited by Josh Code at 2004-5-4 9:32:23[/red][/b][hr]
    : : : // Can someone help me ho to translate this VB code to Delphi the bIsDirectory is a Treeview
    : : : [code]
    : : : // I left this as CLASSNAME but you should use the name of the class this method is a private member of.
    : : : [b]procedure[/b] CLASSNAME.DVDWriterPro1_ISODestPathChanged(sOldDestPath: String, sNewDestPath: String, bIsDirectory: Boolean)
    : : : [b]begin[/b]
    : : : //When a Path has changed (via renaming a directory or file), its
    : : : //Destination path is modified to reflect the new image tree.
    : : : //this event allows you to update image items with thier new destination
    : : : //paths. Since the paths are used as the keys for our tree and list, these need
    : : : //to be updated. We will change directory keys, and reload the file list.
    : : : [b]If[/b] bIsDirectory = True [b]Then[/b]
    : : : [b]begin[/b]
    : : : //Update the directory's key after the renaming
    : : : //tvwDirectories.Nodes(sOldDestPath).Key = sNewDestPath;
    : : : ( not sure how to translate this properly because I can't think of an equivalent component in Delphi. There is a tTreeView component but I couldn't find the same methods as you used.)
    : : : [b]End[/b];
    : : : [b]end[/b];
    : : : [/code]
    : : :
    : : :
    : : As far as I can see the Nodes() property is similar to the Items[] property of the TTreeView, except that it takes the Caption as its index. For this you need to iterate through the tree until you encounter the correct node. Here is a function for it:
    : : [code]
    : : function FindTreeNode(NodeToFind: string; Nodes: TTreeNodes): TTreeNode;
    : : var
    : : i: integer;
    : : begin
    : : if Nodes.Count = 0 then
    : : Result := nil
    : : else
    : : for i := 0 to Nodes.Count-1 do
    : : if CompareText(NodeToFind, Nodes[i]) = 0 then
    : : begin
    : : Result := Nodes[i];
    : : Break;
    : : end;
    : : end;
    : : [/code]
    : : So the last line might read:
    : : [code]
    : : FindTreeNode(sOldDestPath, tvwDirectories.Nodes).Caption = sNewDestPath;
    : : [/code]
    : : although I'm note sure about it, either the translation or the code itself (it's untested).
    : :
    :
    :
    : Thanks for the help.
    :
    : Willem
    :
    Hello again

    if CompareText(NodeToFind, Nodes[i]) = 0 then // error message "incompatible types"

    It's all about a TTreeView and the SubItems.

    The only thing this code has to do is to change the name of the Node (SubItem) if a user selected to do this, and if it's a directory it must stay the way it was. I'm trying to translate a VB sample from the DVDWriterPro ActiveX to Delphi format, I'm not very good in VB and this is the only problem I have for now. I will make it public when finished

    Thanks

  • you're probably comparing string with TTreeNode, use the appropiate field of TTreeNode, Caption in this case
    : Hello again
    :
    : if CompareText(NodeToFind, Nodes[i][RED].Caption[/RED]) = 0 then // error message "incompatible types"
    :
    : It's all about a TTreeView and the SubItems.
    :
    : The only thing this code has to do is to change the name of the Node (SubItem) if a user selected to do this, and if it's a directory it must stay the way it was. I'm trying to translate a VB sample from the DVDWriterPro ActiveX to Delphi format, I'm not very good in VB and this is the only problem I have for now. I will make it public when finished
    :
    : Thanks
    :
    :
    [hr][red][italic][b]N[/b][/red][blue]et[/blue][red][b]G[/b][/red][blue]ert[/italic][/blue][hr]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories