|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Screen Mate CreationI am trying to create a screen mate similar to the popular sheep program
which can run around the screen on top of other windows currently visible on the screen This will require me to obtain an outline of the forms currently being displayed on the screen so that my screen mate can run around on them. Aditional to this I will need to know how to display a form which is partly transparent around the edges. I have seen this done many times before. Thanks for the assistance everyone. "David Pendrey" <fairyd***@dodo.com.au> schrieb: P/invoke on 'EnumWindows'/'GetWindowRect' (MSDN, >I am trying to create a screen mate similar to the popular sheep program >which can run around the screen on top of other windows currently visible >on the screen This will require me to obtain an outline of the forms >currently being displayed on the screen so that my screen mate can run >around on them. <URL:http://www.pinvoke.net/>). > Aditional to this I will need to know how to display a form which is Region from Bitmap> partly transparent around the edges. I have seen this done many times > before. <URL:http://www.bobpowell.net/region_from_bitmap.htm> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thanks for the advice. The region from bitmap looks exactly like what I want
but I can't find out how to use the GetWindowRect function. I can find out how it is used but it seems to need a window identifier. I need to be able to find the location of every window currently open. Does this mean I have to iterate through every possible window ID or is there another API for doing this? Thanks again for the advice. Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:OlscQ%23RNFHA.3000@TK2MSFTNGP10.phx.gbl... > "David Pendrey" <fairyd***@dodo.com.au> schrieb: >>I am trying to create a screen mate similar to the popular sheep program >>which can run around the screen on top of other windows currently visible >>on the screen This will require me to obtain an outline of the forms >>currently being displayed on the screen so that my screen mate can run >>around on them. > > P/invoke on 'EnumWindows'/'GetWindowRect' (MSDN, > <URL:http://www.pinvoke.net/>). > >> Aditional to this I will need to know how to display a form which is >> partly transparent around the edges. I have seen this done many times >> before. > > Region from Bitmap > <URL:http://www.bobpowell.net/region_from_bitmap.htm> > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> "David Pendrey" <fairyd***@dodo.com.au> schrieb: As I already said in my previous post, you can enumerate windows (window > but it seems to need a window identifier. I need to be able to find the > location of every window currently open. Does this mean I have to iterate > through every possible window ID or is there another API for doing this? handles) by suing the 'EnumWindows' function with a callback. 'EnumWindows' Function <URL:http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/enumwindows.asp> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Ok, I have figured out what you meant now. However I can not find a way to
call the EnumWindowsProc function. I found sample code which said to declare the function like this Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Integer, ByVal lParam As Integer) As Integer This fails when i call it with retval = EnumWindows(AddressOf EnumWindowsProc, 0) The error provided is because Integer is not a delegate type. I have tried to fiddle around with delegates but to no luck. I'm fairly sure that I can get the rest to work after this function is being called correctly. Sorry to be such a hassle. Kind regards, David Pendrey Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:OulLBVeNFHA.2468@tk2msftngp13.phx.gbl... > "David Pendrey" <fairyd***@dodo.com.au> schrieb: >> but it seems to need a window identifier. I need to be able to find the >> location of every window currently open. Does this mean I have to iterate >> through every possible window ID or is there another API for doing this? > > As I already said in my previous post, you can enumerate windows (window > handles) by suing the 'EnumWindows' function with a callback. > > 'EnumWindows' Function > <URL:http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/enumwindows.asp> > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> David,
"David Pendrey" <fairyd***@dodo.com.au> schrieb: Take a look at the code in this sample:> This fails when i call it with > > retval = EnumWindows(AddressOf EnumWindowsProc, 0) > > The error provided is because Integer is not a delegate type. I have tried > to fiddle around with delegates but to no luck. <URL:http://groups.google.de/groups?selm=uh24OrXfCHA.1652%40tkmsftngp09> If you need further assistence on this issue, feel free to ask... -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried ,
I am now having problems getting the EnumParentProc function to call the GetWindowRect function. I am getting a null object reference when the GetWindowRect function is called. I have run the code in debug mode and found that the RECT object is created, and the hWnd is being passed in from the Win API. I have tried to modify the code so that the values being passed are integers or integer pointers and tried all different combinations but this did not seem to effect the output. I am trying to create a module within my project to handle the window positions which updates its information when the WindowsLocate function is called. I have included my code here. Any help would be appreciated. Regards, David Module mWindowLocations Private Delegate Function EnumWindowsProc(ByVal hWnd As IntPtr, ByVal lParam As IntPtr) As Boolean <System.Runtime.InteropServices.DllImport("user32", SetLastError:=True)> _ Private Function EnumWindows(ByVal ewp As EnumWindowsProc, ByVal lParam As IntPtr) As Boolean End Function Private mWindows As New Collection Private Structure RECT Dim Left As Long Dim Top As Long Dim Right As Long Dim Bottom As Long End Structure Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As IntPtr, ByVal lpRect As RECT) As Long Private ewp As EnumWindowsProc = New EnumWindowsProc(AddressOf EnumParentProc) Public Sub WindowsLocate() Do While mWindows.Count > 0 mWindows.Remove(1) Loop ' *** Place this code wherever you want to enumerate the windows. *** Dim retval As Long ' return value ' Use the above callback function to list all of the enumerated windows. Note that lParam is ' set to 0 because we don't need to pass any additional information to the function. retval = EnumWindows(ewp, IntPtr.Zero) End Sub ' Display the title bar text of all top-level windows. This ' task is given to the callback function, which will receive each handle individually. ' Note that if the window has no title bar text, it will not be displayed (for clarity's sake). ' *** Place this code in a module. This is the callback function. *** ' This function displays the title bar text of the window identified by hwnd. Private Function EnumParentProc(ByVal hWnd As IntPtr, ByVal lParam As IntPtr) As Boolean Dim R As RECT GetWindowRect(hWnd, R) mWindows.Add(R) EnumParentProc = True ' return value of 1 means continue enumeration End Function End Module
Show quote
Hide quote
"David Pendrey" <fairyd***@dodo.com.au> schrieb: 'Long' -> 'Int32'.> I am now having problems getting the EnumParentProc function to call the > GetWindowRect function. I am getting a null object reference when the > GetWindowRect function is called. I have run the code in debug mode and > found that the RECT object is created, and the hWnd is being passed in > from the Win API. >[...] > Module mWindowLocations > > Private Delegate Function EnumWindowsProc(ByVal hWnd As IntPtr, ByVal > lParam As IntPtr) As Boolean > > <System.Runtime.InteropServices.DllImport("user32", SetLastError:=True)> _ > > Private Function EnumWindows(ByVal ewp As EnumWindowsProc, ByVal lParam As > IntPtr) As Boolean > > End Function > > Private mWindows As New Collection > > Private Structure RECT > > Dim Left As Long > > Dim Top As Long > > Dim Right As Long > > Dim Bottom As Long > Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As IntPtr, 'ByVal lpRect' -> 'ByRef lpRect'. ') As Long' -> ') As Int32'.> ByVal lpRect As RECT) As Long > Dim retval As Long ' return value => 'retval As Int32'.-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
I am very thankfull for your help so far. I should have thought of this sooner but is there a way to find the topmost window at a specified X,Y position on the screen? Using what I have so far it returns much more windows than I would have expected, which is going to impact on the performance. Thanks again for the help so far Regards, David David,
"David Pendrey" <fairyd***@dodo.com.au> schrieb: P/Invoke 'WindowFromPoint'. Untested:> I am very thankfull for your help so far. I should have thought of this > sooner but is there a way to find the topmost window at a specified X,Y > position on the screen? Using what I have so far it returns much more > windows than I would have expected, which is going to impact on the > performance. \\\ Public Structure POINT Public x As Int32 Public y As Int32 End Structure Public Declare Function WindowFromPoint Lib "User32.dll" ( _ ByRef Point As POINT _ ) As IntPtr .. .. .. Dim pt As POINT pt.x = ... pt.y = ... Dim hwnd As IntPtr = WindowFromPoint(pt) /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Why have a DBNull?
Process.Start("Winword.exe") problem OutOfMemory exception loading ZIP or JPEG compressed TIFs from file SQL Question typeof Outlook.Application is not defined. PIA installed and setup correctly. How do you put a hyperlinked text on a blank form Windowless application, pls help. How to debug application? Keypress Event not Firing for enter key |
|||||||||||||||||||||||