I am attempting to create an app that will run "on top" of another app.
My app will create a transparent window over the other app for the
purpose of displaying information.
I am able to create my transparent app but cannot get the size and
position of the other app. I can get the handle of the other app using
the DllImport("user 32")...FindWind ow method. However, when I try to
get this size/position of this other window using
DllImport("gdi3 2")...GetBounds Rect it does not assign any value to the
Rectangle object referenced by GetBoundsRect.
I believe my problem lies in the 'flags' attribute of GetBoundsRect.
The method signature is as follows:
[DllImport("gdi3 2.dll")]
public static extern int GetBoundsRect(i nt hWnd, // handle to window
ref Rectangle rect, // bounding rectangle
int flags); // function options
All of the documentation I have found on this method refer to only one
valid value for the 'flags' variable: DCB_RESET (Clears the bounding
rectangle after returning it. If this flag is not set, the bounding
rectangle will not be cleared.) I cannot figure out how to set or
retrieve this value. Do I need to get this value from somewhere or do
I need to initialize in my program before using? Any help would be
appreciated.
I am fairly new to C# (coming from a Java background) and am using
Visual Studio 2005 Professional.
TIA,
Brian Enderle 4 6166 Br*****@gmail.c om wrote: I am attempting to create an app that will run "on top" of another app. My app will create a transparent window over the other app for the purpose of displaying information.
I am able to create my transparent app but cannot get the size and position of the other app. I can get the handle of the other app using the DllImport("user 32")...FindWind ow method. However, when I try to get this size/position of this other window using DllImport("gdi3 2")...GetBounds Rect it does not assign any value to the Rectangle object referenced by GetBoundsRect.
I believe my problem lies in the 'flags' attribute of GetBoundsRect. The method signature is as follows:
[DllImport("gdi3 2.dll")] public static extern int GetBoundsRect(i nt hWnd, // handle to window ref Rectangle rect, // bounding rectangle int flags); // function options
All of the documentation I have found on this method refer to only one valid value for the 'flags' variable: DCB_RESET (Clears the bounding rectangle after returning it. If this flag is not set, the bounding rectangle will not be cleared.) I cannot figure out how to set or retrieve this value. Do I need to get this value from somewhere or do I need to initialize in my program before using? Any help would be appreciated.
I am fairly new to C# (coming from a Java background) and am using Visual Studio 2005 Professional.
TIA, Brian Enderle
Hi Brian,
Instead, try using GetWindowRect: http://tinyurl.com/bd7eb
--
Hope this helps,
Tom Spink
Brian, However, when I try to get this size/position of this other window using DllImport("gdi 32")...GetBound sRect it does not assign any value to the Rectangle object referenced by GetBoundsRect.
GetBoundsRect isn't the function you want to use (it works on device
contexts, not windows). Have a look at GetWindowRect instead.
And you can't use a System.Drawing. Rectangle as the parameter type,
since it doesn't have the same layout as the GDI RECT struct.
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thanks for the quick replies. GetWindowRect works great but brings up
another question: I would like to have my transparent app lie within
the client area of the other app. I can use GetClientRect to get the
size of this area but how do I properly position it with respect to the
other app, ie; how do I account for the frame, toolbars, etc.?
GetClientRect returns the size of the client rectangle but not the
position of the rectangle within the window. Using Spy++ Client Rect.
shows the coordinates of the client rectangle relative to the window
but when I use the method (GetClientRect) within my program all I get
is the rectangle size (598, 0, 799, 0).
Thanks again,
Brian Enderle
Tom Spink wrote: Br*****@gmail.c om wrote:
I am attempting to create an app that will run "on top" of another app. My app will create a transparent window over the other app for the purpose of displaying information.
I am able to create my transparent app but cannot get the size and position of the other app. I can get the handle of the other app using the DllImport("user 32")...FindWind ow method. However, when I try to get this size/position of this other window using DllImport("gdi3 2")...GetBounds Rect it does not assign any value to the Rectangle object referenced by GetBoundsRect.
I believe my problem lies in the 'flags' attribute of GetBoundsRect. The method signature is as follows:
[DllImport("gdi3 2.dll")] public static extern int GetBoundsRect(i nt hWnd, // handle to window ref Rectangle rect, // bounding rectangle int flags); // function options
All of the documentation I have found on this method refer to only one valid value for the 'flags' variable: DCB_RESET (Clears the bounding rectangle after returning it. If this flag is not set, the bounding rectangle will not be cleared.) I cannot figure out how to set or retrieve this value. Do I need to get this value from somewhere or do I need to initialize in my program before using? Any help would be appreciated.
I am fairly new to C# (coming from a Java background) and am using Visual Studio 2005 Professional.
TIA, Brian Enderle
Hi Brian,
Instead, try using GetWindowRect: http://tinyurl.com/bd7eb
-- Hope this helps, Tom Spink Br*****@gmail.c om wrote: Thanks for the quick replies. GetWindowRect works great but brings up another question: I would like to have my transparent app lie within the client area of the other app. I can use GetClientRect to get the size of this area but how do I properly position it with respect to the other app, ie; how do I account for the frame, toolbars, etc.?
GetClientRect returns the size of the client rectangle but not the position of the rectangle within the window. Using Spy++ Client Rect. shows the coordinates of the client rectangle relative to the window but when I use the method (GetClientRect) within my program all I get is the rectangle size (598, 0, 799, 0).
Thanks again, Brian Enderle
Tom Spink wrote: Br*****@gmail.c om wrote:
> I am attempting to create an app that will run "on top" of another app. > My app will create a transparent window over the other app for the > purpose of displaying information. > > I am able to create my transparent app but cannot get the size and > position of the other app. I can get the handle of the other app using > the DllImport("user 32")...FindWind ow method. However, when I try to > get this size/position of this other window using > DllImport("gdi3 2")...GetBounds Rect it does not assign any value to the > Rectangle object referenced by GetBoundsRect. > > I believe my problem lies in the 'flags' attribute of GetBoundsRect. > The method signature is as follows: > > [DllImport("gdi3 2.dll")] > public static extern int GetBoundsRect(i nt hWnd, // handle to window > ref Rectangle rect, // bounding rectangle > int flags); // function options > > > All of the documentation I have found on this method refer to only one > valid value for the 'flags' variable: DCB_RESET (Clears the bounding > rectangle after returning it. If this flag is not set, the bounding > rectangle will not be cleared.) I cannot figure out how to set or > retrieve this value. Do I need to get this value from somewhere or do > I need to initialize in my program before using? Any help would be > appreciated. > > I am fairly new to C# (coming from a Java background) and am using > Visual Studio 2005 Professional. > > TIA, > Brian Enderle
Hi Brian,
Instead, try using GetWindowRect: http://tinyurl.com/bd7eb
-- Hope this helps, Tom Spink
Hi Brian,
Are you still trying to pass a System.Drawing. Rectangle as the parameter?
This won't work, because GetWindowRect and related functions using a 'Rect'
structure are not the right layout. You'll need to do something like this:
///
[StructLayout(La youtKind.Sequen tial)]
public struct NativeRect
{
public int left;
public int top;
public int right;
public int bottom;
}
///
(This is all from memory, I think I got the attribute right)
Then pass a NativeRect in as the parameter, this should give you the correct
rectangle co-ordinates.
--
Hope this helps,
Tom Spink This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Bierman |
last post by:
Please forgive the simplicy of this question. I have the following code
which attempts to determine the color of some text and set other text
to match that color. It works fine in Firefox, but does nothing in IE.
I'd be greatful for any assistance. Also, if I will have problems the
code on Opera or Safari, I'd appreciate any pointers--I don't...
|
by: fleemo17 |
last post by:
My organization is developing a set of "standards" for websites built
inhouse. The first question that comes to mind is what would be a good
standard default size for <p> text? 12 point? Which begs the
question, what unit of measurement should we use for specifying font
sizes, points or ems?
Thanks.
-Fleemo
|
by: Stuart Norris |
last post by:
Dear Group,
I am having a problem setting SocketOptionName.SendTimeout on a client
TCPIP application using the sockets in .NET. From the on-line help it
is possible to set a SocketOptionName.SendTimeout for sends on TCPIP
sockets.
In all the tests that I have done with both Async and Sync sends the
send returns immediately with the...
|
by: Microsoft |
last post by:
I'm not sure where to physically place my subroutines in vb.net I get
namespace and not declared errors...
Imports System
Imports System.Management
Public Class Form1
|
by: Roger Withnell |
last post by:
How to I find out what size text the browser is set to?
Thanks in anticipation.
| |
by: DBC User |
last post by:
I came across the application setting feature today and it is pretty
cool. I would like to know if someone can help me in the following
situation.
In my current project, On form closing I take the current size of the
windows form and its position and store them as serialized object per
user. Next time when the user login in, I read...
|
by: windows_mss |
last post by:
When I Select Source & Destination Dynamically,
Path Getting Scatter Across The Map...
hi,
i can able to get the Correct Route and Path for the corresponding Source
and destination, like this,
map.GetRoute('Redmond, Washington, United States','seattle, Washington, United States',VEDistanceUnit.KiloMeter,VERouteType.Shortest);
|
by: Andrus |
last post by:
..NET 2 Winforms application.
How to create new setting and set it default value in userSettings section
of app.config file or overwrite existing setting value ?
I found code below in this list which modifies Application setting section
but how to add new item to userSettings ?
Andrus.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |