Notifications
Clear all

[Closed] Resizable Rollout with no borders

I have a rollout dialog (not max form), it should be with no borders and usually not resizable. But there is an option that should allow to rescale the dialog, but to keep the minimum size of the rollout (not less then 200×300 px)

try(destroydialog dialog) catch()
rollout dialog "Toggle Scale" width:200 height:300
(
	checkbutton show_bt "Unlock Resizing" width:85 across:2
	button CloseBtn "Close" width:85-- height:22 
	on CloseBtn pressed do
	(
		try(destroydialog dialog) catch()
	)	
	on show_bt changed state do 
	(	
		--Allow Rollout Scale
		dialog.width = 200
		dialog.height = 300
	)	
)
createdialog dialog style:#(#style_resizing)

If I use style:#() is the look I need, but #style_resizing is adding a border. Please help me.

16 Replies
try (destroydialog boardless) catch()
rollout boardless "boardless dialog" width:300 height:300
(
	local SWP_NOMOVE = 2
	
	local last_size = undefined
	
	spinner width_sp "Width: " type:#integer range:[138,1000,300] fieldwidth:56 align:#right offset:[4,0]
	spinner height_sp "Height: " type:#integer range:[100,1000,300] fieldwidth:56 align:#right offset:[4,0]
	
	checkbutton autoresize_bt "Auto Resize" width:120 align:#right offset:[4,0]
	button close_bt "Close" width:120 align:#right offset:[4,0]
	
	local r_controls = #(width_sp, height_sp, autoresize_bt, close_bt)
	
	fn adjustRightControls controls:r_controls = 
	(
		curr_size = getdialogsize boardless
		r_controls.pos.x += curr_size.x - last_size.x
		last_size = getdialogsize boardless
	)
	fn resizeDialog = 
	(
		last_size = getdialogsize boardless
		b = windows.getwindowpos boardless.hwnd
		windows.setwindowpos boardless.hwnd b.x b.y width_sp.value height_sp.value on
	)
	on width_sp changed val do if autoresize_bt.state do resizeDialog()
	on height_sp changed val do if autoresize_bt.state do resizeDialog()
	on width_sp entered arg can do if not can do resizeDialog()
	on height_sp entered arg can do if not can do resizeDialog()
	
	on close_bt pressed do
	(
		destroydialog boardless
	)
	on boardless resized size do
	(
		format "% %
" (getdialogsize boardless) size 
		adjustRightControls()
	)
	on boardless open do
	(
		last_size = getdialogsize boardless
	)
)
createdialog boardless style:#()

if you want to make nice re-sizing UI (mouse control) you can use events:

on <Rollout> mousemove <Point2> do
on <Rollout> lbuttondown <Point2> do
on <Rollout> lbuttonup <Point2> do

Hi Denis! Thank you so much for your help, it’s looking great, the only thing I get an error:

Unknown property: “getwindowpos” in #Struct:windows

at this line:
b = windows.getwindowpos boardless.hwnd

what version max do you use?

it’s in 3ds Max 2014 and higher.

sorry, 2012! I didn’t try in 2016 yet

if you are < 2014 find an example of .net assembly on this forum (user32.getwindowpos, user32.setwindowpos)

Waaw, in 2016 it’s working just great!
Is there a way to make it work in 2012?

OK, I will take a look!

Well, I think it’s very far from what I wanted:

try (destroydialog boardless) catch()
 rollout boardless "boardless dialog" width:300 height:300
 (
 	local SWP_NOMOVE = 2
 	
 	local last_size = undefined
 	
 	spinner width_sp "Width: " type:#integer range:[138,1000,300] fieldwidth:56 align:#right offset:[4,0]
 	spinner height_sp "Height: " type:#integer range:[100,1000,300] fieldwidth:56 align:#right offset:[4,0]
 	
 	checkbutton autoresize_bt "Auto Resize" width:120 align:#right offset:[4,0]
 	button close_bt "Close" width:120 align:#right offset:[4,0]
 	
 	local r_controls = #(width_sp, height_sp, autoresize_bt, close_bt)
 	
 	fn adjustRightControls controls:r_controls = 
 	(
 		curr_size = getdialogsize boardless
 		r_controls.pos.x += curr_size.x - last_size.x
 		last_size = getdialogsize boardless
 	)
 	fn resizeDialog = 
 	(
 		last_size = getdialogsize boardless
 		b = windows.getwindowpos boardless.hwnd
 		windows.setwindowpos boardless.hwnd b.x b.y width_sp.value height_sp.value on
 	)
 	on width_sp changed val do if autoresize_bt.state do resizeDialog()
 	on height_sp changed val do if autoresize_bt.state do resizeDialog()
 	on width_sp entered arg can do if not can do resizeDialog()
 	on height_sp entered arg can do if not can do resizeDialog()
 	
 	on close_bt pressed do
 	(
 		destroydialog boardless
 	)
 	on boardless resized size do
 	(
 		format "% %
" (getdialogsize boardless) size 
 		adjustRightControls()
 	)
 	on boardless open do
 	(
 		last_size = getdialogsize boardless
 	)
 	local mDownPressed = false
 
 	 
 	on boardless lbuttondown  pos do 
 	(
 		mDownPressed = true
 	)
 	
 	on boardless lbuttonup  pos do 
 	(
 		mDownPressed = false
 	)
 	on boardless mousemove pos do
 	(
 		
 		last_size = getdialogsize boardless
 		if pos.x >= last_size.x-10 and pos.y <= last_size.y-10 then 
 		(	
 			setSysCur #nuscale   
 			if mDownPressed then
 			(
 					b = windows.getwindowpos boardless.hwnd
 					print b
 					windows.setwindowpos boardless.hwnd b.x b.y pos.x b.h on
 			)	
 		)	
 		if pos.y >= last_size.y-10 and pos.x <= last_size.x-10 then 
 		(	
 			setSysCur #uscale  
 			if mDownPressed then
 			(
 					b = windows.getwindowpos boardless.hwnd
 					print b
 					windows.setwindowpos boardless.hwnd b.x b.y b.w pos.y on
 			)	
 		)
 	)	
 )
 createdialog boardless style:#()

