Yeah I thought it'd be cool if we could embed the taskbar.h file into the sub that uses it so wouldn't have to worry about extra files.
I managed to condense code a bit for a one sub routine to get the screen up and set the width and height of work area available:
Code: (Select All)
_Title "Set Xmax YMax And Move test" ' b+ 2023-12-28
'based on SMcNeill code ref:
' https://qb64phoenix.com/forum/showthread.php?tid=2355&pid=22263#pid22263
Dim Shared As Long Xmax, Ymax ' for screen width and height
SetXYMaxAndMove
Print Xmax, Ymax
Line (20, 20)-Step(Xmax - 40, Ymax - 40), , B ' <<< visual check on numbers
Sleep
Sub SetXYMaxAndMove
'''' If you don't have taskbar.h in your QB64pe.exe folder
'''' copy the following, remove single comments in code below,
'''' paste into an editor, and save the file as:
'''' taskbar.h in your QB64PE.exe folder.
'int32 taskbar_height() {
' RECT rect;
' HWND taskBar = FindWindow("Shell_traywnd", NULL);
' if(taskBar && GetWindowRect(taskBar, &rect)) {
' return rect.bottom - rect.top;
' }
'}
'int32 taskbar_width() {
' RECT rect;
' HWND taskBar = FindWindow("Shell_traywnd", NULL);
' if (taskBar && GetWindowRect(taskBar, &rect)) {
' return rect.right - rect.left;
' }
'}
'int32 taskbar_top() {
' RECT rect;
' HWND taskBar = FindWindow("Shell_traywnd", NULL);
' if (taskBar && GetWindowRect(taskBar, &rect)) {
' return rect.top;
' }
'}
'int32 taskbar_left() {
' RECT rect;
' HWND taskBar = FindWindow("Shell_traywnd", NULL);
' if (taskBar && GetWindowRect(taskBar, &rect)) {
' return rect.left;
' }
'}
'int32 taskbar_bottom() {
' RECT rect;
' HWND taskBar = FindWindow("Shell_traywnd", NULL);
' if (taskBar && GetWindowRect(taskBar, &rect)) {
' return rect.bottom;
' }
'}
'int32 taskbar_right() {
' RECT rect;
' HWND taskBar = FindWindow("Shell_traywnd", NULL);
' if (taskBar && GetWindowRect(taskBar, &rect)) {
' return rect.right;
' }
'}
DH = _DesktopHeight: DW = _DesktopWidth
$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
TBW = taskbar_width&
TBH = taskbar_height&
$Else
Flag$ = "Sorry, this is a Windows Only application."
$End If
$If BORDERDEC = UNDEFINED Then
$Let BORDERDEC = TRUE
Declare Library
Function glutGet& (ByVal what&)
End Declare
$End If
If Flag$ <> "" Then Print Flag$: End
TH = glutGet(507)
BW = glutGet(506)
If TBH = DH Then TBH = 0 'Users taskbar is configured vertical, not hortizonal.
If TBW = DW Then TBW = 0
Xmax = DW - TBW - BW * 2
Ymax = DH - TBH - TH - BW * 2
Screen _NewImage(Xmax, Ymax, 32)
If taskbar_bottom = TBH Then ScreenY = TBH Else ScreenY = 0
If taskbar_right = TBW Then ScreenX = TBW Else ScreenX = 0
_ScreenMove ScreenX, ScreenY
End Sub
I tested it on 2 Windows machines and moved taskbar around on each. It worked very well for me.
I am going to test it on Christmas Star 2023 next...
This is going to be very handy because my Dell is tiny screen compared to regular laptop ie Christmas Star won't fit as is.
b = b + ...