Draw to foreign DirectX window

Jonny
02-01-2005, 06:13 AM
Is it possible for me to use DirectDraw to draw to a fullscreen directx window?

I can easily get the hWnd of the window and have tried a loop blting to the window using bitBlt but it is not fast enough and i get a flickering image. So i'm guessing that i should be using DirectDraw?

Any help would be great
Cheers
Jonny

noi_max
02-01-2005, 11:05 AM
That's a good question.. I think the issue you'll inevitably be facing is the other program's updates.

By the time you blit your stuff to the foreign window, it may refresh right after and the timing will be all off, so it would constantly tear and flicker.

That's more or less a guess at why it might not work.

Jonny
02-01-2005, 12:26 PM
What i want to be able to do is control my mp3s from counter strike.

some counter strike hacks show in-game menus... and i know for a fact that these hacks draw to the cs window. I just dont know how to go about doing it.

headkaze
02-02-2005, 06:50 AM
Just a guess, but this is how I would try this...

You should be able to use Spy++ to get all the appropriate DX attributes for creating your surfaces.

1. Get handle to CS window
2. Create a DX back surface that is the width and height to cover the text output
3. Write the text to the back surface...

Private Function clearSurfaceArea(ByRef lpdds As DirectDrawSurface7, ByRef rgb As Long, left As Long, top As Long, right As Long, bottom As Long)
Dim rc As RECT

rc.top = top
rc.left = left
rc.bottom = bottom
rc.right = right
lpdds.BltColorFill rc, rgb
End Function

clearSurfaceArea lpDDSOffGFX, 0, 0, 0, Width, Height
lpDDSOffGFX.SetFontTransparency True
lpDDSOffGFX.SetFont "Arial"
lpDDSOffGFX.SetForeColor rgb(128, 128, 128)
lpDDSOffGFX.DrawText 0, 0, "Now Playing: Kings of Leon", False

4. Bit blit the back surface to the primary surface (CS DX screen). Try lpDDSOffGFX.Blt and lpDDSOffGFX.BltFast.

Jonny
02-02-2005, 08:12 AM
i have the following code now....

Private Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long

Dim dx As New DirectX7
Dim dd As DirectDraw7
Dim lpDDSOffGFX As DirectDrawSurface7
Dim lpDDSOffGFX2 As DirectDrawSurface7
Dim lpDDSD As DDSURFACEDESC2
Dim wDC As Long


Private Function clearSurfaceArea(ByRef lpdds As DirectDrawSurface7, ByRef rgb As Long, left As Long, top As Long, right As Long, bottom As Long)
Dim rc As RECT
rc.top = top
rc.left = left
rc.bottom = bottom
rc.right = right
lpdds.BltColorFill rc, rgb
End Function

Private Sub Command1_Click()
Set dd = dx.DirectDrawCreate("")
'Link DD to CS window.
dd.SetCooperativeLevel 328142, DDSCL_FULLSCREEN Or DDSCL_ALLOWMODEX Or DDSCL_EXCLUSIVE
lpDDSD.lHeight = 50
lpDDSD.lWidth = 200
lpDDSD.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
lpDDSD.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
Set lpDDSOffGFX = dd.CreateSurface(lpDDSD)
Set lpDDSOffGFX2 = dd.GetSurfaceFromDC(wDC)
clearSurfaceArea lpDDSOffGFX, 0, 0, 0, 200, 50
lpDDSOffGFX.SetFontTransparency True
'lpDDSOffGFX.SetFont "Arial"
lpDDSOffGFX.SetForeColor rgb(128, 128, 128)
lpDDSOffGFX.DrawText 0, 0, "Now Playing: Kings of Leon", False
Dim rc As RECT
rc.right = 200
rc.bottom = 50
lpDDSOffGFX2.Blt rc, lpDDSOffGFX, rc, DDBLT_DONOTWAIT
End Sub

Private Sub Form_Load()
wDC = GetDC(328142)
End Sub

i get Automation Error on the line...
Set lpDDSOffGFX = dd.CreateSurface(lpDDSD)
there are probably other errors but i don't really know what i'm doing when it comes to DX.

Cheers for the help :D
Jonny

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum