473,396 Members | 2,111 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,396 software developers and data experts.

Translucent forms and property grids

I am attempting to make a form which has alpha transparency that
varies across the form, similar to the Adobe splash screens and
launchy:
http://www.launchy.net/images/screenshot_sheep.jpg

After a few different approaches, I have ended up overriding the
OnPaint method and using Graphics.CopyFromScreen and then painting the
transparent PNG on top of this using DrawImage. I have so far been
able to get the same effect when stationary, but there are 2 issues:

(1) As you drag the form, there is a slight delay between the form
being moved and the background being drawn. With launchy, the effect
is fluid and there is no delay.

(2) If the content behind the form changes it doesn't show. Is there
any way to trigger a repaint when any forms behind my form change (or,
is there a better way of doing what I am attempting to do)?

Any help please? I have had a look at the 'Vista' form on CodeProject,
which appears to be ideal - but I don't know C# and don't have a
compiler to see if the effect is in fact what I would like to achieve.

----------
Additionally, is it possible to reset all the GridItems within a
PropertyGrid to be reset, without recursively looping through each
item? I know of PropertyGrid.ResetSelectedProperty, but doesn't this
mean I'd have to select each item individually and reset it?

Finally, is it possible to deselect the current property? I tried
using PropertyGrid.SelectedGridItem = Nothing, but it throws an
error.
Thank you very much in advance,
James

Mar 20 '07 #1
3 1745
Any help please? I have had a look at the 'Vista' form on CodeProject,

What's the URL for the article?
but I don't know C#
Actually, C# is very similar to VB.Net, you just need to get used to
the different syntax. Here's a URL that should explain some of the
differences:

http://www.harding.edu/USER/fmccown/...omparison.html
and don't have a compiler to see if the effect is in fact what I would
like to achieve.
Sure you do, you probably just don't realize it. The compilers
for .Net languages actually ship with the framework, not visual
studio, so if you have the framework installed (which I'm sure you do
if your programming in VB.Net right now) you have the compiler. The
only thing you need to figure out is how to compile with the command
line arguments - a quick Google search should turn this info up.

By the way, the compiler's default directory for 2.0 is C:\WINDOWS
\Microsoft.NET\Framework\v2.0.50727\csc.exe

Thanks,

Seth Rowe
On Mar 20, 12:31 pm, jar...@gmail.com wrote:
I am attempting to make a form which has alpha transparency that
varies across the form, similar to the Adobe splash screens and
launchy:http://www.launchy.net/images/screenshot_sheep.jpg

After a few different approaches, I have ended up overriding the
OnPaint method and using Graphics.CopyFromScreen and then painting the
transparent PNG on top of this using DrawImage. I have so far been
able to get the same effect when stationary, but there are 2 issues:

(1) As you drag the form, there is a slight delay between the form
being moved and the background being drawn. With launchy, the effect
is fluid and there is no delay.

(2) If the content behind the form changes it doesn't show. Is there
any way to trigger a repaint when any forms behind my form change (or,
is there a better way of doing what I am attempting to do)?

Any help please? I have had a look at the 'Vista' form on CodeProject,
which appears to be ideal - but I don't know C# and don't have a
compiler to see if the effect is in fact what I would like to achieve.

----------
Additionally, is it possible to reset all the GridItems within a
PropertyGrid to be reset, without recursively looping through each
item? I know of PropertyGrid.ResetSelectedProperty, but doesn't this
mean I'd have to select each item individually and reset it?

Finally, is it possible to deselect the current property? I tried
using PropertyGrid.SelectedGridItem = Nothing, but it throws an
error.

Thank you very much in advance,
James

Mar 20 '07 #2
On 20 Mar, 17:33, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
Any help please? I have had a look at the 'Vista' form on CodeProject,

What's the URL for the article?
but I don't know C#

Actually, C# is very similar to VB.Net, you just need to get used to
the different syntax. Here's a URL that should explain some of the
differences:

http://www.harding.edu/USER/fmccown/...omparison.html
and don't have a compiler to see if the effect is in fact what I would
like to achieve.

Sure you do, you probably just don't realize it. The compilers
for .Net languages actually ship with the framework, not visual
studio, so if you have the framework installed (which I'm sure you do
if your programming in VB.Net right now) you have the compiler. The
only thing you need to figure out is how to compile with the command
line arguments - a quick Google search should turn this info up.

By the way, the compiler's default directory for 2.0 is C:\WINDOWS
\Microsoft.NET\Framework\v2.0.50727\csc.exe

Thanks,

Seth Rowe

