12-26-2023, 03:46 PM
Quote:Code: (Select All)DH = _DesktopHeight: DW = _DesktopWidth
TBH = TaskbarHeight: TBW = TaskbarWidth
TH = TitleBarHeight: BW = BorderWidth
If TBH = DH Then TBH = 0 'Users taskbar is configured vertical, not hortizonal.
If TBW = DW Then TBW = 0
Screen _NewImage(DW, DH, 32)
Print "This screen is the size of your desktop, but it has some inherent issues."; _Width, _Height
Print "Hit the <SPACE BAR> and watch as we position it in different manners:"
Sleep
_ScreenMove 0, 0
Print "To start with, this is a _SCREENMOVE 0,0 call. It places the TITLEBAR's top left corner at position 0,0."
Print "If you notice, the bottom of the screen is now hidden as the titlebar has shifted us down below the max resolution our screen will display."
Sleep
ScreenMove 0, 0
Print "Now, this is a Steve Approved(tm) ScreenMove method to move the screen itself to position 0,0."
Print "Now, as you can tell (if your taskbar is set to hide itself), the program window now covers the screen perfectly."
Print "The only problem with this method is that we are now hiding the title bar over the top of the screen!"
Sleep
Screen _NewImage(DW - TBW, DH - TBH, 32)
If taskbar_bottom = TBH Then ScreenY = TBH Else ScreenY = 0
If taskbar_right = TBW Then ScreenX = TBW Else ScreenX = 0
ScreenMove ScreenX, ScreenY
Print "To fix these issues, we use the functions here to figure out EXACTLY what size our screen needs to be."
Print "Title Bar Height = "; TH
Print "Screen Border ="; BW; "on each side."
Print "Task Bar Height ="; TBH
Print "Task Bar Width ="; TBW
Print "Task Bar Top = "; taskbar_top
Print "Task Bar Left = "; taskbar_left
Print "Task Bar Bottom = "; taskbar_bottom
Print "Task Bar Right = "; taskbar_right
Print "This is a screen perfectly sized to fit on your screen."; _Width, _Height
Print "See how it fits your visible screen perfectly?"
Print "Note: If you have transparent borders, or if your theme has them set to opaque, it may appear to be a gap around your screen. That transparent gap IS the screen border. Set it a solid color and you can see it."
Print "At this point, you should have your title bar up top. You screen shouldn't cover, or be covered, by the task bar."
Print "Everything should be visible and accessable for you."
Print "To my way of thinking, THIS is the maximum resolution that your screen should run in with a program. "
Sleep
Screen _NewImage(DW - TBW - BW * 2, DH - TBH - TH - BW * 2, 32)
If taskbar_bottom = TBH Then ScreenY = TBH Else ScreenY = 0
If taskbar_right = TBW Then ScreenX = TBW Else ScreenX = 0
_ScreenMove ScreenX, ScreenY
Print "Or THIS height, if one wants to include the titlebar and boarder and use the whole screen, without covering the taskbar.)"
Print "This is a screen perfectly sized to fit on your screen. (with Titlebar and Borders)"; _Width, _Height
Print "See how it fits your visible screen perfectly?"
Sub ScreenMove (x, y)
Do Until _Width <> 0 And _ScreenExists <> 0: Loop
_ScreenMove x - BorderWidth, y - BorderWidth - TitleBarHeight
End Sub
Sub ScreenMove_Middle
Do Until _Width <> 0 And _ScreenExists <> 0: Loop
_ScreenMove (_DesktopWidth - _Width - BorderWidth) / 2 + 1, (_DesktopHeight - _Height - BorderWidth) / 2 - TitleBarHeight + 1
End Sub
Function TaskbarHeight
$If WIN Then
Do Until _Width <> 0 And _ScreenExists <> 0: Loop
$If TASKBARDEC = UNDEFINED Then
$Let TASKBARDEC = TRUE
Declare Library "taskbar"
Function taskbar_height& ()
Function taskbar_width& ()
Function taskbar_top& ()
Function taskbar_left& ()
Function taskbar_bottom& ()
Function taskbar_right& ()
End Declare
$End If
TaskbarHeight = taskbar_height&
$Else
TaskbarHeight = 0 'no function to get the value for Linux/Mac, so return 0 instead of an error
$End If
End Function
Function TaskbarWidth
$If WIN Then
Do Until _Width <> 0 And _ScreenExists <> 0: Loop
$If TASKBARDEC = UNDEFINED Then
$Let TASKBARDEC = TRUE
Declare Library "taskbar"
Function taskbar_height& ()
Function taskbar_width& ()
Function taskbar_top& ()
Function taskbar_left& ()
Function taskbar_bottom& ()
Function taskbar_right& ()
End Declare
$End If
TaskbarWidth = taskbar_width&
$Else
TaskbarWidth = 0 'no function to get the value for Linux/Mac, so return 0 instead of an error
$End If
End Function
Function TitleBarHeight
Do Until _Width <> 0 And _ScreenExists <> 0: Loop
$If BORDERDEC = UNDEFINED Then
$Let BORDERDEC = TRUE
Declare Library
Function glutGet& (ByVal what&)
End Declare
$End If
TitleBarHeight = glutGet(507)
End Function
Function BorderWidth
Do Until _Width <> 0 And _ScreenExists <> 0: Loop
$If BORDERDEC = UNDEFINED Then
$Let BORDERDEC = TRUE
Declare Library
Function glutGet& (ByVal what&)
End Declare
$End If
BorderWidth = glutGet(506)
End Function
taskbar.h (Size: 1.11 KB / Downloads: 58) <-- Required C-header file which needs to go in your QB64 folder for this to work properly.