pure basic windows running on top of blitz3d

Windows specific forum
raziel
New User
New User
Posts: 2
Joined: Tue Nov 25, 2003 8:21 am

pure basic windows running on top of blitz3d

Post by raziel »

I have been trying for the last few days to get a system of windows running correctly in PB and Blitz3D.

What I am doing is launching a Blitz3D program which opens a full screen window (no titlebar or toolbar visible) with 3D graphics on it. Then this launches a PB program which opens a small window on top of the Blitz3D window. However, when I close the PB window the toolbar becomes visible over the top of my Blitz3D window. Also if I launch the Blitz3D program from a desktop window, when I close the PB window the desktop window becomes visible over the top of the Blitz3D window.

What I want to have happen is that Blitz windows always stay on top of any desktop windows and PB windows always stay on top of Blitz windows.

Does anyone know how I might stop my desktop windows/toolbar from interfering with the PB\Blitz setup.

I have tried a few methods, like hidden windows and removing the toolbar entry for PB windows, but none seem to work.

Any info would be much appreciated.
Hi-Toro
Enthusiast
Enthusiast
Posts: 270
Joined: Sat Apr 26, 2003 3:23 pm

Post by Hi-Toro »

You're not supposed to be able to display windows on top of a full-screen DirectX display as far as I know, but perhaps forcing your window to the front takes away the Blitz window's topmost flags...? Maybe if you re-set it as a topmost window on closing your PB window, it will work correctly? Might have to mess with SetForegroundWindow_, SetActiveWindow_, SetWindowLong_, etc, to get the right result, as I never quite figured out which command does what...
James Boyd
http://www.hi-toro.com/
Death to the Pixies!
CNESM
User
User
Posts: 54
Joined: Sat Jun 21, 2003 11:15 pm
Contact:

Post by CNESM »

Hi,

take a look on:

http://www.purearea.net/pb/english/userlibs.php

There are a lib calls "AppBar":
Library for easy creating of your own start bar, similar to the one of MS Office.
I dont tested it, but it seems like a easy way to hold your window on top :)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

I know with directx9, you can show all window controls on your directx surface, but i do not know about windows :(
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post by Codemonger »

You are right DirectX9 allows for Dialog Box in full screen mode, but unfortunately Blitz is DX 7 :cry:
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Shannara wrote:I know with directx9, you can show all window controls on your directx surface, but i do not know about windows :(
That's because windows longhorn will only use DX9 has an API... So it will be backcompatible with the hold API...
raziel
New User
New User
Posts: 2
Joined: Tue Nov 25, 2003 8:21 am

Post by raziel »

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.
Post Reply