Lock other windows with one key

Is it possible to have only one window in the application to be able to be used and other ones to be locked like when you use “display dialog”. Also have it beep if you try to use the other windows and it doesn’t bring the other windows to the front but keeps that one window above the others.

Also I used:
on applicationShouldTerminateAfterLastWindowClosed_(sender)
return true
end applicationShouldTerminateAfterLastWindowClosed_

And when I close one window and another is still open or if I use display dialog “” it closes the application even though there is one more window is left open.

You probably want beginModalSessionForWindow_.

I tried that and the other window can still be brought to the front.

How would you write it to make it work for the window:
property mainwin :missing value

does anyone know?