Turning off gadget borders

BlitzMax Forums/BlitzMax GUI Programming/Turning off gadget borders

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This is pretty easy on Windows, dunno about the other platforms though.

GadgetBorder.bmx
SuperStrict

Import PUB.Win32
Import MaxGUI.Drivers
'Import BRL.MaxGUI


Private
?Win32
Const RDW_ERASE:Int = 4
Const RDW_FRAME:Int = 1024
Const RDW_INTERNALPAINT:Int = 2
Const RDW_INVALIDATE:Int = 1
Const RDW_NOERASE:Int = 32
Const RDW_NOFRAME:Int = 2048
Const RDW_NOINTERNALPAINT:Int = 16
Const RDW_VALIDATE:Int = 8
Const RDW_ERASENOW:Int = 512
Const RDW_UPDATENOW:Int = 256
Const RDW_ALLCHILDREN:Int = 128
Const RDW_NOCHILDREN:Int = 64

Extern "Win32"
	Function RedrawWindow:Int( hwnd:Int, rect:Byte Ptr, region:Int, flags:Int)
EndExtern
?
Public


Const BORDER_NONE:Int = 0
Const BORDER_3D:Int = 1
Const BORDER_THIN:Int = 2

Function SetGadgetBorder( gadget:TGadget, bordertype:Int)
	?MacOS
	DebugLog "SetGadgetBorder() doesnt support MacOS"
	?Linux
	DebugLog "SetGadgetBorder() doesnt support Linux"
	?
	?Win32
	Local hwnd:Int = gadget.Query( QUERY_HWND)
	Local style:Int = GetWindowLongW( hwnd, GWL_STYLE)
	Local exstyle:Int = GetWindowLongW( hwnd, GWL_EXSTYLE)	
	Select bordertype
		Case BORDER_NONE
			' remove both border types
			If style & WS_BORDER Then SetWindowLongW( hwnd, GWL_STYLE, style & ~WS_BORDER)
			If exstyle & WS_EX_CLIENTEDGE Then SetWindowLongW( hwnd, GWL_EXSTYLE, exstyle & ~WS_EX_CLIENTEDGE)
		Case BORDER_THIN
			' add thin border & remove 3d border
			If Not (style & WS_BORDER) Then SetWindowLongW( hwnd, GWL_STYLE, style | WS_BORDER)
			If exstyle & WS_EX_CLIENTEDGE Then SetWindowLongW( hwnd, GWL_EXSTYLE, exstyle & ~WS_EX_CLIENTEDGE)		
		Case BORDER_3D
			' remove thin border & add 3d border
			If style & WS_BORDER Then SetWindowLongW( hwnd, GWL_STYLE, style & ~WS_BORDER)
			If Not (exstyle & WS_EX_CLIENTEDGE) Then SetWindowLongW( hwnd, GWL_EXSTYLE, exstyle | WS_EX_CLIENTEDGE)			
	EndSelect
	' update window frame
	SetWindowPos( hwnd,0, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED)
	RedrawWindow( hwnd, Null,0, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME)
	?
EndFunction