VB Code:
Option Explicit Dim DX As New DirectX7 Dim DD As DirectDraw7 Dim Primary As DirectDrawSurface7 Dim ddsd1 As DDSURFACEDESC2 Dim ddsd2 As DDSURFACEDESC2 Dim ddClipper As DirectDrawClipper Dim bInit As Boolean Sub Form_Load() init End Sub Sub init() On Error GoTo ErrHandler Set DD = DX.DirectDrawCreate("") Call DD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL) ddsd1.lFlags = DDSD_CAPS ddsd1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Set Primary = DD.CreateSurface(ddsd1) ddsd2.lFlags = DDSD_CAPS ddsd2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Set ddClipper = DD.CreateClipper(0) ddClipper.SetHWnd picbox.hWnd Primary.SetClipper ddClipper bInit = True blt Exit Sub ErrHandler: MsgBox "Unable to initialize DirectDraw - Closing program", vbInformation, "error" End End Sub Private Sub Form_Resize() picbox.Width = Me.ScaleWidth picbox.Height = Me.ScaleHeight blt End Sub Sub blt() On Error GoTo ErrHand: If bInit = False Then Exit Sub Dim ddrval As Long Dim r1 As RECT 'The screen size Dim r2 As RECT 'The bitmap size Call DX.GetWindowRect(picbox.hWnd, r1) r2.Bottom = ddsd2.lHeight r2.Right = ddsd2.lWidth Primary.DrawCircle 1, 200, 100 'also tried 'ddrval = Primary.DrawCircle (10, 10, 20) Exit Sub ErrHand: MsgBox "There was an error whilst redrawing the screen.", vbCritical, "error" End Sub Private Sub picBox_Paint() DD.RestoreAllSurfaces init blt 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![]()




Reply With Quote