QB64 Phoenix Edition
Prevent Maximize - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Prevent Maximize (/showthread.php?tid=400)



Prevent Maximize - crumpets - 05-12-2022

Is there any way in QB64 that you can prevent a window from maximizing?


RE: Prevent Maximize - mpgcan - 05-12-2022

(05-12-2022, 10:23 AM)crumpets Wrote: Is there any way in QB64 that you can prevent a window from maximizing?

Try the following:

Code: (Select All)
Option _Explicit
'=============================
'a_disable_maximize_button.bas
'=============================

Declare Dynamic Library "User32"
    Function GetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long)
    Function SetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long, Byval dwNewLong As Long)
End Declare

Const GWL_STYLE = -16
Const WS_MAXIMIZEBOX = &H00010000 'maximize button
Const WS_MINIMIZEBOX = &H00020000 'minimize button


Dim hwnd, winstyle, a As Long

hwnd = _WindowHandle
winstyle = GetWindowLongA&(hwnd, GWL_STYLE) 'Get current style
a = SetWindowLongA&(hwnd, GWL_STYLE, winstyle And Not WS_MAXIMIZEBOX) '
a = SetWindowLongA&(hwnd, GWL_STYLE, winstyle And Not WS_MINIMIZEBOX) '


_Title "Disable maximize button"
Print "The end"



RE: Prevent Maximize - crumpets - 05-12-2022

Thank you. This is an excellent solution, but only works on Windows. I suppose doing it in macOS and Linux is not possible?


RE: Prevent Maximize - James D Jarvis - 05-12-2022

(05-12-2022, 10:23 AM)crumpets Wrote: Is there any way in QB64 that you can prevent a window from maximizing?


Code: (Select All)
_AllowFullScreen _Off 

This will do it.

or maybe this.
Code: (Select All)
$Resize:Off
_AllowFullScreen _Off