Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Taskbar Dimensions
#1
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
Print "Hit the <SPACE BAR> and watch as we position it in different manners:"
Sleep
_ScreenMove 0, 0
Print
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
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
Print "To fix these issues, we use the functions here to figure out EXACTLY what size our screen needs to be."
Print
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
Print "This is a screen perfectly sized to fit on your screen."; _Width, _Height
Print "See how it fits your visible screen perfectly?"
Print
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
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
Print "To my way of thinking, THIS is the maximum resolution that your screen should run in with a program. Wink"
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
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


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


Messages In This Thread
Taskbar Dimensions - by SMcNeill - 12-26-2023, 03:46 PM
RE: Taskbar Dimensions - by bplus - 12-26-2023, 04:35 PM
RE: Taskbar Dimensions - by PhilOfPerth - 12-26-2023, 10:51 PM
RE: Taskbar Dimensions - by bplus - 12-27-2023, 12:05 AM
RE: Taskbar Dimensions - by SMcNeill - 12-27-2023, 12:20 AM
RE: Taskbar Dimensions - by PhilOfPerth - 12-27-2023, 11:15 PM
RE: Taskbar Dimensions - by TerryRitchie - 12-27-2023, 11:21 PM
RE: Taskbar Dimensions - by SMcNeill - 12-27-2023, 11:24 PM
RE: Taskbar Dimensions - by PhilOfPerth - 12-27-2023, 11:29 PM
RE: Taskbar Dimensions - by bplus - 12-28-2023, 11:55 PM
RE: Taskbar Dimensions - by SMcNeill - 12-29-2023, 12:47 AM
RE: Taskbar Dimensions - by bplus - 12-29-2023, 02:28 AM
RE: Taskbar Dimensions - by SMcNeill - 12-29-2023, 02:41 AM
RE: Taskbar Dimensions - by bplus - 12-29-2023, 02:59 AM
RE: Taskbar Dimensions - by SMcNeill - 12-29-2023, 06:31 AM



Users browsing this thread: 3 Guest(s)