May 24, 2019, 11:18:10 PM

Author Topic: possible to hide the window text bar in Blitzmax ?  (Read 415 times)

Offline fielder

  • Jr. Member
  • **
  • Posts: 68
Re: possible to hide the window text bar in Blitzmax ?
« Reply #15 on: May 06, 2019, 07:46:52 AM »
Hello

In a BLITZMAX game, Windowed mode (so not full screen), is there a possibility to hide the textbar at the top ? (to simulate a fullscreen mode)

(I ask this question because I have difficulties with FLIP in fullscreen, and no problem in Window mode)

Thank you (and sorry again for my english very poor)
if you don't want to rewrite the code.. replace the FLIP calls with a function that manage the real FLIP using millisecs(); or something like that...
something that prevent a lot of multiply flips .. or maybe that redraw the entire background of app to make the flip "fluid"

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 34
Re: possible to hide the window text bar in Blitzmax ?
« Reply #16 on: May 06, 2019, 05:08:54 PM »
interesting... but i am a casual coder and cannot do that myself ;)

Yes, indeed, I need a function who replace FLIP... a "refresh" function... something which do not swap images but redraw the new image in the buffer.

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 381
Re: possible to hide the window text bar in Blitzmax ?
« Reply #17 on: May 06, 2019, 05:55:34 PM »
If it's in Blitz3d you could use this - Windowed full screen graphics mode (by Zethrax)

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 34
Re: possible to hide the window text bar in Blitzmax ?
« Reply #18 on: May 06, 2019, 09:25:29 PM »
great  !

but BLITZ website is down... and this library no more available.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1828
Re: possible to hide the window text bar in Blitzmax ?
« Reply #19 on: May 06, 2019, 09:37:12 PM »
great  !

but BLITZ website is down... and this library no more available.

Recommended decls and extras :

http://www.mojolabs.nz/codearcs.php?code=1179 - user32.decls
http://www.mojolabs.nz/codearcs.php?code=1180 - kernel32.decls
http://www.mojolabs.nz/codearcs.php?code=1181 - gdi32.decls
http://www.mojolabs.nz/codearcs.php?code=1607 - Win32 Constants
Until the next time...

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 381
Re: possible to hide the window text bar in Blitzmax ?
« Reply #20 on: May 06, 2019, 10:44:53 PM »
Yes no need for a library file here, and you only need user32 declarations.
 
There's also - window (windowed mode) without titlebar and with force redraw (by RemiD).

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 216
  • Whoop-de-doo-ba-dooo!
Re: possible to hide the window text bar in Blitzmax ?
« Reply #21 on: May 07, 2019, 12:17:45 PM »
Hi.

It looks like your application is undergoing a 'triple buffer' effect, which has happened before when my friend started out.    Please use a delta-timer to limit your framerate and make sure FLIP is called at the END of your loop.

Also, in Graphics(), use the GRAPHICS_BACKBUFFER flag...........

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 34
Re: possible to hide the window text bar in Blitzmax ?
« Reply #22 on: May 07, 2019, 05:09:23 PM »
Yes no need for a library file here, and you only need user32 declarations.
 
There's also - window (windowed mode) without titlebar and with force redraw (by RemiD).

Thanks, but i am lost

 i found the file user32.dll to download... i put it in my folder BIN (is that correct ?)

And then ? What should I add to my code ? :)

In fact, i don't at all how to use libs LOL...

If some one can explain me ? My goal : use USER32.DLL in order to hide the windows bar  + simulate a full screen for a 2D game in Blitz 3D

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 381
Re: possible to hide the window text bar in Blitzmax ?
« Reply #23 on: May 08, 2019, 05:26:45 AM »
Okay well, user32.dll is a MS Windows dll and is already installed in system32, as is kernel32.dll and gdi32.dll all you really "have" to do is create a text file with the extension .decls in "Blitz3d/userlibs" folder and copy/paste in the functions you intend to use, Blitz3d will then have access to those functions exactly as they are named, after you reload the IDE.

The easiest thing to do is just save the .bb files from the links Qube posted and rename them to .decls. The Win32 consts should be included as a .bb file. Then to keep it simple, just take the init code from Zethrax's example and paste it where your Graphics3d command is, which you should comment out, the windows dll functions start with "api_".

