Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. StringPointer Problem with TVM_GETITEM! [modified]

StringPointer Problem with TVM_GETITEM! [modified]

Scheduled Pinned Locked Moved C#
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    suguimoto
    wrote on last edited by
    #1

    Hello! [modified] Thanx to OrlandoCurioso! I have tried to use a SendMessage with TVM_GETITEM with a TVITEM struct... but I got no result at all =/ Here is the code(piece): [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct TVITEM { public int mask; public IntPtr hItem; public int state; public int stateMask; [MarshalAs(UnmanagedType.LPStr)] public string pszText; // string pointer public int cchTextMax; public int iImage; public int iSelectedImage; public int cChildren; public IntPtr lParam; } StringBuilder sb = new StringBuilder(256); TVITEM tvItem = new TVITEM(); tvItem.hItem = (IntPtr)Int32.Parse(textBox1.Text); tvItem.cchTextMax = 256; tvItem.pszText = sb.ToString(); tvItem.mask = TVIF_TEXT; // TVIF_TEXT = 0x0001; IntPtr j = SendMessage(TreeHandle, (int)TV_Messages.TVM_GETITEM, (int)0, ref tvItem); MessageBox.Show(j.ToString()); I´m still having some troubles... I think my only problem now is with the the String Pointer... If I can make it work... I can Retrive my item´s name from the TreeView... and it´s done! Thanks! -- modified at 9:27 Friday 9th June, 2006

    O 1 Reply Last reply
    0
    • S suguimoto

      Hello! [modified] Thanx to OrlandoCurioso! I have tried to use a SendMessage with TVM_GETITEM with a TVITEM struct... but I got no result at all =/ Here is the code(piece): [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct TVITEM { public int mask; public IntPtr hItem; public int state; public int stateMask; [MarshalAs(UnmanagedType.LPStr)] public string pszText; // string pointer public int cchTextMax; public int iImage; public int iSelectedImage; public int cChildren; public IntPtr lParam; } StringBuilder sb = new StringBuilder(256); TVITEM tvItem = new TVITEM(); tvItem.hItem = (IntPtr)Int32.Parse(textBox1.Text); tvItem.cchTextMax = 256; tvItem.pszText = sb.ToString(); tvItem.mask = TVIF_TEXT; // TVIF_TEXT = 0x0001; IntPtr j = SendMessage(TreeHandle, (int)TV_Messages.TVM_GETITEM, (int)0, ref tvItem); MessageBox.Show(j.ToString()); I´m still having some troubles... I think my only problem now is with the the String Pointer... If I can make it work... I can Retrive my item´s name from the TreeView... and it´s done! Thanks! -- modified at 9:27 Friday 9th June, 2006

      O Offline
      O Offline
      OrlandoCurioso
      wrote on last edited by
      #2

      You use the TV_INSERTSTRUCT declare. This is correct: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct TVITEM { public int mask; public IntPtr hItem; public int state; public int stateMask; public IntPtr pszText; public int cchTextMax; public int iImage; public int iSelectedImage; public int cChildren; public IntPtr lParam; }

      S 1 Reply Last reply
      0
      • O OrlandoCurioso

        You use the TV_INSERTSTRUCT declare. This is correct: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct TVITEM { public int mask; public IntPtr hItem; public int state; public int stateMask; public IntPtr pszText; public int cchTextMax; public int iImage; public int iSelectedImage; public int cChildren; public IntPtr lParam; }

        S Offline
        S Offline
        suguimoto
        wrote on last edited by
        #3

        Thanky you very much!!!! NExt step: set correctly the values.. send set it to fire! Best Regards

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups