Click here to Skip to main content
15,918,624 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionIcon for a new control (vb.net 2008) Pin
JR21218-Aug-08 2:33
JR21218-Aug-08 2:33 
AnswerRe: Icon for a new control (vb.net 2008) Pin
John_Adams18-Aug-08 3:50
John_Adams18-Aug-08 3:50 
GeneralRe: Icon for a new control (vb.net 2008) Pin
JR21219-Aug-08 7:40
JR21219-Aug-08 7:40 
QuestionRe: Icon for a new control (vb.net 2008) Pin
JR21219-Aug-08 23:40
JR21219-Aug-08 23:40 
QuestionDeploying font in setup files Pin
helelark12318-Aug-08 2:15
helelark12318-Aug-08 2:15 
AnswerRe: Deploying font in setup files Pin
Thomas Stockwell18-Aug-08 5:39
professionalThomas Stockwell18-Aug-08 5:39 
AnswerRe: Deploying font in setup files Pin
Manas Bhardwaj18-Aug-08 5:58
professionalManas Bhardwaj18-Aug-08 5:58 
Question[SOLVED!!!] Trying to draw custom form bitmap Pin
The Cadde18-Aug-08 0:21
The Cadde18-Aug-08 0:21 
I SOLVED THIS MYSELF. If you need to know how, please visit http://www.xtremevbtalk.com/showthread.php?p=1301781&posted=1#post1301781[^]
------------------------------------------------------------------------------------------
I have been bashing my head against this wall for quite some time, there is a lack of information on the subject.

I am trying to draw a .png with it's alpha channel as a graphic on a form. The alpha channel works well when i draw on the existing form background but i want nothing BUT the image to be drawn. No background and any semi transparent pixels are to be drawn as is. (see through)
I have tried plenty of methods until i came across http://www.codeproject.com/KB/vb/xDock.aspx[^]

Now here is the question(s) i have:

* What steps do i need to take to override all painting functions of a form and only use GDI and GDI+ to draw Bitmaps.
* And what steps do i need to take to draw .png files with alpha transparency on that said form using GDI and GDI+
* I have the source code from the XDock example but there is very little explanation to how it works, i would love it if someone could explain HOW it does the job and how i can write my own version to understand it.

At this current time my source code is a cluster**** of different approaches, the current lines i am trying to get to work is:

Public Sub SetBitmap(ByVal bitmap As Bitmap, ByVal opacity As Byte)
    If Not (bitmap.PixelFormat = PixelFormat.Format32bppArgb) Then
        Throw New ApplicationException("The bitmap must be 32ppp with alpha-channel.")
    End If
    hBitmap = bitmap.GetHbitmap(Color.FromArgb(0))
    oldBitmap = Win32.SelectObject(memDc, hBitmap)
    Dim size As Win32.Size = New Win32.Size(bitmap.Width, bitmap.Height)
    Dim pointSource As Win32.Point = New Win32.Point(0, 0)
    Dim topPos As Win32.Point = New Win32.Point(Left, Top)
    Dim blend As Win32.BLENDFUNCTION = New Win32.BLENDFUNCTION
    blend.BlendOp = Win32.AC_SRC_OVER
    blend.BlendFlags = 0
    blend.SourceConstantAlpha = opacity
    blend.AlphaFormat = Win32.AC_SRC_ALPHA
    Win32.UpdateLayeredWindow(Handle, screenDc, topPos, size, memDc, pointSource, 0, blend, Win32.ULW_ALPHA)
End Sub


This is what should draw the form's graphic content, at the moment i get nothing drawn.

Here follows my bitmap graphics:

Dim SF As StringFormat = New StringFormat()
SF.Alignment = StringAlignment.Center
SF.LineAlignment = StringAlignment.Center
BB.DrawString("* EDIT MODE *" & vbCrLf & ActiveEditObj.Name & vbcrlf & Cursor.Position.ToString & vbcrlf & EditHasMouse0.ToString, HugeBFont, New SolidBrush(Color.FromArgb(50 + (Flux * 100), 255, 0, 0)), me.ClientRectangle, SF)
        
Dim BitTest As Bitmap = New Bitmap(application.StartupPath & "\img\closebtn.png")
BB.DrawImageUnscaled(BitTest, 10, 10)


Where BB is a graphic object created from BBBitmap.


BBBitmap = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
BB = graphics.FromImage(BBBitmap)


I have a reoccurring event that calls:

SetBitmap(BBBitmap, 255)


And like i said above, NOTHING gets drawn. But if i place a button on the form it is drawn and flickers alot, so something is definitely working. But not as intended.

Thank you for any help!

modified on Monday, August 18, 2008 1:12 PM

Questionrow click event in datagridview Pin
Milind Panchal17-Aug-08 23:26
Milind Panchal17-Aug-08 23:26 
Questionhi how this string is splited and how to eliminate special characters Pin
lakshmichawala17-Aug-08 19:59
lakshmichawala17-Aug-08 19:59 
AnswerRe: hi how this string is splited and how to eliminate special characters Pin
Christian Graus17-Aug-08 21:55
protectorChristian Graus17-Aug-08 21:55 
AnswerRe: hi how this string is splited and how to eliminate special characters Pin
Noctris17-Aug-08 21:57
Noctris17-Aug-08 21:57 
GeneralRe: hi how this string is splited and how to eliminate special characters Pin
Dave Kreskowiak18-Aug-08 1:42
mveDave Kreskowiak18-Aug-08 1:42 
GeneralRe: hi how this string is splited and how to eliminate special characters Pin
Mycroft Holmes18-Aug-08 12:35
professionalMycroft Holmes18-Aug-08 12:35 
GeneralRe: hi how this string is splited and how to eliminate special characters Pin
Noctris8-Oct-08 0:28
Noctris8-Oct-08 0:28 
QuestionHelp with PostMessage Pin
PeterRod17-Aug-08 17:05
PeterRod17-Aug-08 17:05 
AnswerRe: Help with PostMessage Pin
The Cadde18-Aug-08 0:24
The Cadde18-Aug-08 0:24 
AnswerRe: Help with PostMessage Pin
KarstenK18-Aug-08 2:41
mveKarstenK18-Aug-08 2:41 
GeneralRe: Help with PostMessage Pin
PeterRod18-Aug-08 8:38
PeterRod18-Aug-08 8:38 
QuestionAccess Database and VB.net Pin
Rhoden17-Aug-08 14:18
Rhoden17-Aug-08 14:18 
AnswerRe: Access Database and VB.net Pin
Mycroft Holmes17-Aug-08 14:57
professionalMycroft Holmes17-Aug-08 14:57 
GeneralRe: Access Database and VB.net Pin
Rhoden18-Aug-08 5:49
Rhoden18-Aug-08 5:49 
GeneralRe: Access Database and VB.net Pin
Rhoden18-Aug-08 5:56
Rhoden18-Aug-08 5:56 
GeneralRe: Access Database and VB.net Pin
Mycroft Holmes18-Aug-08 12:27
professionalMycroft Holmes18-Aug-08 12:27 
Questionalternative of recordset in vb.net Pin
lahsiv17-Aug-08 4:56
lahsiv17-Aug-08 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.