473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Screen Mate Creation

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.
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.
Nov 21 '05 #1
9 1796
"David Pendrey" <fa*******@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/>

Nov 21 '05 #2
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.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Ol****************@TK2MSFTNGP10.phx.gbl...
"David Pendrey" <fa*******@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/>

Nov 21 '05 #3
"David Pendrey" <fa*******@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/>

Nov 21 '05 #4
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
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Ou**************@tk2msftngp13.phx.gbl...
"David Pendrey" <fa*******@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/>

Nov 21 '05 #5
David,

"David Pendrey" <fa*******@dodo.com.au> schrieb:
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.


Take a look at the code in this sample:

<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/>

Nov 21 '05 #6
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
Nov 21 '05 #7
"David Pendrey" <fa*******@dodo.com.au> schrieb:
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
'Long' -> 'Int32'.
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As IntPtr,
ByVal lpRect As RECT) As Long
'ByVal lpRect' -> 'ByRef lpRect'. ') As Long' -> ') As Int32'.
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/>

Nov 21 '05 #8
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
Nov 21 '05 #9
David,

"David Pendrey" <fa*******@dodo.com.au> schrieb:
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.


P/Invoke 'WindowFromPoint'. Untested:

\\\
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/>
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ishwor | last post by:
Hi i use IDLE to code Python in my machine. What i haven't been able to do is call an in-built function called clear()/cls()/clr() because it mightn't exist. so what i did is coded my own function...
7
by: Mr. x | last post by:
Hello, Can Html code be a screen saver ? How can I do that ? Thanks :)
23
by: Dufe | last post by:
Hello all: To deal with the problem of differing user screen resolutions, I've explored: 1) making the pages in PHP, 2) having different pages on the same page and selecting the proper one via...
3
by: RICHARD BROMBERG | last post by:
I am using ASP and CDONTS to read data entered into a Form and E-mail the data entered to me. The Form is pretty long and has about thirty Text entry boxes and some radio buttons. After the...
1
by: u::l | last post by:
Hi I would like to ask directions regarding the creation of a screen that will pop up when a user logs in. He'll have to accept the terms of usage (a lab we are running). If he accepts he can...
3
by: steve | last post by:
Hi All I have set a splash screen form as the application splash screen in VB.net 2005 I t runs fine but stays on top when my login screen appears How can I shut the splash screen down when...
3
by: bala | last post by:
Hi Gurus The scenario A MS Access frontend application with Oracle Backend (Linked Tables). The Database UserID and password is not stored and each user has a unique UserID and password. There...
2
by: Patrick.O.Ige | last post by:
I would like to output raw xml string to the browser e.g <roteTarget au_lname="0.09" au_fname="0.045"> <MysteryShoppingTrgt>Where Does The Time Go</MysteryShoppingTrgt> </roteTarget> Any...
7
by: patr0805 | last post by:
I have a problem my application is a hide working spion the problem is that when I save in documents (The folder my application watching for file creation) then my msgbox(message) come thats not the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.