Help needed converting a VB6 Project

Discussion in 'Questions (Windows Mobile)' started by Drewpeu, Oct 12, 2008.

  1. Drewpeu

    Drewpeu Member Licensed User

    Hi Guys,
    Any help would be great. :sign0085:

    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

    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

    Sub Line(x1,y1,x2,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

    Thanks in advance,

  2. Erel

    Erel Administrator Staff Member Licensed User

    VB6 PictureBoxes are Image controls in Basic4ppc.
    Create 7 images (at the beginning of your program):
    'create 7 image controls
        For i = 0 To 7 
    "Form1","Image" & i,x,y,width,height)
    Move images:
    For i = vaderst To vaderfin
    Control("Image" & i).Left = looperx
    Control("Image" & i).Top = loopery
    You can store the images (not controls) in an ImageList and then assign these images to the image controls when needed:
    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.
  3. Drewpeu

    Drewpeu Member Licensed User

    Re Help Needed converting a VB6 Project

    Hi Erel,

    Thank you for your speedy and helpfull responce.

    The code samples you provided work a treat.

    The Randomize statement is used to generate randome enemy fire
    by setting and resetting the tmrTimer_EnemyFire Subroutine.

    Any chance that you or one of your many Library coders could
    create a Basic4ppc bitblt dll? :)

    Thanks again.

  4. Erel

    Erel Administrator Staff Member Licensed User

    There are several image libraries available.
    I'm not familiar enough with bitblt. What do you need it for? Maybe there is already an alternative way.
  5. Drewpeu

    Drewpeu Member Licensed User

    Hi again Erel,

    Please find below as requested!

    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:

    rectSrc.New1(0,0,bmp.Width,bmp.Height) 'The source rectangle.
    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)

    'get the IntPtr's of the graphics

    Dim HDC1 As IntPtr = srcPic.GetHdc

    'get the IntPtr's of the graphics

    Dim HDC2 As IntPtr = srcMem.GetHdc

    'get the picture

    BitBlt(HDC2, 0, 0, rect.Width, _
    rect.Height, HDC1, rect.X, rect.Y, 13369376)

    'Clone the bitmap so we can dispose this one

    copyRect = srcBmp.Clone()

    'Clean Up

    End Function

    Then all we need to do is call the function to return the image we want:

    Dim bmp = CType(copyRect(src, _
    New RectangleF(0, 0, 50, src.Height)), Bitmap)
    dest.Image = bmp.CloneShorthand:

    dest.Image = CType(copyRect(src, _
    New RectangleF(0, 0, 50, src.Height)), Bitmap).Clone

  6. Erel

    Erel Administrator Staff Member Licensed User

  7. agraham

    agraham Expert Licensed User

    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 :confused: I'll look again tomorrow - my brain's hurting!
  8. Erel

    Erel Administrator Staff Member Licensed User

    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?
  9. Drewpeu

    Drewpeu Member Licensed User

  10. agraham

    agraham Expert Licensed User

    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.
  11. Drewpeu

    Drewpeu Member Licensed User

    That is a shame!
    Thanks for trying, I have noticed that this forum is a very helpfull one unlike some others I know! :(
  12. taximania

    taximania Well-Known Member Licensed User

    :sign0137: That's some heavy reading.

    What came first, the chicken or the egg ? :sign0148:

    Do all theories come to a solution, or are some so debetable
    an answer is unobtainable :sign0136: ha ha ha
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice