[.net] How to "detatch" a modal form?
Quote:Original post by orbano
all of you are bound to these stupid old habits.
Yeah, that's a good way to get people to help you. :rolleyes:
Quote:Original post by orbano
why should it not change its modal state? where did you learn that? its some kind of software-ergonomy domgma? i dont think so...
No, it's called good design. Its purpose is to give users a consistent experience so they don't get frustrated using software where everyone makes things that look the same act differently.
I still see no reason to do something like this. If every window is detachable, why would they need to be modal to start? If you're worried about people interacting with Form A when Form B is opened, disable Form A while Form B is open and make Form A the owner of Form B. The user can still see it but not do anything on it. When Form B closes it can re-enable it's owner or you can have Form A hook into Form B's Closing event and re-enable itself.
As i mentioned before, only specific windows will have this ability (read-only lists). They will also have some options disabled in modeless state. If you can help, please do it. I'm here to get some help. Not an advice...
Regards
Regards
Sometimes good advice is the best help you can get. Maybe there's a reason why this type of functionality doesn't exist.
Quote:Original post by Machaira
Sometimes good advice is the best help you can get. Maybe there's a reason why this type of functionality doesn't exist.
we have very good proverbs for this. unfortunately my english restricts me to express them :)
i dont really care about the current design of windows forms. there are many design issues related to it. for exaple it took about a year to develop our own control-management. create our own controls, taborder, validation, extend customizeability, just to create a competent user experience. after this i dont really care if it was someone's intention not to allow this "feature" in windowing, or simply the sloppyness of some coders at M$.
and please, dont misunderstand me. i really respect that you are trying to reflect at the sossibility of a dsign failure (i'd do the same). but i can assure you, i know what i want. really.
Quote:Original post by orbano
I want the following:
after opening FormB as a modal form from FormA /FormB.ShowDialog(FormA);/, i would like to have an option, to make FormB turn into a modeless form without altering its current state (with a press of a button on FormB).
You cannot do this... easily... Because of the way modal windows are implemented you'd need to dispose of the dialog's modal message pump and hook the window back into the application's message pump.
Quote:Original post by orbano
why should it not change its modal state?
Unfortunately the modal path for a dialog cannot become a modeless path because the calling code will always block while waiting for the modal pump to return with a result. Having a window that changed modal state would suggest that there was not always going to be a return value from that dialog - which is counter to the way most application logic flows.
Anyway, the the only practical way of achieving this is to destroy your modal window and create another modeless one. A workable alternative is to always create your dialog modeless and prevent interaction with your application via other means for modal scenarios.
Jans.
thank you, im going on the second way you suggest. i hoped there would be an easier solution than simulating modal behaviour. this way i will also be able to provide a return value (maybe a special-, or default one).
Did you try shadowing the ShowDialog method?
Basically, it sets a flag if the detach button is selected, and the custom ShowDialog method (maybe better to change its name for code clarity) checks to see if the detach button was clicked, and if it was, reshow the form as modeless. There's no need to put the main form in a loop or anything, because the child form is shown with ShowDialog first.
Public Class Form2 Dim detaching As Boolean Public Shadows Function ShowDialog(ByVal owner As IWin32Window) As DialogResult Dim retval As DialogResult retval = MyBase.ShowDialog(owner) If (detaching) Then Show(owner) End If End Function Private Sub btnDetach_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDetach.Click detaching = True End SubEnd Class
Basically, it sets a flag if the detach button is selected, and the custom ShowDialog method (maybe better to change its name for code clarity) checks to see if the detach button was clicked, and if it was, reshow the form as modeless. There's no need to put the main form in a loop or anything, because the child form is shown with ShowDialog first.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement