|
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
|
|
|
|
|
I am creating a window application in .net. There I have used datagridview. I want to add button in gridview and on click of that button there should be popup window-form with employee number.
So how can i find row click event for button column
|
|
|
|
|
iam a having a string like this 'hi this is "john" iam a 'good,' boy:' so how can i get the words like this
hi
this
is
john
iam
a
good
boy
mean even though there are special characters we should get ony srtings
|
|
|
|
|
split is the right word. The string class has a split method.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I would be saying first replace all characters different then 0123456789abcdefghijklmnopqrstuvwxyz with "" EXCEPT spaces.
Then split on the on you space and voila !
Do Or Don't, there is no "try catch ex as exception end try"
|
|
|
|
|
What the....
|
|
|
|
|
He's talking about getting rid of the embedded double and single quotes in the string!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I know my thought process sometimes is funny to say the least, but i think this one is actually correct
Do Or Don't, there is no "try catch ex as exception end try"
|
|
|
|
|
I am presently using WM_COPYDATA and SendMessage to pass string data from a c++ app to my vb.net app.
Everything works but the response time gets sluggish in the c++ app waiting for vb.net app to process the message.
I would like to use PostMessage to speed up the string data transfer.
I read somewhere that I cannot use WM_COPYDATA with PostMessage.
How can I use PostMessage to do my data transfer?
I would like to see both the vb.net code for receiving data from PostMessage
and
the c++ code for sending data with PostMessage
Will the use of PostMessage really speed up the sending app?
Any suggestions , examples or links would be greatly appreciated
Roger
VS2005 Std / WinXP Pro SP3
|
|
|
|
|
I have no clue what you are talking about with the PostMessage deal but my i suggest making a thread that handles the c++ to vb messaging like a background worker?
|
|
|
|
|
Be sure that the transfered data is in a valid data block ie global object.
And test it on the 'secure' Vista.
Greetings from Germany
|
|
|
|
|
Thanks for your quick replies.
I am interested in knowing how to use PostMessage which is a Windows OS function similiar to SendMessage
Thanks
Roger
|
|
|
|
|
Can someone please take a look at this code:
I notice that the code is not sufficient to connect to an access database what is wrong with this code?
<Dim db as NEW ADO DB.Connection
Dim rs as NEW ADO DB.Record-set
DIM spath as String ' Path for the database
Dim SQLL as String ' Sql statement
sPath = app.path & "\DB\Name.mdb
>
What I want to do is to connect to an access database, I'd really appreciate some assistance.
Thank you!
|
|
|
|
|
|
I know that line of code provided by the link that you sent.
That only answered my question in an infinitestimate way.
So much for human stupidity.
Jesus Christ is Lord!
DR
|
|
|
|
|
What you have given me is the connection string. But I am also having problems with the declaration of the variables.
Do you know how to do that, if you do, I will really appreciate your assistance. I have made several attampts to do this but it seems I am stuck. All I need is to know how to declare the variables and how to connect - that's all!
Jesus Christ is Lord!
|
|
|
|
|
Sorry I have not used access for 10 years but your syntax seems to indicate you are using VB6, recordsets do not exist in .Net, if this is the case I can only offer you a paddle.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I have one application in vb6.I want to convert it in vb.net.I have been trying alot to use recordset but giving error like arguments are of wrong type,are of out range or conflict with one another.What i do?
code:
If rs1.State = 1 Then rs1.Close()
rs1.Open("select * from UserTable where User_Id ='" & Trim(TextBox1.Text) & "' and User_Password='" & Trim(TextBox2.Text) & "'")
If rs1.EOF = True Then
MsgBox(" Password is not correct, check again .....?", vbCritical + vbOKOnly, "")
i = i + 1
If i = 3 Then
MsgBox("Sorry, you have lost your time.....", MsgBoxStyle.Exclamation)
Application.Exit()
End If
Else
MDIParent1.Show()
Me.Hide()
End If
|
|
|
|
|
VB no longer has recordsets. You need to read up on ADO.NET to see what is currently available as there are many ways to get data to and from a database now to cater for different scenarios.
Also, the code you showed is susceptable to SQL Injection Attacks, you should read up on them also so you can protect your application. This article will show you what SQL Injection Attacks are and how to prevent them[^].
|
|
|
|
|
recordset is easy to use.i am not feel comfort with datasets.If any one know plz solve.
|
|
|
|
|
lahsiv wrote: i am not feel comfort with datasets
There are other ways to access data in .NET.
DataReaders, for example. Or you could use the Data Access Application Block (part of the Enterprise Library). Or you could use an ORM (Object Relational Mapping) tool such as XPO or NHibernate. Or... Or.... Or....
|
|
|
|
|
lahsiv wrote: .i am not feel comfort with datasets.
Tough - get used to it, as a programmer you will continiously need to learn new things. You have 2 choices here, upgrade your skills or quit.
Dataset, datatable, dataview are the tools you are going to have to work with in .net. Unless you to linq of course .
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Dataset, datatable, dataview are the tools you are going to have to work with in .net. Unless you to linq of course
There are even alternatives to that.
|
|
|
|
|
Colin Angus Mackay wrote: There are even alternatives to that.
Elaborate please - I may be guilty of finding the first successful method and ignoring other possibilities. I often do this and am continiously surprised when someone comes up with a different method.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Elaborate please
DataReaders for starters - Read my other post in this thread, the one to the OP, where I list a bunch of ways.
|
|
|
|