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
  1. Home
  2. General Programming
  3. Visual Basic
  4. New to WPF. Getting frustrated

New to WPF. Getting frustrated

Scheduled Pinned Locked Moved Visual Basic
csharpjsonhelpc++wpf
11 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.
  • B beastmp13

    I am assuming this is relatively simple, but I have not been able to figure this out as of yet. I have an external WPF application that I cannot modify, but I would like to retrieve the data from a control in the application. I have the code to retrieve the application top window from the windows API and the code needed to traverse the visual tree to find child items. The problem lies in getting the window (which is contained in the HwndWrapper) into an object in my program that I can use to send to my code to find the controls I need. I have tried searching and have come up with the following: Using HwndSource.FromHwnd() - Returns Nothing Casting a custom window class to Window - Will not convert Inheriting from Window in custom window class - none of the attributes I need get populated this way. I know that this can be done, as the opensource project, snoop, is able to get the data. Unfortunately it is written in C# with a C++ ManagedInjector and I am not as proficient in these languages as I am in VB, so while I can read and understand some of it, the rest is lost on me. I truly hope that someone will be able to help me with this project, as I am ready to tear my hair out. Thanks in advance.

    X Offline
    X Offline
    xcal
    wrote on last edited by
    #2

    Hi Mr, I know few things about WPF, I can be wrong, but I vaguely remember that a WPF window do not use child windows, child windows do not 'exist' as usual, they are really painted only on one window. Hope this helps, Carlos.

    1 Reply Last reply
    0
    • B beastmp13

      I am assuming this is relatively simple, but I have not been able to figure this out as of yet. I have an external WPF application that I cannot modify, but I would like to retrieve the data from a control in the application. I have the code to retrieve the application top window from the windows API and the code needed to traverse the visual tree to find child items. The problem lies in getting the window (which is contained in the HwndWrapper) into an object in my program that I can use to send to my code to find the controls I need. I have tried searching and have come up with the following: Using HwndSource.FromHwnd() - Returns Nothing Casting a custom window class to Window - Will not convert Inheriting from Window in custom window class - none of the attributes I need get populated this way. I know that this can be done, as the opensource project, snoop, is able to get the data. Unfortunately it is written in C# with a C++ ManagedInjector and I am not as proficient in these languages as I am in VB, so while I can read and understand some of it, the rest is lost on me. I truly hope that someone will be able to help me with this project, as I am ready to tear my hair out. Thanks in advance.

      X Offline
      X Offline
      xcal
      wrote on last edited by
      #3

      Hi Mr, I know few things about WPF, I can be wrong, but I vaguely remember that a WPF window do not 'use' child windows, I mean child windows do not 'exist' as in C++, Windws Forms ,etc., but really they are all together painted only on one main window. Hope this helps, Carlos.

      B X 2 Replies Last reply
      0
      • X xcal

        Hi Mr, I know few things about WPF, I can be wrong, but I vaguely remember that a WPF window do not 'use' child windows, I mean child windows do not 'exist' as in C++, Windws Forms ,etc., but really they are all together painted only on one main window. Hope this helps, Carlos.

        B Offline
        B Offline
        beastmp13
        wrote on last edited by
        #4

        Thank you. I did read that the controls in a WPF application do not have handles and therefore must be traversed through with a TreeHelper/Walker, but I cannot figure out how to get the initial element to start the process. I have the names of the controls I need to find by using Inspect and Snoop, but finding the controls by name seems to require an initial element.

        X 1 Reply Last reply
        0
        • X xcal

          Hi Mr, I know few things about WPF, I can be wrong, but I vaguely remember that a WPF window do not 'use' child windows, I mean child windows do not 'exist' as in C++, Windws Forms ,etc., but really they are all together painted only on one main window. Hope this helps, Carlos.

          X Offline
          X Offline
          xcal
          wrote on last edited by
          #5

          Perhaps there exist another WPF code to accomplish this idea, (please excuse my English grammar, it is not my native language). Also there is no more the usual OnPaint event, it has been replaced also by OnRender or something more else, unhappiliy I don't remember now. Hope this helps, Carlos

          1 Reply Last reply
          0
          • B beastmp13

            Thank you. I did read that the controls in a WPF application do not have handles and therefore must be traversed through with a TreeHelper/Walker, but I cannot figure out how to get the initial element to start the process. I have the names of the controls I need to find by using Inspect and Snoop, but finding the controls by name seems to require an initial element.

            X Offline
            X Offline
            xcal
            wrote on last edited by
            #6

            Hi, perhaps the initial element is the biggest container, like, Canvas, InkCanvas, or it can be the main window

            B 1 Reply Last reply
            0
            • X xcal

              Hi, perhaps the initial element is the biggest container, like, Canvas, InkCanvas, or it can be the main window

              B Offline
              B Offline
              beastmp13
              wrote on last edited by
              #7

              Yes, the initial element would be the main window, but obtaining that element as an object that can be used is the issue that I'm having

              X 3 Replies Last reply
              0
              • B beastmp13

                Yes, the initial element would be the main window, but obtaining that element as an object that can be used is the issue that I'm having

                X Offline
                X Offline
                xcal
                wrote on last edited by
                #8

                Hi, try google with wpf spy utility, you'll find snoopwpf on codeplex, also http://msdn.microsoft.com/en-us/library/ms742404.aspx[^], hope this helps. Well, this does not answer you question, but I suppose it could help you, also I didn't try any of these tools yet

                1 Reply Last reply
                0
                • B beastmp13

                  Yes, the initial element would be the main window, but obtaining that element as an object that can be used is the issue that I'm having

                  X Offline
                  X Offline
                  xcal
                  wrote on last edited by
                  #9

                  Hi, try google with wpf spy utility, you'll find snoopwpf on codeplex, also http://msdn.microsoft.com/en-us/library/ms742404.aspx\[^\], hope this helps. Well, this does not answer you question, but I suppose it could help you, yet also I haven't not used any of these tools :)

                  1 Reply Last reply
                  0
                  • B beastmp13

                    Yes, the initial element would be the main window, but obtaining that element as an object that can be used is the issue that I'm having

                    X Offline
                    X Offline
                    xcal
                    wrote on last edited by
                    #10

                    Hi, try google with wpf spy utility, you'll find snoopwpf on codeplex, also http://msdn.microsoft.com/en-us/library/ms742404.aspx\[^\], hope this helps. Well, this does not answer you question, but I suppose it could help you, yet also I have not used any of these tools Smile | :)

                    B 1 Reply Last reply
                    0
                    • X xcal

                      Hi, try google with wpf spy utility, you'll find snoopwpf on codeplex, also http://msdn.microsoft.com/en-us/library/ms742404.aspx\[^\], hope this helps. Well, this does not answer you question, but I suppose it could help you, yet also I have not used any of these tools Smile | :)

                      B Offline
                      B Offline
                      beastmp13
                      wrote on last edited by
                      #11

                      I do have the snoop sourcecode and have looked through it, but unfortunately it is a bit too complex for me to understand in its entirety.

                      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