From: SQACSharp on 7 Nov 2006 20:15 OK I finally figure out how to use the enumwindow , enumchildwindow functions Dont hesitate if you know how to retrieve properties from an object that come from an external window by using it's handle... Ex: name, focus, caption, left, right, blablabla Thanks again for everything....
From: Willy Denoyette [MVP] on 8 Nov 2006 05:26 "SQACSharp" <lsdisciples(a)hotmail.com> wrote in message news:1162940193.897589.171290(a)b28g2000cwb.googlegroups.com... | damn.... Theses API functions are not well documented and finding a | working c# usage example is almost impossible. | | If I want to enumerate all the controls (windows) in a windows, like | SPY ++? | | [DllImport("User32.dll")] | public static extern int FindWindow(String lpClassName,String | lpWindowName); | | public delegate bool CallBack(IntPtr hwnd, int lParam); | | [DllImport("user32"), SuppressUnmanagedCodeSecurityAttribute] | public static extern int EnumWindows(CallBack x, int y); | | IntPtr hwnd = FindWindow(null, "Login"); | EnumWindows(???) | | What is delegate? | What is this callback? | How the hell i'm suppose to call the enumwindows to get the control of | my application? | | After looking for examples in the net for guessing how to call the | EnumWindow function, I still have no clue. | Once again, please pay attention to your API declarations, here is a sample that illustrates how to enumerate the top level windows. using System; using System.Runtime.InteropServices; // Callback must return a bool, see description of EnumWindowsProc in MSDN public delegate bool CallBack(IntPtr hwnd, IntPtr lParam); public sealed class Application { [DllImport("user32"), SuppressUnmanagedCodeSecurity] public static extern int EnumWindows(CallBack x, int y); public static void Main() { CallBack myCallBack = new CallBack(Application.ReportTopLevelWindows); EnumWindows(myCallBack, 0); } // must return true or false, true = continue enumeration, false = stop enumeration public static bool ReportTopLevelWindows(IntPtr hwnd, IntPtr lParam) { // use hwnd here... return true; } } Note also that all Windows API's are described in the platform sdk docs and on MSDN. These API's are C style API's, using them from C# requires a correct interop declaration and some knowledge of their functionality. So, what you are trying is to use an API set from a language which is not designed to consume this set, if you are not willing to spend some time with the interop stuff, I suggest you to write this in C/C++ using the the managed extentions or C++/CLI. Willy.
From: SQACSharp on 8 Nov 2006 08:36 Thanks again willy, now i can browse all the object in my window! The only thing i'm still playing with is to be able to retreive the properties of an object with it's handle. I try GetProps, GetProp API is it the correct API function to do this? Michel
From: Willy Denoyette [MVP] on 8 Nov 2006 11:31 "SQACSharp" <lsdisciples(a)hotmail.com> wrote in message news:1162992988.673013.261950(a)e3g2000cwe.googlegroups.com... | Thanks again willy, now i can browse all the object in my window! | | The only thing i'm still playing with is to be able to retreive the | properties of an object with it's handle. I try GetProps, GetProp API | is it the correct API function to do this? | | Michel | You have the choice, depending on what you want: GetWindowsRect, GetClassName, GetWindowsText, GetWindowsInfo, GetProp, EnumProps and EnumPropsEx. EnumProp and EnumPropsEx are the ones you should start with, but beware there is a lot of marshaling to do between unmanaged and managed. Willy.
From: SQACSharp on 8 Nov 2006 15:44 What is the meaning of managed vs unmanaged??? Since it takes me almost a day of work just to understand how to work with GetProps, atom name, etc. maybe you can point me to the right function? I try to use EnumProps ,i'm still having a problem for displaying the properties of an object (a window hwnd) but i can that this function is not exactly what I need because when callng the enumprops function i can see that the enumpropPROC is called only 4-5 times....Since I have almost 20-30 properties for my object it look like enumprops cannot retreive them. Just to make sure you understand what im trying to do : in C# create a new project, go in design mode, add a new TextBox and select "properties window" in the view menu. All the properties displayed in this window are the properties I need to retreive from the textBox. The particular thing in my case is that this textbox is not in my form but it's in an external application/window Is it me or theses functions are REALLY REALLY hard to use and understand??? Is there any good place with code example about theses functions instead of loosing all the days trying to use it in my code? Thanks, Willy Denoyette [MVP] a écrit : > "SQACSharp" <lsdisciples(a)hotmail.com> wrote in message > news:1162992988.673013.261950(a)e3g2000cwe.googlegroups.com... > | Thanks again willy, now i can browse all the object in my window! > | > | The only thing i'm still playing with is to be able to retreive the > | properties of an object with it's handle. I try GetProps, GetProp API > | is it the correct API function to do this? > | > | Michel > | > > You have the choice, depending on what you want: > GetWindowsRect, GetClassName, GetWindowsText, GetWindowsInfo, GetProp, > EnumProps and EnumPropsEx. > EnumProp and EnumPropsEx are the ones you should start with, but beware > there is a lot of marshaling to do between unmanaged and managed. > Willy.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: How to get any upload using WUA API ? Next: microsoft.common.target |