Ed,
It sounds like you seriously need to reconsider what you are attempting!
Consider rewriting the spell check form (from scratch if necessarily), so it
functions in the manner that you require, of course I would question any
spell check form that required ShowDialog anyway.
As has been pointed out only ShowDialog returns the DialogResult. If you
need to use Show, then you need another method to return the DialogResult,
most if not all of these other methods will require your spell form to raise
an event or some sort, otherwise how would the first form know that the
DialogResult was available from the spell check form?
Remember when you design a form, developers rarely design a form to support
both Show & ShowDialog, they design it to use one or the other, at least I
cannot think of a reason why I would design a form to support both. If the
Spell Dialog was designed to return a DialogResult, it sounds like it was
only designed to use ShowDialog, hence your problems.
In other words do it "correctly", any thing else, as Cor puts it, is an
"obfuscated program", a very hard to read & understand program.
Hope this helps
Jay
ed said:
Armin,
First, here's my objective....If there there is a misspelled word in a
textbox on the main form, the spell check form will appear and at the same
time, the misspelled word on the main form should be highlighted (I used
textbox.select() for this one). By the way, the spell check form is somewhat
similar to the spell checker of word.
Here comes the problem.... since the spell check form is modal, the
highlight for the misspelled word cannot be seen since the focus of the
application is on the spell check form. I'm pretty much sure that my code
for the highlighting of the misspelled word is working because if i close
the spell check form (meaning it loses focus on it and brings the focus back
on the main form), i can see that the misspelled word is highlighted.
Now just an FYI, this is a complex application handed over to me for
maintenance purposes so the whole app is really not my code. What I'm trying
to do now is to do as little change to the code as possible (if it can be
done, which i hope
)
Cor,
Now this is the main reason why I can't just apply the code that you
wrote. I know it should be like that too (and as simple as that
) it's
just that the original designer of the code didn't make it that way, he did
it a little bit more complex
CJ,
I appreciate the alternative but whoah....i guess i agree with you when
you said "extensive"
Like I said above, I like to do as little change as
possible to the code, nevertheless, I will try your suggestion if there are
no more easy alternatives
Jay B. Harlow,
As i said above, the original code did not come from me. I was about to
try your suggestion but when i saw the code, there is already an
eventhandler for each of the button_click events. Aside from the select case
Me.dialogresult..... that will process what was clicked on the spell check
form, it also has an event handler. Now i have yet to understand how that
works but i will work on it
Thanks again to everyone
I hope i have cleared some of your
questions.....so with those in mind....any more suggestions?