|
-
Oct 24th, 2002, 03:53 PM
#1
Thread Starter
Frenzied Member
Why does the circle apear on the screen instead of in the picturebox? :S
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
Last edited by Ultimasnake; Oct 25th, 2002 at 11:48 AM.
-
Oct 25th, 2002, 05:02 AM
#2
Lively Member
Primary.DrawCircle 1, 200, 100
-
Oct 25th, 2002, 08:57 AM
#3
Thread Starter
Frenzied Member
-
Oct 25th, 2002, 09:01 AM
#4
post alle the files in your app...and I try to fix it...(I'm not that good, but I'll try)...
-
Oct 25th, 2002, 10:24 AM
#5
Thread Starter
Frenzied Member
put that code above in a form.. and add a picture box named PICBOX the form.. thats all
-
Oct 25th, 2002, 11:45 AM
#6
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....
-
Oct 25th, 2002, 11:48 AM
#7
Thread Starter
Frenzied Member
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|