To be honest, intuitively I came up to this:

clearlistener()
try (destroydialog boardless) catch()
rollout boardless "boardless dialog" width:300 height:300
(
	local SWP_NOMOVE = 2
	
	local last_size = undefined
	
	spinner width_sp "Width: " type:#integer range:[138,1000,300] fieldwidth:56 align:#right offset:[4,0]
	spinner height_sp "Height: " type:#integer range:[100,1000,300] fieldwidth:56 align:#right offset:[4,0]
	
	checkbutton autoresize_bt "Auto Resize" width:120 align:#right offset:[4,0]
	button close_bt "Close" width:120 align:#right offset:[4,0]
	
	local r_controls = #(width_sp, height_sp, autoresize_bt, close_bt)
	
	fn adjustRightControls controls:r_controls = 
	(
		curr_size = getdialogsize boardless
		r_controls.pos.x += curr_size.x - last_size.x
		last_size = getdialogsize boardless
	)
	fn resizeDialog = 
	(
		last_size = getdialogsize boardless
		b = windows.getwindowpos boardless.hwnd
		windows.setwindowpos boardless.hwnd b.x b.y width_sp.value height_sp.value on
	)
	on width_sp changed val do if autoresize_bt.state do resizeDialog()
	on height_sp changed val do if autoresize_bt.state do resizeDialog()
	on width_sp entered arg can do if not can do resizeDialog()
	on height_sp entered arg can do if not can do resizeDialog()
	
	on close_bt pressed do
	(
		destroydialog boardless
	)
	on boardless resized size do
	(
		--format "% %
" (getdialogsize boardless) size 
		adjustRightControls()
	)
	on boardless open do
	(
		last_size = getdialogsize boardless
	)
	local mDownPressed = 0

	 
	on boardless lbuttondown  pos do 
	(
		if pos.x >= last_size.x-10 and pos.y <= last_size.y-10 then
			mDownPressed = 1 -- X Direction
		if pos.y >= last_size.y-10 and pos.x <= last_size.x-10 then
			mDownPressed = 2 -- Y Direction
		if pos.y >= last_size.y-10 and pos.x >= last_size.x-10 then 
			mDownPressed = 3 -- X and Y Direction
	)
	
	on boardless lbuttonup  pos do 
	(
		mDownPressed = 0
	)
	on boardless mousemove pos do
	(
		
		last_size = getdialogsize boardless
		b = windows.getwindowpos boardless.hwnd
		case mDownPressed of
		(
			1: windows.setwindowpos boardless.hwnd b.x b.y pos.x b.h on -- X only
			2: windows.setwindowpos boardless.hwnd b.x b.y b.w pos.y on -- Y only
			3: windows.setwindowpos boardless.hwnd b.x b.y pos.x pos.y on -- Y only
		)	
		
		
		if pos.x >= last_size.x-10 and pos.y <= last_size.y-10 then 
		(	
			cursors = dotNetClass "System.Windows.Forms.Cursors"
			cursor = dotNetClass "System.Windows.Forms.Cursor"
			cursor.current = cursors.SizeWE
		)	
		if pos.y >= last_size.y-10 and pos.x <= last_size.x-10 then 
		(	
			cursors = dotNetClass "System.Windows.Forms.Cursors"
			cursor = dotNetClass "System.Windows.Forms.Cursor"
			cursor.current = cursors.SizeNS 
		)
		if pos.y >= last_size.y-10 and pos.x >= last_size.x-10 then 
		(
			cursors = dotNetClass "System.Windows.Forms.Cursors"
			cursor = dotNetClass "System.Windows.Forms.Cursor"
			cursor.current = cursors.SizeNWSE
		)	
	)	
)
createdialog boardless style:#()

Now I’m more happy with the result, but still, I don’t understand how to make it work in max 2012. I tried but I’m sure without help I can’t go on. Please don’t leave me at this point, because I really like how it’s working now!

Page 1 / 2