Results 1 to 7 of 7

Thread: Why does the circle apear on the screen instead of in the picturebox? :S

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    Why does the circle apear on the screen instead of in the picturebox? :S

    VB Code:
    1. Option Explicit
    2. Dim DX As New DirectX7
    3. Dim DD As DirectDraw7
    4. Dim Primary As DirectDrawSurface7
    5. Dim ddsd1 As DDSURFACEDESC2
    6. Dim ddsd2 As DDSURFACEDESC2
    7. Dim ddClipper As DirectDrawClipper
    8. Dim bInit As Boolean
    9.  
    10.  
    11. Sub Form_Load()
    12. init
    13. End Sub
    14.  
    15.  
    16. Sub init()
    17. On Error GoTo ErrHandler
    18. Set DD = DX.DirectDrawCreate("")
    19. Call DD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL)
    20.  
    21. ddsd1.lFlags = DDSD_CAPS
    22. ddsd1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
    23. Set Primary = DD.CreateSurface(ddsd1)
    24.  
    25. ddsd2.lFlags = DDSD_CAPS
    26. ddsd2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
    27.  
    28.  
    29. Set ddClipper = DD.CreateClipper(0)
    30. ddClipper.SetHWnd picbox.hWnd
    31. Primary.SetClipper ddClipper
    32.  
    33.  
    34. bInit = True
    35.  
    36.  
    37. blt
    38.  
    39. Exit Sub
    40. ErrHandler:
    41. MsgBox "Unable to initialize DirectDraw - Closing program", vbInformation, "error"
    42. End
    43. End Sub
    44.  
    45.  
    46. Private Sub Form_Resize()
    47. picbox.Width = Me.ScaleWidth
    48. picbox.Height = Me.ScaleHeight
    49. blt
    50. End Sub
    51.  
    52.  
    53. Sub blt()
    54. On Error GoTo ErrHand:
    55. If bInit = False Then Exit Sub
    56. Dim ddrval As Long
    57. Dim r1 As RECT 'The screen size
    58. Dim r2 As RECT 'The bitmap size
    59.  
    60. Call DX.GetWindowRect(picbox.hWnd, r1)
    61. r2.Bottom = ddsd2.lHeight
    62. r2.Right = ddsd2.lWidth
    63.  
    64. Primary.DrawCircle 1, 200, 100
    65.  
    66. 'also tried
    67. 'ddrval = Primary.DrawCircle (10, 10, 20)
    68.  
    69. Exit Sub
    70. ErrHand:
    71. MsgBox "There was an error whilst redrawing the screen.", vbCritical, "error"
    72. End Sub
    73.  
    74.  
    75. Private Sub picBox_Paint()
    76. DD.RestoreAllSurfaces
    77. init
    78. blt
    79. End Sub

    i tried this almost the same source code from directx4vb.com but this now draws the circle on screen instead of the picturebox any one know what i did wrong? :S

    ps , edited the code to be better viewed
    Last edited by Ultimasnake; Oct 25th, 2002 at 11:48 AM.
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  2. #2
    Lively Member FireSlash518's Avatar
    Join Date
    Nov 2001
    Posts
    67
    Primary.DrawCircle 1, 200, 100

    Leader of the Maxoverkill Mods
    -Fire§lash

  3. #3

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    err and this will help? that's accectly what i wrote and so it is wrong.. want to help me with a correct way then? (
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    post alle the files in your app...and I try to fix it...(I'm not that good, but I'll try)...

  5. #5

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    put that code above in a form.. and add a picture box named PICBOX the form.. thats all
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    One of the reasens why I told you to post the code, was so I could see what you used the line "pictrue", but if you don't I just supose that line is a mistake....

  7. #7

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    oops sorry yeah i forgot to take that away.. :S... have any idea what does it draw on the screen instead of in the in the picturebox? :S... (the wron line is gone now)
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

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