Transparency seems impossible in Visual Basic 2005 :..(

Hi,

I've been using VB 6.0 in the past, but .gif transparent images were too limited in colors, and .png seems so much better. So I got the beta 2 edition of Visual Basic 2005 (free off Microsoft's website, nice surprise!).

The thing is though, transparency like on the image I attached above doesn't seem possible. The transparent pixels just show the form background, not the other image below. Am I missing something here?

I was wondering what the best way (that's still simple for someone who hasn't programmed in a while, hehe) to make it work? In VB 6 a transparent text layer worked perfectly. So for example I could have giant "RELOAD" text on top of the screen, or your score etc... now with these layers it doesn't seem possible:

Layer 0 - Form Background
Layer 1 - Image of Scenery
Layer 2 - Bad guys / Hostages drawn on top of Scenery (to allow you to shoot one bad guy, and the other guys on screen to stay there)
Layer 3 - Text like "Reload", or objects like those hearts up top of this post

My entire game relys on this working, so any advice at all would be sooo great. Thanks SO much for reading!!

[1280 byte] By [TailsNZ] at [2008-2-16]
# 1
If you are talking about overlaying text on top of a graphic I would suggest you handle the paint event for the control you wish to place text on, for example:


Public Sub HandlePaint(sender As Object, e As PaintEventArgs)Handles myControl.Paint

Dim fnt As New Font("Tahoma",10,FontStyle.Bold,GraphicsUnit.Point)
Dim fntBrush As New SolidBrush(Color.Black)

e.Graphics.DrawString("My String",fnt,fntBrush,x,y)

fntBrush.Dispose()
fnt.Dispose()

End Sub


Good Luck,

Joe

JoeSmugeresky at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Thanks :) Sorry to ask again, but do you know of any demo's for it, ones complete that will be run right away? As I'm self taught in Qbasic (then took a short course on Visual Basic, and took things from there) and the example and other examples I've found so far don't seem to work on their own... they are missing other parts of a program needed or something, I'm not too sure. Sorry to be a pain.

Is the general idea though, you draw a path around the image file? Or that you draw the actual image using lines, shapes and colored pixels, and some sort of string or something holds the data?

Thanks so much again!

TailsNZ at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Hi

This is a bit late but for the others out there if they interested in achieving this effect in VB2005, i suggest using bitmaps. See example.

Public Class Form1

Dim coords As Point

Dim mschanged As Boolean = False

Dim bm As Bitmap = New Bitmap("C:\Picture1.png")'

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

coords = e.Location

If e.Button = Windows.Forms.MouseButtons.Left Then

mschanged = True

Me.Refresh()

End If

End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

e.Graphics.DrawImage(nbm, New Point(50, 50))

If mschanged Then

e.Graphics.DrawImage(bm, coords)

mschanged = False

End If

End Sub

End Class

Regards

Chaven

Chaven at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...