Code: [Select]
Function GetDesktopSize()
; Gets the width and height of the desktop on the main monitor and returns them in
; the globals G_desktop_screen_width and G_desktop_screen_height.

Local rectangle = CreateBank( 16 )
api_GetClientRect( api_GetDesktopWindow(), rectangle )
G_desktop_screen_width = PeekInt( rectangle, 8 ) - PeekInt( rectangle, 0 )
G_desktop_screen_height = PeekInt( rectangle, 12 ) - PeekInt( rectangle, 4 )
FreeBank rectangle
End Function

; -- Declare Windows API constants.
Const C_GWL_STYLE = -16
Const C_WS_POPUP = $80000000
Const C_HWND_TOP = 0
Const C_SWP_SHOWWINDOW = $0040

; -- Get the width and height of the desktop and place them into these globals.
Global G_desktop_screen_width
Global G_desktop_screen_height
GetDesktopSize()

Global G_viewport_x = 0
Global G_viewport_y = 0
Global G_viewport_width = G_desktop_screen_width
Global G_viewport_height = G_desktop_screen_height

; -- Get the OS handle of the app window.
Global G_app_handle = SystemProperty( "AppHWND" )

If Not Windowed3D() Then RuntimeError "FATAL ERROR: Your computer does not support the rendering of 3D graphics within a window."

Graphics3D G_viewport_width, G_viewport_height, 0, 2

; -- Change the window style to 'WS_POPUP' and then set the window position to force the style to update.
api_SetWindowLong( G_app_handle, C_GWL_STYLE, C_WS_POPUP )
api_SetWindowPos( G_app_handle, C_HWND_TOP, G_viewport_x, G_viewport_y, G_viewport_width, G_viewport_height, C_SWP_SHOWWINDOW )

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 34
Re: possible to hide the window text bar in Blitzmax ?
« Reply #24 on: May 08, 2019, 09:54:28 AM »
Great ! Thank you ! It's working, no window bar and "virtual" fullscreen ! And the best : FLIP ploblems as diseapear !!!!!

But there is still a little problem :

My game is 320x240 pixels... So I changed the parameters :

Global G_viewport_width = 320 ;G_desktop_screen_width
Global G_viewport_height = 240; G_desktop_screen_height

But the game appear in a very little part of the screen at the top left....

Is it possible to zoom full screen ?

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 381
Re: possible to hide the window text bar in Blitzmax ?
« Reply #25 on: May 10, 2019, 04:09:37 AM »
Hmm well, Blitzmax has virtual resolution commands which would make this easy, but Blitz3d doesn't but it should still be possible by copying the screen to an image or sprite texture and scale it up, requiring an extra Flip.

See Sledge's example - http://www.mojolabs.nz/posts.php?topic=62357.

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 34
Re: possible to hide the window text bar in Blitzmax ?
« Reply #26 on: May 11, 2019, 11:23:29 PM »
I successfull !!! 320x240 pixels in windowed full screen !!!

And the bonus : FLIP function now works as a real refresh of the screen !!! (you can use several FLIP in a same loop without any problem !)


Code: [Select]
' windowed
Graphics 320,240,0,60

' full screen borderless *******************************************************************
Type MONITORINFO
 
        Field cbSize:Int
 
        Field rcMonitorLeft:Int
        Field rcMonitorTop:Int
        Field rcMonitorRight:Int
        Field rcMonitorBottom:Int
 
        Field rcWorkLeft:Int
        Field rcWorkTop:Int
        Field rcWorkRight:Int
        Field rcWorkBottom:Int
 
        Field dwFlags:Int
 
End Type
 
' Win32 constants...
 
Const MONITOR_DEFAULTTONEAREST:Int      = 2
 
Const GWL_STYLE:Int                                     = -16
Const GWL_EXSTYLE:Int                           = -20
 
Const HWND_TOP:Int                                      = 0
Const SWP_FRAMECHANGED:Int                      = $20
 
Const WS_POPUP:Int                                      = $80000000
Const WS_VISIBLE:Int                            = $10000000
Const WS_CAPTION:Int                            = $C00000
Const WS_THICKFRAME:Int                         = $00040000
Const WS_MINIMIZE:Int                           = $20000000
Const WS_MAXIMIZE:Int                           = $01000000
Const WS_SYSMENU:Int                            = $80000
 
