Just starting out? Need help? Post your questions and find answers here.
Axolotl
Addict
Posts: 804 Joined: Wed Dec 31, 2008 3:36 pm
Post
by Axolotl » Tue Nov 05, 2024 4:55 pm
you can do it this way....
Code: Select all
Procedure DisableWindowSizing(hWnd, State)
Protected currStyle
currStyle = GetWindowLongPtr_(hwnd, #GWL_STYLE)
If State
Style = currStyle & ~#WS_SIZEBOX ; <-- remove style flag #WS_SIZEBOX
Else
Style = currStyle | #WS_SIZEBOX ; <-- add style flag #WS_SIZEBOX
EndIf
SetWindowLongPtr_(hWnd, #GWL_STYLE, Style)
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOZORDER | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
EndProcedure
OpenConsole()
;ConsoleTitle("Console fixed size")
stdout = GetStdHandle_(#STD_OUTPUT_HANDLE)
OpenLibrary(0, "kernel32.dll")
hWin = CallFunction(0, "GetConsoleWindow")
CloseLibrary(0)
; ;...Remove the Size option from the menu
; system_menu = GetSystemMenu_(hWin, #False)
; DeleteMenu_(system_menu, 2, #MF_BYPOSITION)
; DrawMenuBar_(hWin)
ConsoleTitle("Console fixed size")
DisableWindowSizing(hWin, #True)
With windowSize.SMALL_RECT
\left = 0
\top = 0
\right = 79
\bottom = 24
EndWith
SetConsoleWindowInfo_(stdout, #True, @windowSize)
With bufferSize.COORD
\x = 80
\y = 25
EndWith
SetConsoleScreenBufferSize_(stdout, PeekL(bufferSize))
Repeat
in$ = Input()
If in$ = "on"
ConsoleTitle("Console changeable size")
DisableWindowSizing(hWin, #False)
ElseIf in$ = "off"
ConsoleTitle("Console fixed size")
DisableWindowSizing(hWin, #True)
ElseIf in$ = "exit"
Break
EndIf
Until in$ = ""
CloseConsole()
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home . Now started with Linux (VM: Ubuntu 22.04 ).
Armoured
Enthusiast
Posts: 365 Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:
Post
by Armoured » Wed Nov 06, 2024 1:57 am
Axolotl wrote: Tue Nov 05, 2024 4:55 pm
you can do it this way....
Code: Select all
Procedure DisableWindowSizing(hWnd, State)
Protected currStyle
currStyle = GetWindowLongPtr_(hwnd, #GWL_STYLE)
If State
Style = currStyle & ~#WS_SIZEBOX ; <-- remove style flag #WS_SIZEBOX
Else
Style = currStyle | #WS_SIZEBOX ; <-- add style flag #WS_SIZEBOX
EndIf
SetWindowLongPtr_(hWnd, #GWL_STYLE, Style)
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOZORDER | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
EndProcedure
OpenConsole()
;ConsoleTitle("Console fixed size")
stdout = GetStdHandle_(#STD_OUTPUT_HANDLE)
OpenLibrary(0, "kernel32.dll")
hWin = CallFunction(0, "GetConsoleWindow")
CloseLibrary(0)
; ;...Remove the Size option from the menu
; system_menu = GetSystemMenu_(hWin, #False)
; DeleteMenu_(system_menu, 2, #MF_BYPOSITION)
; DrawMenuBar_(hWin)
ConsoleTitle("Console fixed size")
DisableWindowSizing(hWin, #True)
With windowSize.SMALL_RECT
\left = 0
\top = 0
\right = 79
\bottom = 24
EndWith
SetConsoleWindowInfo_(stdout, #True, @windowSize)
With bufferSize.COORD
\x = 80
\y = 25
EndWith
SetConsoleScreenBufferSize_(stdout, PeekL(bufferSize))
Repeat
in$ = Input()
If in$ = "on"
ConsoleTitle("Console changeable size")
DisableWindowSizing(hWin, #False)
ElseIf in$ = "off"
ConsoleTitle("Console fixed size")
DisableWindowSizing(hWin, #True)
ElseIf in$ = "exit"
Break
EndIf
Until in$ = ""
CloseConsole()
Thanks Axolotl!