Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Taskbar Dimensions
#12
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 + ...
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: 5 Guest(s)