-
Need alot of awnsers. Bitblt, Control Arrays...
Okay. i am already mad at the fact that control arrays are gone..... but anyways.
Is the syntax for BitBlt that same from vb6 and vb.net? Can i still use the vbSrcAnd, vbSrcCopy, and vbSrcPaint?
I have seen some things on going around control arrays, but how would i do some control arrays for bitblt? i tried
Dim picPicture(0) as picturebox
Dim i
for i = 0 to 10
redim preserve picPicture(i)
picPicture(i).Image = Application.Startuppath & "\img" & i & ".bmp"
next
Would that work for the bitblt?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
If you want to know how to use BitBlt in VB.NET then there's an easy way to find information.
http://www.google.com.au/search?q=bi...ient=firefox-a
That's got nothing whatsoever to do with how you store an Image. As for the code, as I said in another thread, if you want to store Images then you should be using an Image array, NOT a PictureBox array. If you know that you have 11 images then you don't need ReDim Preserve. Just create an array with 11 elements to begin with. Then, you actually have to create an Image object. This:
Code:
picPicture(i).Image = Application.Startuppath & "\img" & i & ".bmp"
is just a string. It doesn't magically become an Image because it contains the path to an image file. If you want to create an Image object from a file then you call Image.FromFile. I suggest that you start out by doing some reading on the Image class.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Could i in the code change all of the names of the pictureboxes i have on the form, and that would make them control arrays? bc i dont want to have to put all my images into a file with the .exe....
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Is this what you are talking about?
vb Code:
Dim PictureBoxCtrlArray As PictureBox() = {PictureBox1, PictureBox2, PictureBox3, PictureBox4}
PictureBoxCtrlArray(x).Image = x
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Quote:
Originally Posted by
Gamemaster1494
bc i dont want to have to put all my images into a file with the .exe....
Can't you just go to Project>Properties>Resources> then add all your images in there?
Then to get the image you just type:
PictureBox1.Image = My.Resources.FileName
..or you DONT want to do that?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
O_O I didnt know u could do that.......... Okay. Could i just use the my.resources.filename in bitblt? or would i have to put it in a picturebox?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Can I ask why you even need to use BitBlt?
System.Drawing.Graphics can do anything BitBlt can do.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
I am just so used to using it from vb6. I just switched over, and making sure i can do all the things i used to do in vb6, in vb.net.
How do i do clearscreen? in vb6, i used Me.Cls
And, what do i do instead of the form1.hDC? HELP
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Have you read any of the resources I provided in post #2?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Yeah. I have. Dont really understand what it came up with.... What i have seen so far, it ppl that have made functions for it. that isnt what i want... can u show me an example of code, for how to bitblt to the form? I saw something about the GetDC() function for the hDC?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Yes I can. Go to post #2, click the link I provided and then click the link for the first result. There's your code example. You want to use BitBlt? That's how you do it. People haven't "made functions for it". That code calls the Windows BitBlt function. If you don't understand it then I suggest that you try a bit harder. The code is commented throughout. If you don't know what the types and members are that are used, read the relevant documentation.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
okay.......... Thanks.... I think i got it.... Um... One thing, when i try to do
Code:
beepic(1).Image = My.Resources.Image1
It wont work.. How would i get the image from the image1? i have beepic(1) as a picturebox.....
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
How would i get it to work like that? i changed it to an object, and now it is saying Object variable or With block variable not set.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
First you give us code and no error message, then you change things and give us an error message with no code. You need to be much more coherent if you want us to be able to help you. You need to provide a FULL and CLEAR description of EXACTLY what you're trying to do, how you're trying to do it and what happens when you try. We don't know anything about what you're doing other than what you tell us, so telling us little bits and pieces is not going to work.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Code:
beepic(1).Image = Form2.Image1.Image
beepic(2).Image = Form2.Image2.Image
maskpic(1).Image = Form2.Imagemask1.Image
maskpic(2).Image = Form2.Imagemask2.Image
beepic(1).Size = Form2.Image1.Size
beepic(2).Size = Form2.Image1.Size
maskpic(1).Size = Form2.Image1.Size
maskpic(2).Size = Form2.Image1.Size
beep = 1
playerleft = 0
playertop = 0
i = 0
playerwidth = My.Resources.Image1.Width
playerheight = My.Resources.Image1.Height
And in a modual
Code:
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public beep As Integer 'pic for bee
Public maskp As Integer 'pic for mask
Public beepic(2) As Object
Public maskpic(2) As Object
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public KeyArray(300) As Boolean
Public playerleft As Integer
Public playertop As Integer
Public vbSrcAnd As VariantType = &H8800C6
Public vbSrcCopy As VariantType = &HCC0020
Public vbSrcPaint As VariantType = &HEE0086
It wont accept it. I have 4 pictureboxes on form2. is that more helpful?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
System.NullReferenceException was unhandled
Message="Object variable or With block variable not set."
Source="Microsoft.VisualBasic"
StackTrace:
at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase, CallType CallType) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments) at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\Owner\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb:line 16 at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
InnerException:
There is the exception detail.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
First things first, your API declarations are wrong. They look like they were created for VB6 so, at the very least, you'll have to change all the Longs to Integers. You should look online for declarations that were created for VB.NET in the first place.
Next, you're obviously using late-binding so you should get rid of that for a start. In your project properties you should set Option Strict On and then fix all the errors that result. That will ensure that all your late-binding and implicit conversions are changed to early-binding and explicit conversions. That will most likely highlight where the problem is an force you to fix it at design-time instead of the app failing at run-time.
-
1 Attachment(s)
Re: Need alot of awnsers. Bitblt, Control Arrays...
I H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NETI H8 VB.NET!!!!!!!!!!!!!!!!
I am so confused!!!!!! WHAT AM I DOING WRONG?!? HERE. i will upload my project. Please explain to me what i am doing wrong, because this is my first try at vb.net, from vb6...
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
If you want to learn by trial and error then you have to be prepared to live with the errors. Throwing something together when you have no idea what you're doing and then asking someone else to fix it is not really the way to learn. I'd suggest learning the basics of VB.NET first, and there are plenty of places that you can do that.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
I thought that vb.net uses the same language as vb6? and, it seems to be just that one thing with having Image(1) = form2.image1.image
idk y... After i figure this out, all the rest will be on my own. I have tried to fix it, but it isnt working. so plz... help... =(
Well, did the Option Strict, and i got that to okay everything... But, a new error with the stuff is happening as well. its saying Object reference not set to an instance of an object. What does that mean?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Quote:
Originally Posted by
Gamemaster1494
I thought that vb.net uses the same language as vb6?
VB.NET syntax is based on VB6 syntax. Code written in one looks much like code written in the other but they are two different languages and there are a lot of differences. Sometimes VB6 knowledge can be a hindrance when learning VB.NET because you can expect things to work the same and they often don't. The best thing you can do is assume that everything is different and consider it a bonus when something is the same.
Quote:
Originally Posted by
Gamemaster1494
its saying Object reference not set to an instance of an object. What does that mean?
That means that you are trying to access a member of an object that doesn't exist. For instance, this will throw a NullReferenceException:In that code 'f' is Nothing because a Form object is never assigned to it. If there's no Form then there's nothing to call Show on.
When a NullReferenceException occurs, the first thing to do is check all references on the line that threw it to find out which is Nothing. You can then work backwards to where you expected an object to be created/assigned.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
okay.... So, there has to be something wrong with me doing:
Public beepic(2) As PictureBox
Public maskpic(2) As PictureBox
But.... Hm..... So, how would i assign a picturebox object to them?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
In that code you are creating two arrays each with three elements, but each element is Nothing by default. If you want an element to refer to a PictureBox object then you have to create a PictureBox object first (which you may already have done in the designer) and then assign it to the appropriate element. If you want the array to contain three elements then you'll have to do that three times, or else initialise the array with three PictureBoxes when you create it.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Okay. Since i have no idea whatsoever that u just told me.. Im done. I am done with vb.net. I would rather be outdated, and be able to make cool games, than go and spend a long time trying to learn vb.net when my knoledge of vb6 hinders me from doing so. Thank you for ur help jmcilhinney.
-
Re: [officaly done with vb.net]0Need alot of awnsers. Bitblt, Control Arrays...
Well, just to be pedantic, you wouldn't really want to code games in VB.Net anyway. Go for C#, then you can even code on the XBox platform.
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Quote:
Originally Posted by Gamemaster1494
I would rather be outdated, and be able to make cool games, than go and spend a long time trying to learn vb.net when my knoledge of vb6 hinders me from doing so.
Despite what you like to think, you only have a tiny amount of knowledge of VB6.
Questions like "How can i exit out of a For Next loop?" (which you asked just a couple of weeks ago) are a very long way below the level where your existing knowledge will hinder you.
While there are some stumbling blocks when you start to switch, it wont take much effort - and if you do then lots of things will be much easier, which is part of the reason that several of us told you to switch when you first came to this site (long before you had ever attempted to even open a file).
Quote:
i have no idea whatsoever that u just told me
I'll break down the post a bit:
Quote:
Originally Posted by
jmcilhinney
In that code you are creating two arrays each with three elements, but each element is Nothing by default.
Just like in VB6, variables don't have a value until you give them one.
The code snippet posted earlier will fail in VB6 too for the same reason:
Code:
Dim f As Form
f.Show
Quote:
If you want an element to refer to a PictureBox object then you have to create a PictureBox object first (which you may already have done in the designer) and then assign it to the appropriate element.
You need to assign values to the array elements, just like you would in VB6.
The "designer" is where you view/edit the form inside VB (and put controls on it, etc).
Quote:
If you want the array to contain three elements then you'll have to do that three times, or else initialise the array with three PictureBoxes when you create it.
If you have put pictureboxes on the form, the easiest way to assign them to the array is with the code in post #4 (which is easier than it is in VB6).
You are easily capable of switching, and overall it will save you effort before you even finish this program... but whether you are willing to try is up to you.
-
Re: [officaly done with vb.net]0Need alot of awnsers. Bitblt, Control Arrays...
Yeah. Ik what the problem is. Its because i dont put Dim PicturePic as new picturebox
but because i have it as an array, it wont work.
And i know i only have a little knoledge of vb6, but i have already made a game, and working on another, and at least i can understand the way vb6 works. XD
@MaximilianMayrhofer: is making games on Xbox also possible with C++?
-
Re: Need alot of awnsers. Bitblt, Control Arrays...
Quote:
Originally Posted by
Gamemaster1494
okay.... So, there has to be something wrong with me doing:
Public beepic(2) As PictureBox
Public maskpic(2) As PictureBox
But.... Hm..... So, how would i assign a picturebox object to them?
First, are you aware that arrays start a 0? 0, 1, 2 = 3 objects. So you have 6 PictureBoxes?
Second, I already showed you how to asssign a picturebox object to them.
vb Code:
Public beepic() As PictureBox = { PictureBox1, PictureBox2, PictureBox3 }
This is the result;
beepic(0) = PictureBox1
beepic(1) = PictureBox2
beepic(2) = PictureBox3
So you can do this:
beepic(1).Image = x
I still don't see why you are having such trouble with VB.NET, enough to give up so easily? With that mind set, you won't last long as a programmer in an industry of constant change. You will always be out dated.
-
Re: [officaly done with vb.net]0Need alot of awnsers. Bitblt, Control Arrays...
Ok, I just looked at your code..
Your Module1.vb is just all wrong..
vb Code:
Module Module1
Public beep As Integer 'pic for bee
Public maskp As Integer 'pic for mask
Public beepic(2) As Object
Public maskpic(2) As Object
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Public KeyArray(300) As Boolean
Public playerleft As Integer
Public playertop As Integer
Public vbSrcAnd As VariantType = &H8800C6
Public vbSrcCopy As VariantType = &HCC0020
Public vbSrcPaint As VariantType = &HEE0086
beepic(1).Image = Form2.Image1.Image
beepic(2).Image = Form2.Image2.Image
maskpic(1).Image = Form2.Imagemask1.Image
maskpic(2).Image = Form2.Imagemask2.Image
beepic(1).Size = Form2.Image1.Size
beepic(2).Size = Form2.Image1.Size
maskpic(1).Size = Form2.Image1.Size
maskpic(2).Size = Form2.Image1.Size
End Module
... as far as I know, you can't assign properties to arrays like a declaration. You need to put that stuff (lines 13 to 20) in a sub or function. Call it from a Form_Load event or something..
Also, from the looks of your Form2 images, you are trying to use two images (main image and mask image) to create a transparent image. You don't have to do that in VB.Net. You can just use a .png image with transparency/opacity set in an image editor. There are other ways too..
-
Re: [officaly done with vb.net]0Need alot of awnsers. Bitblt, Control Arrays...
Hmm..... Yeah, with the assigning to picturbox, does it have to be an actual picturebox? (if so, thats okay) XD I think i gave up easily yesturday because i was really tired... xD
-
Re: [officaly done with vb.net]0Need alot of awnsers. Bitblt, Control Arrays...
Gamemaster, I was able to make your code work just by changing the Module1.vb like this;
vb Code:
Module Module1
Public beep As Integer 'pic for bee
Public maskp As Integer 'pic for mask
Public beepic() As PictureBox = {Nothing, Form2.Image1, Form2.Image2}
Public maskpic() As PictureBox = {Nothing, Form2.Imagemask1, Form2.Imagemask2}
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Public KeyArray(300) As Boolean
Public playerleft As Integer
Public playertop As Integer
Public vbSrcAnd As VariantType = &H8800C6
Public vbSrcCopy As VariantType = &HCC0020
Public vbSrcPaint As VariantType = &HEE0086
'beepic(1).Image = Form2.Image1.Image
'beepic(2).Image = Form2.Image2.Image
'maskpic(1).Image = Form2.Imagemask1.Image
'maskpic(2).Image = Form2.Imagemask2.Image
'beepic(1).Size = Form2.Image1.Size
'beepic(2).Size = Form2.Image1.Size
'maskpic(1).Size = Form2.Image1.Size
'maskpic(2).Size = Form2.Image1.Size
End Module
It animates the character, but when use the arrow keys it glitches. But it runs...
There is no reason to have a 3 object array, and leave the 1st object as "nothing". The only reason you have it that way, is because your Timer1_Tick is counting like this:
vb Code:
Private Sub Timer1_Tick.......
i = i + 1
If i = 3 Then
i = 1
End If
'the rest of the code removed
'beepic(i)
'maskpic(i)
End Sub
Every time your Timer1 ticks, it is adding 1 to i. When i gets to 3, it goes back to 1. So it's looping 1, 2, 1, 2, 1, 2, 1, 2, etc...
You should change it to this;
vb Code:
Private Sub Timer1_Tick.......
i += 1
If i = 2 Then
i = 0
End If
'the rest of the code removed
End Sub
If you do that, it will loop 0, 1, 0, 1, 0, 1, etc....
Then you can change your Module1.vb to this;
vb Code:
Module Module1
Public beep As Integer 'pic for bee
Public maskp As Integer 'pic for mask
Public beepic() As PictureBox = {Form2.Image1, Form2.Image2}
Public maskpic() As PictureBox = {Form2.Imagemask1, Form2.Imagemask2}
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Public KeyArray(300) As Boolean
Public playerleft As Integer
Public playertop As Integer
Public vbSrcAnd As VariantType = &H8800C6
Public vbSrcCopy As VariantType = &HCC0020
Public vbSrcPaint As VariantType = &HEE0086
End Module
Notice the difference?
After looking at how your program runs, It looks like you are only moving the graphics object (or ??) around, and not the actual image. So your character stays in one place, and the arrows are moving the area that is to be painted. That should be changed.