[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

Accessing items in a TreeView of an external application

Asked by Sebastion in Delphi Programming

Tags: Treeview external

Hi,

I've already had a look at http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20272830.html, http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20593454.html, though the links in there don't work (eg MadRemote, etc).  Also what's thrown me is http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23524965.html whereby it seems someone was able to get this working with the existing "TreeView_GetSelection" function in CommCtrl.

I've probably gotten ahead of myself here abit, so first some information.  We have a application here and what I'm doing at the moment is writing an application that will just stress test it.  By this I mean it'll simulate a user going through it and repeating various actions in rapid succession, usually for hours on end (all the while keeping logs of everything which is happening).  

Reading various data like listboxes and text boxes is easily done already, as with the various navigations (the program knows what screen the system is currently on and re-acts accordingly), and the only thing holding me up at the moment is a TreeView who's contents change depending on the options set up and data in the database.  I've already made it possible for the program to choose an option in there, but for record purposes (and also to know how to react afterwards) I need to determine what option it's selected.

The program is able to already gather the hwnd of the window with the treeview, as well as drill down through the child components until it actually reaches the treeview itself.  I've also managed to get the number of items in the list via TVM_GETCOUNT, but when I try to get the actual selected item via either TVM_GETITEM or TreeView_GetItem I always get a null string and a failure bool .

I've only given the question 125 points because I have this feeling I'm going to be told that it isn't possible with the existing routines in CommCtrl (though it does make me ask the question of why those routines exist) and thus it's probably an open and shut case, but if it is possible then I'll up the points to 500.

I've added my two functions to the code section.  If anyone can give some insight it'd be greatly appreciated.
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:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
function GetSelectedTreeItem(HwndTree) : String;
var
  pitem: TTVItem;
begin
  try
    result := '';
    pitem.hItem := TreeView_GetSelection(HwndTree);
    pitem.mask := TVIF_TEXT;
    pitem.cchTextMax := 255;
    if TreeView_GetItem(HwndTree, pitem) then
      UpdateLog('Successfull GetItem')
     else
       UpdateLog('Unsuccessful GetItem');
     //SendMessage(HwndPOSChild, TVM_GETITEM, 0, longint(@pitem));
    Result:=pitem.pszText;
    //result := TreeView_GetSelection(HwndPOSChild);
  except
    result := '';
  end;
end;
 
function GetSelectedTreeItemV2(HwndTree) : String;
var
  TreeItem: TV_ITEM;
  TreeText: array [0 .. 255] of Char;
begin
  try
    FillChar(TreeItem, SizeOf(TreeItem), 0);
    result := '';
    TreeText := '';
    with TreeItem do
       begin
       mask := TVIF_TEXT or TVIF_HANDLE;
       hItem := TreeView_GetSelection(HwndTree);
       pszText := @TreeText;
       cchTextMax := 255;
      end;
    if (TreeView_GetItem(HwndTree, TreeItem)) then
      UpdateLog('Successfull GetItem')
    else
      UpdateLog('Unsuccessful GetItem');
    //SendMessage(HwndPOSChild, TVM_GETITEM, 0, longint(@TreeItem));
    Result:=TreeText;
  except
    result := '';
  end;
end;
[+][-]04/01/09 07:40 AM, ID: 24039619Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Delphi Programming
Tags: Treeview external
Sign Up Now!
Solution Provided By: rllibby
Participating Experts: 2
Solution Grade: A
 
[+][-]03/27/09 12:30 AM, ID: 23998624Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/27/09 04:57 PM, ID: 24006476Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/30/09 05:22 PM, ID: 24024751Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/31/09 05:17 AM, ID: 24028007Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/31/09 06:17 PM, ID: 24035293Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/31/09 09:18 PM, ID: 24035928Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/31/09 11:54 PM, ID: 24036522Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/01/09 07:43 PM, ID: 24045948Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/01/09 07:48 PM, ID: 24045973Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/01/09 08:10 PM, ID: 24046068Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/02/09 09:26 PM, ID: 24056642Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/03/09 06:28 AM, ID: 24059643Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/05/09 04:33 PM, ID: 24073453Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625