Notifications
Clear all

[Closed] How to close Dialog on focus lost?

Hi guys,
I’m working on an experimental UI made mostly of popups, nothing too fancy but it could speed me up quite a bit.

Coming to the question: is there a way to destroy a dialog once it loses focus?
One dirty way could be to get (by timer) the currently active window HWND and see if it matches the dialog (got by DialogMonitorOps), but I haven’t found a straight way to get such HWND with plain MaxScript yet.

Any solution is well accepted, by .Net too, provided it is not too convoluted and allows me to easily handle standard 3ds Max rollout UI elements.

Thank you very much.

  • Enrico
5 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

as i understood you want to close (at least to get the message – event) when your dialog (max dialog) gets lost the focus. am i correct?
with the dotnet form is not a problem. but you want to get it for a max dialog. right?

the general way of doing it is to use the timer. it’s usual way how a developer does it. personally i hate this way but i use it because sometimes there is no workaround.

you can use dotnet form and ‘ownered ’ the max dialog (rollout) and catch parent messages… see my samples how to use max dialog (rollout(s)) in a dotnet form.

to make the trick i need to know exactly what you want to achieve.

I guess dotNet is the answer:

on <control_name> LostFocus <System.EventArgs>e do ( ... )

Thanks lutteral, unfortunately I’m completely illiterate on dotNet. Could you please elaborate more on this or point me to docs, in order to make me able to patch something together?

  • Enrico

I’m not an expert using dotNet neither, but I’ve used some controls in my scripts though. There’s a lot of dotNet gurus in this forum, maybe one of them could point you in the right direction better than me. Try searching this forum (or the area forum from autodesk) and the MaxScript help files, you should get a good starting point.

cheers,

M

Hi Denis,
you got it right, I’d like to be able to catch the “on focus lost” event for a simple 3ds Max rollout displayed as a dialog. I don’t really care if I have to use a timer, because it is for a very transient user interface and the timer would be active for a very short amount of time. I hate timers too, but in particular those that are obnoxiously ever ticking to make up for the lack of an event catcher. I should only press a shortcut that shows the “popup interface” and at very first click anywhere within 3ds Max, close it.

I’ve seen your solution with the dotNet form that becomes parent to the 3ds Max rollout before actually posting this request, but while I get it from a logical standpoint, looks to me quite obscure code-wise as I don’t have any dotNet/C# knowledge yet.

Thank you for your continuous help.

  • Enrico