Results 1 to 10 of 10

Thread: can you convert this VB6 sample code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    170

    can you convert this VB6 sample code

    i have a sample code i downloaded sometime ago,
    and i need its functionality.
    i have a project that uses code snipets from it,
    but after i upgraded to .net, it dont work anymore.

    the problem is in the biggest problem is the api calls.

    can anyone convert this sample into
    a functional vb.net sample.
    Last edited by ZaidGS; Mar 26th, 2004 at 07:02 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    170
    here is the sample attached.
    Attached Files Attached Files

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    As a first rule , change all "Long" in the API calls to Integer types .

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    170
    i know this rule,
    the upgrade wizard did that.
    but that didnot work.

    if you think you can walk around
    this trouble, try attaching a working
    example of this sample.
    (its dont inlude much code,
    so guess anyone who knows
    how to do this thing, will not
    need much time at all)

  5. #5
    Hyperactive Member VBD's Avatar
    Join Date
    Apr 2001
    Location
    The Place Above The Place Below Heavin
    Posts
    278

    One Major Thing to change.

    Change all refrences from "Form1" that are in "Form1" to Me
    You need to refer to an instance of a class, not a class. In .NET a form is a class. Next, you can't use the line method. For:
    Form1.picture1.line
    change to
    Me.Picture1.CreateGraphics.DrawLine()
    I don' feel like changing that all, but you can probably fix that much.

    Also, replace .HDC
    with .Handle

    This should solve most if not all of your problems
    Hello

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    170

    Re: One Major Thing to change.

    Originally posted by VBD
    Next, you can't use the line method. For:
    Form1.picture1.line
    change to
    Me.Picture1.CreateGraphics.DrawLine()
    guess the way the .CreatGraphics.DrawLine() is
    used seems very tricky, you cannot do a simple
    replacement.

    btw, the full vb line for the line is:
    Form1.Picture1.Line (aX, aY)-(aX + 725, aY + 2.5 * TwipY), vbBlue, BF

    can anyone give a .net equivalent ?!?!
    Last edited by ZaidGS; Mar 27th, 2004 at 12:34 PM.

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by ZaidGS
    guess the way the .CreatGraphics.DrawLine() is
    used seems very tricky, you cannot do a simple
    replacement.

    btw, the full vb line for the line is:
    Form1.Picture1.Line (aX, aY)-(aX + 725, aY + 2.5 * TwipY), vbBlue, BF

    can anyone give a .net equivalent ?!?!
    The equivalent is :
    Graphcis.DrawLine(.....) .

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    170
    well, forget about the graphics thing,
    i've got it right sometime before
    (i once just tried .net, then stopped)
    but this bitblt api didnt work at all.

    i'v been testing on how to use it:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim srcRect = New Rectangle(50, 50, 100, 100)
    3.         Dim r As Region
    4.         If flip Then
    5.             g.SetClip(New Rectangle(50, 50, 100, 100), Drawing.Drawing2D.CombineMode.Replace)
    6.             g.DrawImage(PictureBox2.Image, 50, 50, srcRect, GraphicsUnit.Pixel)
    7.             'g.DrawImage(PictureBox2.Image, 50, 50, srcRect, GraphicsUnit.Pixel)
    8.             flip = False
    9.         Else
    10.             g.SetClip(New Rectangle(0, 0, 100, 100), Drawing.Drawing2D.CombineMode.Replace)
    11.             g.DrawImage(PictureBox3.Image, 0, 0, srcRect, GraphicsUnit.Pixel)
    12.             'g.DrawImage(PictureBox3.Image, 0, 0, srcRect, GraphicsUnit.Pixel)
    13.             flip = True
    14.         End If
    15.     End Sub
    is this code similar to what i should use ?!?!

    guess that could only COPY pixcels, not make "AND" and "OR"

    also, ive been trying it on my thing, its not working !!

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    170
    anyone can help further,
    or convert code ??

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by ZaidGS
    anyone can help further,
    or convert code ??
    Rewrite the code in VB.NET or ask specific questions .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width