Notifications
Clear all

[Closed] Detecting last resize event

So… I;m using resized event to save the last dialog size.
Problem is that this event is fired many many times when user is resizing.

How could I defect only the last resize even?
I was trying to use dotnet timer.
But. no success.

9 Replies

Update a variable and save it when the dialog is closed. Or get the size just before the dialog is closed.

(
	try destroydialog ::RO_TEST catch()
	rollout RO_TEST "" width:200 height:200
	(
		local dlgSize = [200,200]
		
		on RO_TEST resized arg do dlgSize = arg
			
		on RO_TEST close do messagebox ("Dialog Size will be saved\n\n" + (dlgSize as string))
	)
	createdialog RO_TEST style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu)
)

or

(
	try destroydialog ::RO_TEST catch()
	rollout RO_TEST "" width:200 height:200
	(
		on RO_TEST close do
		(
			w = RO_TEST.width
			h = RO_TEST.height
			messagebox ("Dialog Size will be saved\n\n" + ([w,h] as string))
		)
	)
	createdialog RO_TEST style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu)
)

Well… the reason why I’m tryong to defect is that I want to close dialog automatically when resize is done.

Well, that changes the things. Although I have to say it is an uncommon behavior what you are seeking (IMO). I’ve never seen such a behavior in a dialog, but I am sure you must have your reasons.

So, you must also have an idea of what you consider resizing. I mean, you want to close the dialog automatically when the resize event ends, but what defines the end of the resizing event 50ms, 250ms, 500ms, a mouse up event? It is an arbitrary behavior so I guess you already know what it should be.

May I ask how this would be used and why it must be when the user “somehow” ends the resizing and not when the event begins?

If I can detect 100ms, that should be enough.
The reason is…

I need to restart dialog to redraw all UI sized according to resized main dialog when user finishes resize.

Does this work for what you need?

(
	try destroydialog ::RO_TEST catch()
	rollout RO_TEST "" width:200 height:200
	(
		timer clock "" interval:100 active:off
		
		on clock tick do destroydialog ::RO_TEST
		
		on RO_TEST resized arg do clock.active = on
			
		on RO_TEST close do
		(
			w = RO_TEST.width
			h = RO_TEST.height
			messagebox ("Dialog Size will be saved\n\n" + ([w,h] as string))
		)
	)
	createdialog RO_TEST style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu)
)

oh… it seems working well.
Thanks!
I guess I can control the interval number?

Sure, you can use the one you define at rollout setup of modify it anytime later, as well as turn the timer on/off.

Working great. I’m also using for moved event, too.
Thanks a lot!

the right way is to add Native Window and catch all messages. I don’t remember right now but you need to catch WM_SIZING or WM_NCCALCSIZE. The ‘resized’ event is going after WM_SIZE. It’s usually too late and visible when children controls are not align/resize with the dialog

i posted an example on this forum