On Mar 20, 12:31 pm, jar...@gmail.com wrote:
I am attempting to make a form which has alpha transparency that
varies across the form, similar to the Adobe splash screens and
launchy:http://www.launchy.net/images/screenshot_sheep.jpg
After a few different approaches, I have ended up overriding the
OnPaint method and using Graphics.CopyFromScreen and then painting the
transparent PNG on top of this using DrawImage. I have so far been
able to get the same effect when stationary, but there are 2 issues:
(1) As you drag the form, there is a slight delay between the form
being moved and the background being drawn. With launchy, the effect
is fluid and there is no delay.
(2) If the content behind the form changes it doesn't show. Is there
any way to trigger a repaint when any forms behind my form change (or,
is there a better way of doing what I am attempting to do)?
Any help please? I have had a look at the 'Vista' form on CodeProject,
which appears to be ideal - but I don't know C# and don't have a
compiler to see if the effect is in fact what I would like to achieve.
----------
Additionally, is it possible to reset all the GridItems within a
PropertyGrid to be reset, without recursively looping through each
item? I know of PropertyGrid.ResetSelectedProperty, but doesn't this
mean I'd have to select each item individually and reset it?
Finally, is it possible to deselect the current property? I tried
using PropertyGrid.SelectedGridItem = Nothing, but it throws an
error.
Thank you very much in advance,
James
Thanks for the reply.

The URL is: http://www.codeproject.com/useritems..._VistaForm.asp

Since posting I have downloaded C# EE and had a look. However, it is
not the same as launchy - in fact it has the same issues I am having.
"Jumpy" updates as you drag it, plus it doesn't account for any
changes behind the window.

As such, does anyone know any better way of doing this, or how launchy
does it? I believe it is written in C, the source can be downloaded
from sourceforge if anyone is interested.

Finally - any pointers with the PropertyGrid questions? Thank again,
James

Mar 21 '07 #3
On 21 Mar, 17:13, jar...@gmail.com wrote:
On 20 Mar, 17:33, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
Any help please? I have had a look at the 'Vista' form on CodeProject,
What's the URL for the article?
but I don't know C#
Actually, C# is very similar to VB.Net, you just need to get used to
the different syntax. Here's a URL that should explain some of the
differences:
http://www.harding.edu/USER/fmccown/...omparison.html
and don't have a compiler to see if the effect is in fact what I would
like to achieve.
Sure you do, you probably just don't realize it. The compilers
for .Net languages actually ship with the framework, not visual
studio, so if you have the framework installed (which I'm sure you do
if your programming in VB.Net right now) you have the compiler. The
only thing you need to figure out is how to compile with the command
line arguments - a quick Google search should turn this info up.
By the way, the compiler's default directory for 2.0 is C:\WINDOWS
\Microsoft.NET\Framework\v2.0.50727\csc.exe
Thanks,
Seth Rowe
On Mar 20, 12:31 pm, jar...@gmail.com wrote:
I am attempting to make a form which has alpha transparency that
varies across the form, similar to the Adobe splash screens and
launchy:http://www.launchy.net/images/screenshot_sheep.jpg
After a few different approaches, I have ended up overriding the
OnPaint method and using Graphics.CopyFromScreen and then painting the
transparent PNG on top of this using DrawImage. I have so far been
able to get the same effect when stationary, but there are 2 issues:
(1) As you drag the form, there is a slight delay between the form
being moved and the background being drawn. With launchy, the effect
is fluid and there is no delay.
(2) If the content behind the form changes it doesn't show. Is there
any way to trigger a repaint when any forms behind my form change (or,
is there a better way of doing what I am attempting to do)?
Any help please? I have had a look at the 'Vista' form on CodeProject,
which appears to be ideal - but I don't know C# and don't have a
compiler to see if the effect is in fact what I would like to achieve.
----------
Additionally, is it possible to reset all the GridItems within a
PropertyGrid to be reset, without recursively looping through each
item? I know of PropertyGrid.ResetSelectedProperty, but doesn't this
mean I'd have to select each item individually and reset it?
Finally, is it possible to deselect the current property? I tried
using PropertyGrid.SelectedGridItem = Nothing, but it throws an
error.
Thank you very much in advance,
James

Thanks for the reply.

The URL is:http://www.codeproject.com/useritems..._VistaForm.asp

Since posting I have downloaded C# EE and had a look. However, it is
not the same as launchy - in fact it has the same issues I am having.
"Jumpy" updates as you drag it, plus it doesn't account for any
changes behind the window.

As such, does anyone know any better way of doing this, or how launchy
does it? I believe it is written in C, the source can be downloaded
from sourceforge if anyone is interested.

