|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
manged alternative to get the complete text from each open windowrather use only managed code rather than unmanaged code my current solution relies on. The purpose is to get the text in each open window even/especially for child windows in other non managed mdi apps - if excel has 3 books open or any other mdi app has several windows open, I'd like the complete text from each window. The current solution gives me more info than i need (quite a bit), as i'm getting not just the text from each open window - i'm getting other stuff that i am not familiar with with my desired info. heres the code i'm using currently: # Windows Form Designer generated code # Private Delegate Function EnumWindowsProc( _ ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32 Private Declare Function EnumWindows Lib "user32.dll" _ (ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Int32) As Int32 Private Declare Function GetWindowTextLength Lib _ "user32.dll" Alias "GetWindowTextLengthA" _ (ByVal hwnd As IntPtr) As Int32 Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" _ (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32 Private Function EnumWindowsCallBack(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32 Dim sSave As String sSave = Space(GetWindowTextLength(hwnd) + 1) GetWindowText(hwnd, sSave, Len(sSave)) sSave = Microsoft.VisualBasic.Left(sSave, Len(sSave) - 1) If sSave.Trim <> "" Then lv.Items.Add(sSave) End If Return 1 End Function Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click lv.Items.Clear() EnumWindows(AddressOf EnumWindowsCallBack, 0) End Sub Either a manged only alternative(perfect), a change to make to get only the window text and not everythign else (a close second) or direction to go look further (always appreciated) would be nice. gabe Gabe,
You know this page? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/win32map.asp I hope this helps, Cor Cor, darn i'm glad you responded, you've been invaluable in the past. yeah,
i spent the last 45 minutes staring at that exact page, checking documentation for the classes and looking for samples (google, .net2themax, et al) and while i see that the Win32 function GetWindowText is mapped to System.Windows.Forms.Form.Text, I didnt see how that class could be used to gather the window text for other/external programs and thier the window text for mdiChildren. are you looking at another class or do i (again) misunderstand that class, or are you using more than just that class? gabe Show quoteHide quote "Cor Ligthert" wrote: > Gabe, > > You know this page? > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/win32map.asp > > I hope this helps, > > Cor > > > "gabe" <g***@discussions.microsoft.com> schrieb: The 'Form' class is not a replacement of the Win32 API calls you mentioned > while i see that the Win32 function GetWindowText is mapped to > System.Windows.Forms.Form.Text, I didnt see how that class could be used > to > gather the window text for other/external programs and thier the window > text > for mdiChildren. are you looking at another class or do i (again) > misunderstand that class, or are you using more than just that class? in your post. Some of the functionality you want to archieve can be archieved using the 'System.Diagnostics.Process' class and its 'GetProcesses' method and 'MainWindowTitle' property, however, I doubt that a fully managed solution is possible. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> bummer - really wish someone i respected less was telling that they doubted a
fully managed solution was possible, i saw the MainWindowTitle property and thought maybe i had skipped over ChildWindowTitles() or ChildWindow() on the page, but no - just dont seem to exist. sadly, MainWindowTitle doesnt provide what i'm looking for. the solution is to run a db query based on some text found in another process' childWindowTitle, then start an additional process based on the results of the query. looks like i'm leaving in the win32api calls. oh well. if you run my sample code you'll see that i get a bunch of entries that arent visable windows? can i somehow remove the entires that arent windows captions? Aside from www.pinvoke.net, where do you go for vb.net win32api reference? thanks tons gabe |
|||||||||||||||||||||||