Const WS_EX_DLGMODALFRAME:Int           = $00000001
Const WS_EX_CLIENTEDGE:Int                      = $200
Const WS_EX_STATICEDGE:Int                      = $20000
 
' Win32 function pointers...
 
Global FindWindow (lpClassName:Byte Ptr, lpWindowName:Byte Ptr) "win32"
Global MonitorFromWindow (hwnd:Int, dwFlags:Int)                                "win32"
Global GetMonitorInfo (hMonitor:Int, lpmi:Byte Ptr)                             "win32"
Global GetWindowLong (hwnd:Int, nIndex:Int)                                             "win32"
Global SetWindowLong (hwnd:Int, nIndex:Int, dwNewLong:Int)              "win32"
Global SetWindowPos (hWnd:Int, hWndInsertAfter:Int, X:Int, Y:Int, cx:Int, cy:Int, uFlags:Int)
 
' Set up function pointers...
 
Local user32:Int = LoadLibraryA ("user32.dll")
 
If user32
 
        FindWindow                      = GetProcAddress (user32, "FindWindowA")
        MonitorFromWindow       = GetProcAddress (user32, "MonitorFromWindow")
        GetMonitorInfo          = GetProcAddress (user32, "GetMonitorInfoA")
        GetWindowLong           = GetProcAddress (user32, "GetWindowLongA")
        SetWindowLong           = GetProcAddress (user32, "SetWindowLongA")
        SetWindowPos            = GetProcAddress (user32, "SetWindowPos")
       
        If Not (FindWindow And MonitorFromWindow And GetMonitorInfo And GetWindowLong And SetWindowLong And SetWindowPos)
                Print "Missing function!"
                End
        EndIf
       
EndIf
 
' AppTitle allocated as C-string...
 
Local cbytes:Byte Ptr = AppTitle.ToCString ()
 
' Find app window...
 
Local appwindow:Int = FindWindow (Null, cbytes)
 
' Free C-string memory...
 
MemFree cbytes
 
' Find which monitor the app window is on...
 
Local monitor:Int = MonitorFromWindow (appwindow, MONITOR_DEFAULTTONEAREST)
 
' Monitor info...
 
Local mi:MONITORINFO = New MONITORINFO
mi.cbSize = SizeOf (MONITORINFO)
 
GetMonitorInfo monitor, mi
 
' Read window style/extended style...
 
Local style:Int         = GetWindowLong (appwindow, GWL_STYLE)
Local exstyle:Int       = GetWindowLong (appwindow, GWL_EXSTYLE)
 
' Prepare to remove unwanted styles...
 
style   = style And Not (WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU)
exstyle = exstyle And Not (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)
 
' Remove unwanted styles...
 
SetWindowLong (appwindow, GWL_STYLE, style | WS_POPUP | WS_VISIBLE | SWP_FRAMECHANGED)
SetWindowLong (appwindow, GWL_EXSTYLE, exstyle)
 
' Update window...
 
SetWindowPos appwindow, HWND_TOP, mi.rcMonitorLeft, mi.rcMonitorTop, mi.rcMonitorRight - mi.rcMonitorLeft, mi.rcMonitorBottom - mi.rcMonitorTop, 0


in fact the solution was here :
https://www.syntaxbomb.com/index.php?topic=286.0

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 381
Re: possible to hide the window text bar in Blitzmax ?
« Reply #27 on: May 12, 2019, 03:16:27 AM »
Great, nice one drfloyd. I assume it expands to whatever the screen size is, and is anti-aliased.

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 34
Re: possible to hide the window text bar in Blitzmax ?
« Reply #28 on: May 12, 2019, 08:28:45 AM »
yes,

whatever the screen size, no resolution swap ! (you just indicate the res of your game : Graphics 320,240,0,60 if 320x240)
anti aliased
and no FLIP problem

I don't know if it is as fast as a real fullscreen ? I suppose yes ? If someone can try with one of his Blitzmax game ? I have tried with some BLITZMAX samples, it seems to be perfect !

(and I don't know if someone can adapt this code to BLITZ 3D ?)