QB64 Phoenix Edition
Taskbar Dimensions - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Prolific Programmers (https://qb64phoenix.com/forum/forumdisplay.php?fid=26)
+---- Forum: SMcNeill (https://qb64phoenix.com/forum/forumdisplay.php?fid=29)
+---- Thread: Taskbar Dimensions (/showthread.php?tid=2355)

Pages: 1 2


RE: Taskbar Dimensions - SMcNeill - 12-29-2023

(12-28-2023, 11:55 PM)bplus Wrote: With the embedded stuff now, is it possible to create one sub that can set the exact screen width and height and move it so the title and task bar both show but you have the rest of the screen for your app?

I think I would use a sub like that allot for scaling the drawing, buttons and such so it fits anyones system.

Screen _NewImage(DW - TBW - BW * 2, DH - TBH - TH - BW * 2, 32)

^ That's what the code does there, with the math provided via the functions. Wink


RE: Taskbar Dimensions - bplus - 12-29-2023

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.


RE: Taskbar Dimensions - SMcNeill - 12-29-2023

It does that already.   .h files are only needed at compile time.  You don't have to include them with the EXE.


RE: Taskbar Dimensions - bplus - 12-29-2023

Yeah but I'd like to skip the step of having to have .h files clutter up the QB64pe folder and having to copy them into every update for QB64pe.exe


RE: Taskbar Dimensions - SMcNeill - 12-29-2023

I imagine that'd be rather hard to do though.  Even though .h files are text files, I'm not certain they have to be ASCII code.  You should be able to save them as UTF8, use unicode with them, and do other such things that our IDE just doesn't support.