Finally - any pointers with the PropertyGrid questions? Thank again,
James
Update: I've managed to solve the transparency problem. I can now draw
a semi-transparent form with alpha transparency that varies across the
form (using a PNG). After a good few hours searching & reading I came
up with some important searches: UpdateLayeredWindow and Per-Pixel
Alpha Blending. The following code loads a PNG and applies it to the
form, allowing you to see through it, drag it around & it updates as
smooth/quick as dragging a normal window. It even updates when things
behind it change. Note that this was from the (very) useful article:
http://www.codeproject.com/gdi/pxalphablend.asp

Now, however, I have a new issue! Any controls that were on the form
are no longer visible. I had a textbox, picturebox and label - all of
which are gone. It I remove the CreateParams part they reappear, but
the window is no longer transparent.

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC
As Integer) As Integer
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As
Integer) As Integer
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject
As Integer) As Integer
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal
hWnd As Integer) As Integer
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As
Integer, ByVal hDC As Integer) As Integer
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As
Integer, ByVal hObject As Integer) As Integer
Private Declare Function UpdateLayeredWindow Lib "user32" (ByVal
hWnd As IntPtr, ByVal hDCDst As IntPtr, ByRef pptDst As Point, ByRef
pSize As Size, ByVal hdcSrc As IntPtr, ByRef pprSrc As Point, ByVal
crKey As Integer, ByRef pblend As BLENDFUNCTION, ByVal dwFlags As
Integer) As Boolean

Private Structure BLENDFUNCTION
Public BlendOp As Byte
Public BlendFlags As Byte
Public SourceConstantAlpha As Byte
Public AlphaFormat As Byte
Public Sub New(ByVal _BlendOp As Byte, ByVal _BlendFlags As
Byte, ByVal _SourceConstantAlpha As Byte, ByVal _AlphaFormat As Byte)
BlendOp = _BlendOp
BlendFlags = _BlendFlags
SourceConstantAlpha = _SourceConstantAlpha
AlphaFormat = _AlphaFormat
End Sub
End Structure

Public Sub SetBackgroundImage(ByVal theImage As Bitmap)

Dim screenDc As IntPtr = GetDC(IntPtr.Zero)
Dim memDc As IntPtr = CreateCompatibleDC(screenDc)
Dim hBitmap As IntPtr = IntPtr.Zero
Dim oldBitmap As IntPtr = IntPtr.Zero

Try

hBitmap = theImage.GetHbitmap(Color.FromArgb(0))
oldBitmap = SelectObject(memDc, hBitmap)

UpdateLayeredWindow(Me.Handle, screenDc, New
Point(Me.Left, Me.Top), theImage.Size, memDc, New Point(0, 0), 0, New
BLENDFUNCTION(0, 0, 255, 1), 2)

Finally

ReleaseDC(IntPtr.Zero, screenDc)

If Not hBitmap.Equals(IntPtr.Zero) Then
SelectObject(memDc, oldBitmap)
DeleteObject(hBitmap)
End If

DeleteDC(memDc)

End Try

End Sub

Protected Overrides ReadOnly Property CreateParams() As
CreateParams
Get

Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H80000
Return cp

End Get
End Property
Question: How can I have a transparent window but with controls on it?
If this isn't possible, what is the best way to show a transparent
background and overlay the controls ontop?

Mar 26 '07 #4

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

Similar topics

6
by: Otie | last post by:
I have a project with a main form and a second form with a grid on it. Neither form is an MDI, thus neither form is a child - they are two independent forms. The CALCULATE button on the main form...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
16
by: Naveen Mukkelli | last post by:
Hi, How can we run the app on full-screen. I mean all the controls such as, text boxes, data grids on the form would also be resized or re-located automatically when we press maximize button...
7
by: Lloyd Dupont | last post by:
In my C# & MC++ app there is some drawing done through GDI (not +, but win32). I would like to be able to create a translucent HBRUSH. the RGB macro create only solid color... and, anyway,...
18
by: Jerry Boone | last post by:
I'm looking for a way to fire a public sub/function when a form is opened and closed - without using form level events. I have already done some extensive form work with instancing, looping...
0
by: James Arnold | last post by:
I am attempting to make a form which has alpha transparency that varies across the from, similar to launchy: http://www.launchy.net/images/screenshot_sheep.jpg After a few different approaches,...
3
by: jarnie | last post by:
I am attempting to make a form which has alpha transparency that varies across the form, similar to the Adobe splash screens and launchy: http://www.launchy.net/images/screenshot_sheep.jpg ...
0
by: tristanlbailey | last post by:
I have been attempting to solve this problem for a few weeks now, but I'm not having much luck... I would like to create a seamless fading effect on each form/window in my program; one that, when...
3
by: Sin Jeong-hun | last post by:
As far as I know if I change the form's opacity, every control on the form also inherits that opacity. But in many real applications (not application programs), we see opaque text (100% opacity) on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.