I have managed to get PB windows on top of Blitz3D DirectX screen. Thankyou for your replies and sorry I could not respond sooner. Here's a test which works well. It puts PB windows on top of the Blitz3D teapot example. I know the code isn't very tidy and there's a lot of unneeded code in this but it was only a test to see if this 'windows on blitz3d' feature is possible. I have done this test in view of a larger application I wish to develop that requires windows on a full-screen DirectX surface.
The great thing about this method is that you can open and close any windows in PB without needing to set the blitz3d window to the background every time or anything like that.
The disadvantage is that the windows toolbar appears whenever a PB window is clicked, and then disappears when the blitz3d window is clicked.
Does anyone know a way of preventing the toolbar from appearing??
Anyway, you should get the idea of what I'm trying to get working.
To start with you need a few declarations in Blitz3D. Put the following into a notepad file and save it as 'Blitz3D\userlibs\user32.decls'
Code: Select all
.lib "user32.dll"
User32_GetActiveWindow%():"GetActiveWindow"
User32_SetWindowLong% (hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA"
User32_GetSystemMetrics% (nIndex%) : "GetSystemMetrics"
User32_MoveWindow% (hwnd%, x%, y%, nWidth%, nHeight%, bRepaint%) : "MoveWindow"
User32_GetWindowRect% (hwnd%, lpRect*) : "GetWindowRect"
User32_GetClientRect% (hwnd%, lpRect*) : "GetClientRect"
User32_ClientToScreen% (hwnd%, lpwndpl*): "ClientToScreen"
User32_ScreenToClient% (hwnd%, lpwndpl*): "ScreenToClient"
User32_GetCursorPos%( lpwndpl* ):"GetCursorPos"
User32_LockSetForegroundWindow( x% ):"LockSetForegroundWindow"
User32_SetForegroundWindow( hwnd% ):"SetForegroundWindow"
User32_SetActiveWindow( hwnd% ):"SetActiveWindow"
Now here is the Pure Basic code:
Code: Select all
If ReadFile(1,"BlitzWndwHndl.txt")<>0
a.l=ReadLong()
OpenWindow(10,100,100,50,50,#PB_Window_SystemMenu |#PB_Window_TitleBar,"Not needed",a.l)
OpenWindow(11,125,125,50,50,#PB_Window_SystemMenu | #PB_Window_TitleBar,"Not needed",a.l)
CloseFile(1)
time.l=0
Repeat
EventID.l = WindowEvent()
If EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
CloseWindow(EventWindowID())
Quit = Quit + 1
EndIf
Delay(1)
Until Quit = 2
EndIf
End
and here is the Blitz3D code:
Code: Select all
Const LSFW_LOCK = 1
Const LSFW_UNLOCK = 2
; Set Window Long
Const GWL_STYLE =(-16)
Const GWL_EXSTYLE =(-20)
; Window Style
Const WS_VISIBLE =$10000000
Const WS_SYSMENU =$80000
Const WS_DISABLED =$8000000
Const WS_EX_TOPMOST =$00000008
Const WS_EX_NOACTIVATE =$08000000
Const WS_EX_TOOLWINDOW =$00000080
Const WS_EX_NOINHERITLAYOUT =$00100000
Type win
Field hWindow
Field WindowStyle
Field WindowExStyle
End Type
;
; This function initializes the actual blitz window
Function InitBlitzWindow()
Graphics3D 1280,1024,0,3
win\hWindow = User32_GetActiveWindow()
win\WindowStyle = WS_VISIBLE
win\WindowExStyle = WS_EX_NOACTIVATE
User32_SetWindowLong(win\hWindow,GWL_STYLE,win\WindowStyle)
User32_SetWindowLong(win\hWindow,GWL_EXSTYLE,win\WindowExStyle)
; Resize and center Blitz Window
User32_MoveWindow(win\hWindow,0,0,1280,1024,True)
If FileType("BlitzWndwHndl.txt")=1
DeleteFile("BlitzWndwHndl.txt")
EndIf
fileout=WriteFile("BlitzWndwHndl.txt")
WriteInt(fileout,win\hWindow)
CloseFile(fileout)
End Function
User32_LockSetForegroundWindow(LSFW_LOCK)
; Example
Global win.win = New win
InitBlitzWindow()
SetBuffer BackBuffer()
Global info1$="Teapot demo"
Global info2$="Features spherical reflection mapping"
ExecFile("PBWin.exe")
SetBuffer BackBuffer()
teapot=LoadMesh( "teapot.x" )
tex=LoadTexture( "spheremap.bmp",64+1 )
EntityTexture teapot,tex
EntityFX teapot,3
camera=CreateCamera()
PositionEntity camera,0,0,-3
While Not KeyHit(1)
TurnEntity teapot,.5,.7,1.1
UpdateWorld
RenderWorld
Flip
Delay(1000/85) ;85 should be the current monitor refresh rate
Wend
End
Compile both of these to the same directory and put the 'teapot.x' model there. Make sure to compile the PB code as 'PBWin.exe'.
Now run the Blitz code to see it working. Works on Blitz3D v1.85, PB3.80, XP Pro SP1, DirectX 9.