I want to have a form that all my actions go through it.
Actually, my form is semi transparent that is always on top most, and I just want to display information on it. And when I click on it, I actually want to click on the window behind it.
if you want to have the form with no titlebar too just change the form borderstyle = 0 - none
VB Code:
Option Explicit
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
2) If someone has been useful to you please show your respect by rating their posts.
3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
4) Before posting your question, make sure you checked this links: MICROSOFT MSDN -- VB FORUMS SEARCH
5)Support Classic VB - A PETITION TO MICROSOFT
And when I click on it, I actually want to click on the window behind it.
If I understand this correctly, you want to click on one form but have that click activate or perform some action on the form behind it, is that right?
If I understand this correctly, you want to click on one form but have that click activate or perform some action on the form behind it, is that right?
Basically, I want the computer to act as if there is nothing there... You can't do anything to it, except view it on the screen... and I want it on top most.
I will have a tray icon, where I can "enable it" so that you can actually click on it, and do whatever, but when in "viewing" mode, I just want it displaid on the screen that's it...
As you can see there is a semi transparent window (title Continous Backup) that is on top of Display Properties.
You can see the "OK" button, I want to click on the OK button, but I can't because the Continous Backup window is on top of it...
And actually, wiz126's code won't work because it makes my form complectly transparent, except the objects. And I don't want that...
I want the form as it is now, and be able to click "through" it anywhere on the form (well, maybe not the title bar, so I can move the window around).
Edit
Ow... And I also want it so you can't get the focus on it, when in "viewing" mode...
Last edited by CVMichael; Sep 9th, 2005 at 10:22 AM.
Michael,
you'd have to create a low level hooking so you can intersept all mouse and/or keyboard activities. I would recommend to look @ vbAccelerator's Journal (or something like that) sample project. Also, you would need to trap mouse movements but that is a simple thing. You would do all of this from underlying form(s) and from the top one. And the last thing: Karl E. Peterson has very nice sample to make form translucent so take a look at it.
I just realized, I only need the mouse to go through, because for the keyboard, the user would select the window first, then type. Even if my window is on top of it, typing in the window below still works.
But how do I know what window is below depending on where the mouse is ?
For example in the picture attached, there is the Display Properties window, and the tray.
How do I know if the mouse is over the Display Properties or the tray ? through my window ?
I think there is an API that returns the window handle by X, Y position of the mouse, but that API returns the window that is on top of the mouse, and in my case it is my window. But I need the window below mine...
...But how do I know what window is below depending on where the mouse is ? ...
You don't have to know - you "dispatch" it from that window and not from the one that's transparent. So, if your "hooking" routine detects mouse click and mouse pointer is within one of your buttons boundaries then you know what to do.
Don't you have multiple forms in your app where one is transparent and rest of them are not and you want to "click" on the button that "belongs" to a form that's beneath the transparent ? Unless I misunderstood you completly and the form you want to click on is some external app ...
2000+, most of the API's i'm using already (like transparency, and the round corners) are pretty advanced, so i'm sure the app won't work on lower OS's...
If I remember correctly there's an API for getting a window from a X/Y coordinate.
Then just subclass your window and redirect the mouse messages to
the hWnd returned by the API, if the coordinates get sent with the messages.
If I remember correctly there's an API for getting a window from a X/Y coordinate.
Then just subclass your window and redirect the mouse messages to
the hWnd returned by the API, if the coordinates get sent with the messages.
That would be WindowFromPoint().
Trouble is, your window is at that point. You need somehow to get the one beneath it.
I thought I had it with SendInput but then I realised it was simply duplicating the messages to your own window.
If I remember correctly there's an API for getting a window from a X/Y coordinate.
Then just subclass your window and redirect the mouse messages to
the hWnd returned by the API, if the coordinates get sent with the messages.
I was saying the same thing on post #11
The problem is that my form is always on top, so that API will return my window not the on ebelow it.
I thought I had it with SendInput but then I realised it was simply duplicating the messages to your own window.
What's wrong about that ?
If that sends the input to the window below, then that's all I need... I can just ignore the message on my window when in "viewing" mode.