Home > Software engineering >  How to obtain the SysTreeView32 control handle and send a message of all nodes under the selected cl
How to obtain the SysTreeView32 control handle and send a message of all nodes under the selected cl

Time:10-01


As shown in figure on the left is a SysTreeView32 control,
I want to get the control of all nodes under the handle, and can send messages selected click on the name of a specified node
Ask for advice,,,
Rookie just contact API soon
Online, etc... O source
# region API
The definition of/* API */
///
///is essentially FindWindow, find target handle
///

[DllImport (" user32. DLL, "EntryPoint=" FindWindow SetLastError=true)]
The static extern IntPtr FindWindowByCaption (IntPtr ZeroOnly, string lpWindowName);
The best use of c # language writing easier to understand

CodePudding user response:

Not have a special section in c #?

CodePudding user response:


Tree Control Item Information
Home | the Overview | Sample

Tree controls (CTreeCtrl) have a number of member functions provides that retrieve information about the items in the control. The the GetItem member function retrieves some or all of the data associated with an item. This data could include the item 's text, the state, images, and the count of child items, and an application - defined 32 - bit data value. There is also a SetItem function that can set some or all of the data associated with an item.

The GetItemState GetItemText, GetItemData, and GetItemImage member functions provides retrieve individual attributes of an item. Each of these functions provides has a corresponding Set function for setting The attributes of an item.

The GetNextItem member function retrieves The tree control item that bears The specified relationship to The current item. This function can retrieve an item 's parent, The next or previous visible item, The first child item, and so on. There are also member functions provides The to traverse by The tree: GetRootItem, GetFirstVisibleItem, GetNextVisibleItem, GetPrevVisibleItem, GetChildItem, GetNextSiblingItem, GetPrevSiblingItem, GetParentItem, GetSelectedItem, and GetDropHilightItem.

The GetItemRect member function retrieves The bounding rectangle for a tree control item. The GetCount and GetVisibleCount member functions provides retrieve a count of The items in a tree control and a count of The items that are currently visible in The tree control 's window, respectively. You can ensure that a particular item is visible by calling The EnsureVisible member function.

See Also Windows Common Controls and MFC Classes



Common Control Sample List
Home | the Overview | Details

See the following sample designed that illustrateenrollment common controls:

CMNCTRL1


CMNCTRL2


CTRLTEST


The FIRE
Back to the Control Tasks

CodePudding user response:

Public static bool GetTreeViewText (IntPtr AHandle)
{


Uint vProcessId;
GetWindowThreadProcessId (AHandle, out vProcessId);

IntPtr vProcess=OpenProcess (PROCESS_VM_OPERATION | PROCESS_VM_READ |
PROCESS_VM_WRITE, false, vProcessId);
IntPtr vPointer=VirtualAllocEx (vProcess, IntPtr. Zero, 4096,
MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
Try
{
Uint vItemCount=TreeView_GetCount (AHandle);
IntPtr vTreeItem=GetRoot (AHandle);//root node

VTreeItem=GetFirstChildItem (AHandle vTreeItem);//the first child node
MessageBox. Show (vItemCount. ToString ());
for (int i=0; I & lt; VItemCount; I++)
{
Byte [] vBuffer=new byte [256].
TVITEM [] vItem=new TVITEM [1].
VItem [0]=new TVITEM ();
VItem [0]. Mask=TVIF_TEXT;
VItem [0]. HItem=vTreeItem;
VItem [0]. PszText=(IntPtr) ((int) vPointer + Marshal. SizeOf (typeof (TVITEM)));
VItem [0]. CchTextMax=vBuffer. Length;
Uint vNumberOfBytesRead=0;
WriteProcessMemory (vProcess vPointer,
Marshal. UnsafeAddrOfPinnedArrayElement (vItem, 0),
Marshal. SizeOf (typeof (TVITEM)), ref vNumberOfBytesRead);
SendMessage (AHandle TVM_GETITEMA, 0, (int) vPointer);
ReadProcessMemory (vProcess,
(IntPtr) ((int) vPointer + Marshal. SizeOf (typeof (TVITEM))),
Marshal. UnsafeAddrOfPinnedArrayElement (vBuffer, 0),
VBuffer Length, ref vNumberOfBytesRead);
MessageBox. Show (Marshal. PtrToStringAnsi (
Marshal. UnsafeAddrOfPinnedArrayElement (vBuffer, 0)));

VTreeItem=GetNextItem (AHandle vTreeItem);
}
}
The finally
{
VirtualFreeEx (vProcess vPointer, 0, MEM_RELEASE);
The CloseHandle (vProcess);
}
return true;
}



All handles have value, but the returned is an empty string
  •  Tags:  
  • API
  • Related