How can I do the following:
PictureBox Arrays:
Bug(0) to Bug(7)
for i = vaderst to vaderfin
bug(i).Left = looperx:Bug(i).Top = loopery
next
Image Arrays:
imaBugSplat(0) to imgBugSplat(7)
Bug(BKI) = imgBugSplat(KI) '<---KILLS BUGS DEAD
I am also having trouble with this line:
Randomize Val(Right(Time$, 2)) / 3.17412
Line's and Shapes's were easy to convert:
pen1.Color = cGold
line(160,150,160,350)
Sub Line(x1,y1,x2,y2)
drawer.DrawLine(pen1.Value,x1,y1,x2,y2)
drawer.Refresh(x1-x2,y1-y2,x1-x2,y1-y2)
End Sub
Can we Use/Create VB6 Class Modules
Is their an equivelent of the following:
Private 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
VB6 PictureBoxes are Image controls in Basic4ppc.
Create 7 images (at the beginning of your program):
Code:
'create 7 image controls For i = 0To7 AddImage("Form1","Image" & i,x,y,width,height) Next
Move images:
Code:
For i = vaderst To vaderfin Control("Image" & i).Left = looperx Control("Image" & i).Top = loopery Next
You can store the images (not controls) in an ImageList and then assign these images to the image controls when needed:
Code:
Control("Image" & BKI) = ImageList.Item(KI)
What values do you expect from the Randomize statement?
It is not possible to use VB6 class modules..
Basic4ppc can only interact with .Net modules (c# or VB.Net)
There is no equivalent to BitBlt.
BitBlt quite simply makes copies of portions of the screen.
This is done by accessing the Windows hDC and other low level mind numbing things.
This is similar to your:
drawer.New1("Form1",true)
rectSrc.New1(0,0,bmp.Width,bmp.Height) 'The source rectangle.
rectDest.New1(120,120,36,32)
drawer.DrawImage1(bmp.Value,rectSrc.Value,rectDest .Value,true)
Form1.DrawString("Try to catch the smiley",12,10,10,200,50,cBlack)
It is a very fast routine, you dont get the flickering as you do in tha above routine
This has been on the go since VB3 and I still use it in VB6:
Declare the functions that are in the GDI32.DLL file so we can use them in VB.NET.
Declare Auto Function BitBlt Lib "GDI32.DLL" ( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Int32) As Boolean
Private Function copyRect(ByVal src As PictureBox, _
ByVal rect As RectangleF) As Bitmap
'Get a Graphics Object from the form
Dim srcPic As Graphics = src.CreateGraphics
'Create a EMPTY bitmap from that graphics
Dim srcBmp As New Bitmap(src.Width, src.Height, srcPic)
'Create a Graphics object in memory from that bitmap
Dim srcMem As Graphics = Graphics.FromImage(srcBmp)
Thanks.
Maybe I will get to it later.
However if anyone is interested in building such a library it shouldn't be too complicated.
Alex Yakhnin blog has a post about it: Alex Yakhnin - Creating a screen snapshot in CF v2.
However if anyone is interested in building such a library it shouldn't be too complicated.
That's what I thought but! .... .... there is some hidden twist that I don't presently understand. having obtained the hdcs for a couple of .NET Bitmaps I can BitBlt BLACKNESS and WHITENESS onto the destination bitmap but even thought BtBlt returns true (success) it won't pick up the contents of the source bitmap for SRCCOPY and the other SRC... raster ops. I have no idea why I'll look again tomorrow - my brain's hurting!
That's what I thought but! .... .... there is some hidden twist that I don't presently understand. having obtained the hdcs for a couple of .NET Bitmaps I can BitBlt BLACKNESS and WHITENESS onto the destination bitmap but even thought BtBlt returns true (success) it won't pick up the contents of the source bitmap for SRCCOPY and the other SRC... raster ops. I have no idea why I'll look again tomorrow - my brain's hurting!
Oops. There are many simple looking computer problems that end with huge efforts.
How about this one:
Can you write a program that receives some code and checks if this code always stop? http://en.wikipedia.org/wiki/Halting_problem
Lots of problems interoperating from GDI+ to GDI which explains the odd behaviour I have observed while experimenting. INFO: Interoperability Between GDI and GDI+. The key paragraph is "Using GDI on a GDI+ Graphics Object Backed by a Bitmap"
A concise summary of a highly technical situation.
An hDC from a .NET Graphics for a Bitmap created by Graphics.FromImage(Bitmap) is effectively write-only as the underlying bitmap is not initialised. Therefore you can draw on it but not use it as a source.
An hDC from a .NET Graphics for a Control created by Control.CreatGraphics().GetHdc() is both readable and writeable as a physical bitmap exists on the screen.
Therefore BitBlt can be used for screen capture using the SRCCOPY rasterop to a destination bitmap and for very little else as the combinatorial rasterops do not have a destination to read. For this reason the the BitBlt way of achieving tranparency and animation won't work as it relies on the combinatorial rasterops SRCAND and SRCPAINT
GDI gurus may have a way round this but I am afraid that I don't know enough about GDI (and don't want to learn either) so I'll have to give up for now.