Enumwindows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wayne

    Enumwindows

    I have some code written in delphi that uses EnumWindows, I would like to
    begin to translate this code to C#. Is there a built in EnumWindows call in
    Csharp? or do I have to import the API and use it that way?

    Thanks
    Wayne


  • Shakir Hussain

    #2
    Re: Enumwindows

    You have to use DllImport

    [DllImport("user 32")]
    public static extern int EnumWindows(Enu mWindowsCB cb, int lparam);

    --
    Shak
    (Houston)


    "Wayne" <MeNotYou@commu nity.nospam> wrote in message
    news:#VwSRfpaEH A.1644@tk2msftn gp13.phx.gbl...[color=blue]
    > I have some code written in delphi that uses EnumWindows, I would like to
    > begin to translate this code to C#. Is there a built in EnumWindows call[/color]
    in[color=blue]
    > Csharp? or do I have to import the API and use it that way?
    >
    > Thanks
    > Wayne
    >
    >[/color]


    Comment

    • Telmo Sampaio

      #3
      Re: Enumwindows

      I am sorry for the stupid question, but what does EnumWindows do? Gives you
      a list of each MDI Child window? Each Form? Each Application?

      Telmo Sampaio
      "Wayne" <MeNotYou@commu nity.nospam> wrote in message
      news:#VwSRfpaEH A.1644@tk2msftn gp13.phx.gbl...[color=blue]
      > I have some code written in delphi that uses EnumWindows, I would like to
      > begin to translate this code to C#. Is there a built in EnumWindows call[/color]
      in[color=blue]
      > Csharp? or do I have to import the API and use it that way?
      >
      > Thanks
      > Wayne
      >
      >[/color]


      Comment

      • Wayne

        #4
        Re: Enumwindows

        It will give you a list of every top level window on the current desktop.
        From there for each window you can call EnumChildWindow recursivly which
        will give you a list of each of the child windows.

        Thanks
        Wayne


        "Telmo Sampaio" <tsampaio@gmail .com> wrote in message
        news:usu75AqaEH A.2944@TK2MSFTN GP11.phx.gbl...[color=blue]
        > I am sorry for the stupid question, but what does EnumWindows do? Gives[/color]
        you[color=blue]
        > a list of each MDI Child window? Each Form? Each Application?
        >
        > Telmo Sampaio
        > "Wayne" <MeNotYou@commu nity.nospam> wrote in message
        > news:#VwSRfpaEH A.1644@tk2msftn gp13.phx.gbl...[color=green]
        > > I have some code written in delphi that uses EnumWindows, I would like[/color][/color]
        to[color=blue][color=green]
        > > begin to translate this code to C#. Is there a built in EnumWindows call[/color]
        > in[color=green]
        > > Csharp? or do I have to import the API and use it that way?
        > >
        > > Thanks
        > > Wayne
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Wayne

          #5
          Re: Enumwindows

          No problem importing it, just wanted to make sure I had to, what about the
          following:

          EnumChildWindow s
          GetWindowtext
          GetWindow
          SendMessage
          PostMessage
          SetCursorPos

          The Help in VS.net is great, just its VERY BIG and sometimes hard to find
          exactly what you need.

          Thanks
          Wayne



          "Shakir Hussain" <shak@fakedomai n.com> wrote in message
          news:e5wHd9paEH A.3244@TK2MSFTN GP12.phx.gbl...[color=blue]
          > You have to use DllImport
          >
          > [DllImport("user 32")]
          > public static extern int EnumWindows(Enu mWindowsCB cb, int lparam);
          >
          > --
          > Shak
          > (Houston)
          >
          >
          > "Wayne" <MeNotYou@commu nity.nospam> wrote in message
          > news:#VwSRfpaEH A.1644@tk2msftn gp13.phx.gbl...[color=green]
          > > I have some code written in delphi that uses EnumWindows, I would like[/color][/color]
          to[color=blue][color=green]
          > > begin to translate this code to C#. Is there a built in EnumWindows call[/color]
          > in[color=green]
          > > Csharp? or do I have to import the API and use it that way?
          > >
          > > Thanks
          > > Wayne
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Shakir Hussain

            #6
            Re: Enumwindows


            a) SetCursorPos

            Cursor.Position .X = 50;
            Cursor.Position .Y = 50;

            b)GetWindow

            IntPtr handle = //set handle here
            Form myForm = Form.FromHandle (handle );

            c)GetWindowText

            IntPtr handle = //set handle here
            Form myForm = Form.FromHandle (handle );
            string Title = myForm.Text;

            d) EnumChildWindow s, SendMessage and Postmessage can be used using DllImport

            --
            Shak
            (Houston)



            "Wayne" <MeNotYou@commu nity.nospam> wrote in message
            news:utiKBKqaEH A.2840@TK2MSFTN GP11.phx.gbl...[color=blue]
            > No problem importing it, just wanted to make sure I had to, what about the
            > following:
            >
            > EnumChildWindow s
            > GetWindowtext
            > GetWindow
            > SendMessage
            > PostMessage
            > SetCursorPos
            >
            > The Help in VS.net is great, just its VERY BIG and sometimes hard to find
            > exactly what you need.
            >
            > Thanks
            > Wayne
            >
            >
            >
            > "Shakir Hussain" <shak@fakedomai n.com> wrote in message
            > news:e5wHd9paEH A.3244@TK2MSFTN GP12.phx.gbl...[color=green]
            > > You have to use DllImport
            > >
            > > [DllImport("user 32")]
            > > public static extern int EnumWindows(Enu mWindowsCB cb, int lparam);
            > >
            > > --
            > > Shak
            > > (Houston)
            > >
            > >
            > > "Wayne" <MeNotYou@commu nity.nospam> wrote in message
            > > news:#VwSRfpaEH A.1644@tk2msftn gp13.phx.gbl...[color=darkred]
            > > > I have some code written in delphi that uses EnumWindows, I would like[/color][/color]
            > to[color=green][color=darkred]
            > > > begin to translate this code to C#. Is there a built in EnumWindows[/color][/color][/color]
            call[color=blue][color=green]
            > > in[color=darkred]
            > > > Csharp? or do I have to import the API and use it that way?
            > > >
            > > > Thanks
            > > > Wayne
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Telmo Sampaio

              #7
              Re: Enumwindows

              Thanks Wayne! I am no good with Win32 APIs... I always cheated using (what's
              his name? Petzold?)'s API book.

              Telmo Sampaio

              "Wayne" <MeNotYou@commu nity.nospam> wrote in message
              news:#BRvaGqaEH A.2388@TK2MSFTN GP11.phx.gbl...[color=blue]
              > It will give you a list of every top level window on the current desktop.
              > From there for each window you can call EnumChildWindow recursivly which
              > will give you a list of each of the child windows.
              >
              > Thanks
              > Wayne
              >
              >
              > "Telmo Sampaio" <tsampaio@gmail .com> wrote in message
              > news:usu75AqaEH A.2944@TK2MSFTN GP11.phx.gbl...[color=green]
              > > I am sorry for the stupid question, but what does EnumWindows do? Gives[/color]
              > you[color=green]
              > > a list of each MDI Child window? Each Form? Each Application?
              > >
              > > Telmo Sampaio
              > > "Wayne" <MeNotYou@commu nity.nospam> wrote in message
              > > news:#VwSRfpaEH A.1644@tk2msftn gp13.phx.gbl...[color=darkred]
              > > > I have some code written in delphi that uses EnumWindows, I would like[/color][/color]
              > to[color=green][color=darkred]
              > > > begin to translate this code to C#. Is there a built in EnumWindows[/color][/color][/color]
              call[color=blue][color=green]
              > > in[color=darkred]
              > > > Csharp? or do I have to import the API and use it that way?
              > > >
              > > > Thanks
              > > > Wayne
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Wayne

                #8
                Re: Enumwindows

                a) x,y are marked as read only so that won't work
                b) the form may not be in my app, when I run this code using a handle that I
                know exists I get back a null refferance.
                c) see b
                d) cool I'll get that converted

                Any other ideas?

                Thanks
                Wayne

                "Shakir Hussain" <shak@fakedomai n.com> wrote in message
                news:e0X0RPqaEH A.972@TK2MSFTNG P12.phx.gbl...[color=blue]
                >
                > a) SetCursorPos
                >
                > Cursor.Position .X = 50;
                > Cursor.Position .Y = 50;
                >
                > b)GetWindow
                >
                > IntPtr handle = //set handle here
                > Form myForm = Form.FromHandle (handle );
                >
                > c)GetWindowText
                >
                > IntPtr handle = //set handle here
                > Form myForm = Form.FromHandle (handle );
                > string Title = myForm.Text;
                >
                > d) EnumChildWindow s, SendMessage and Postmessage can be used using[/color]
                DllImport[color=blue]
                >[/color]


                Comment

                • Wayne

                  #9
                  Re: Enumwindows

                  I played with the Cursor.Postion a bit more, turns out I have to create a
                  new Point and assign the postion property the point. So I am good there.
                  Just need to know how to find a window and get it's text if its not in my
                  app and possible that it's not a .net app.

                  Thanks
                  Wayne


                  "Wayne" <MeNotYou@commu nity.nospam> wrote in message
                  news:ezvlEyyaEH A.996@TK2MSFTNG P12.phx.gbl...[color=blue]
                  > a) x,y are marked as read only so that won't work
                  > b) the form may not be in my app, when I run this code using a handle that[/color]
                  I[color=blue]
                  > know exists I get back a null refferance.
                  > c) see b
                  > d) cool I'll get that converted
                  >
                  > Any other ideas?
                  >
                  > Thanks
                  > Wayne
                  >
                  > "Shakir Hussain" <shak@fakedomai n.com> wrote in message
                  > news:e0X0RPqaEH A.972@TK2MSFTNG P12.phx.gbl...[color=green]
                  > >
                  > > a) SetCursorPos
                  > >
                  > > Cursor.Position .X = 50;
                  > > Cursor.Position .Y = 50;
                  > >
                  > > b)GetWindow
                  > >
                  > > IntPtr handle = //set handle here
                  > > Form myForm = Form.FromHandle (handle );
                  > >
                  > > c)GetWindowText
                  > >
                  > > IntPtr handle = //set handle here
                  > > Form myForm = Form.FromHandle (handle );
                  > > string Title = myForm.Text;
                  > >
                  > > d) EnumChildWindow s, SendMessage and Postmessage can be used using[/color]
                  > DllImport[color=green]
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Kevin Yu [MSFT]

                    #10
                    Re: Enumwindows

                    Hi Wayne,

                    As far as I know, there is no managed class in .NET framework equivalent to
                    EnumWindows API. However, you can use P/Invoke to call that API. Here I
                    have found some sample codes that uses EnumWindows and GetWindowText in C#.
                    HTH.



                    dows/EnumWindows_Cod e.asp

                    Kevin Yu
                    =======
                    "This posting is provided "AS IS" with no warranties, and confers no
                    rights."

                    Comment

                    • Wayne

                      #11
                      Re: Enumwindows

                      Thanks to everyone for their hints and help. I got Enumwindows working over
                      the weekend.

                      Thanks
                      Wayne


                      "Kevin Yu [MSFT]" <v-kevy@online.mic rosoft.com> wrote in message
                      news:wqwVVcWbEH A.2688@cpmsftng xa06.phx.gbl...[color=blue]
                      > Hi Wayne,
                      >
                      > As far as I know, there is no managed class in .NET framework equivalent[/color]
                      to[color=blue]
                      > EnumWindows API. However, you can use P/Invoke to call that API. Here I
                      > have found some sample codes that uses EnumWindows and GetWindowText in[/color]
                      C#.[color=blue]
                      > HTH.
                      >
                      > http://www.codeproject.com/csharp/windowhider.asp
                      >[/color]
                      http://www.vbaccelerator.com/home/NE...numerating_Win[color=blue]
                      > dows/EnumWindows_Cod e.asp
                      >
                      > Kevin Yu
                      > =======
                      > "This posting is provided "AS IS" with no warranties, and confers no
                      > rights."
                      >[/color]


                      Comment

                      • Adam Clauss

                        #12
                        Re: Enumwindows

                        Maybe a little late if you've already solved the problem, but you may find this site useful for figuring out the PInvoke:


                        --
                        Adam Clauss
                        cabadam@tamu.ed u
                        "Wayne" <MeNotYou@commu nity.nospam> wrote in message news:%23qKHfqbb EHA.2388@TK2MSF TNGP11.phx.gbl. ..[color=blue]
                        > Thanks to everyone for their hints and help. I got Enumwindows working over
                        > the weekend.
                        >
                        > Thanks
                        > Wayne
                        >
                        >
                        > "Kevin Yu [MSFT]" <v-kevy@online.mic rosoft.com> wrote in message
                        > news:wqwVVcWbEH A.2688@cpmsftng xa06.phx.gbl...[color=green]
                        > > Hi Wayne,
                        > >
                        > > As far as I know, there is no managed class in .NET framework equivalent[/color]
                        > to[color=green]
                        > > EnumWindows API. However, you can use P/Invoke to call that API. Here I
                        > > have found some sample codes that uses EnumWindows and GetWindowText in[/color]
                        > C#.[color=green]
                        > > HTH.
                        > >
                        > > http://www.codeproject.com/csharp/windowhider.asp
                        > >[/color]
                        > http://www.vbaccelerator.com/home/NE...numerating_Win[color=green]
                        > > dows/EnumWindows_Cod e.asp
                        > >
                        > > Kevin Yu
                        > > =======
                        > > "This posting is provided "AS IS" with no warranties, and confers no
                        > > rights."
                        > >[/color]
                        >
                        >[/color]

                        Comment

                        Working...