Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I interact with a dialog? 1

Status
Not open for further replies.

RestonDeveloper

Programmer
Aug 1, 2007
23
US
I have a dialog (spellchecker)

I have a form that calls the dialog.

the only problem is the dialog doesn't show the mispelled word in the context. so I want to add a textbox to the dialog that I can pass the context to.
 
Can you provide a better example of what you are trying to do? Is it as simple as checking the spelling in an existing text box (but prompting in a dialog for spelling errors? I am reading it as you are checking spelling but your prompt to fix spelling is only showing the word in question. What would help is:

1. How are you spell checking
2. How are you bringing up the dialog

Good Luck,

Alex

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
If you have a reference to the instance of that dialog, you can do the following:

- Add a public method in the dialog class that, given a string parameter, will change the textbox.Text property.

- From the main form, call that method and pass the misspelled word as a parameter.

Hope that helps.
Andrew

|| ABC
 
[ol]
[li]I am using a 3rd party spellchecker Keyoti.RapidSpell[/li]
[li]rapidSpellDialog1.Check();[/li]
[/ol]
 
.Check() is in the the 3rd party Dll.

I guess something I would be comfortable with, though probably not ideal is to have a dialog that's mine that serves as intermediary, hiding rapid spell's dialog.

if that's the case I need to have my dialog reference there dialog's textbox (and buttons).
i can have my textbox have the word in it's context and my buttons call their equivalent button.onclick events.

my question is how do i reference a dialog, for instance i have the dialog onload MessageBox(this.Name); and it alerts blank.
 
Can you post ALL your spell checking code?

Reading Keyoti's website it appears that the pop-up spell checker does show the misspelled word in context, so I am afraid that I have misread your problem. If I have not, then perhaps you are not calling the dialog properly?

Also, as it appears this is mostly done client side (after a very brief perusal of Keyoti's website) and you are asking very web-centric questions you may wish to try this forum: forum855

Hope this helps,

Alex






[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
Alex Rapid Spell has two versions, Web and Desktop. They don't look, work identical. I'm referring to the Desktop.

Their Desktop came with samples for 2005 and 2003, but only shows a custom gui in 2003 doesn't show the context in their dialog. I've posted in the Keyoti Support Forum as well, but it's not that active this week anyways.

I just want to know how to reference an open dialog who's name I don't know so that I can create a form or dialog exactly like my manager wants it to look like.

so FormA starts rapidspelldialog1.check(), I want FormB to read in values and point to button events of the dialog that was called. it will always only be one dialog.

If you know, much appreciated sorry i wasn't clearer in original posts.
 
Ah, didn't see that. I'm looking at the desktop version right now and of course it does not show the words in context. I'll download the trial when I get home and play with it a little bit.

You would think for $300 they would give a little better support, right? ;-)

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
Alright, this turned out to be a task that is not for the faint of heart. I am sure there is a better way, but this is the best I could do.

In a nutshell, I created my own form that extends the Keyoti.RapidSpell.RapidSpellGUI class. I added a text box called txtOrig and set the size (and more importantly minimum size, because the Check() method seems to size the form down uless you have a minimum set) to 500,305. I didn't do anything with the text box in design view so I can show you in code where its' positioned. I didn't mess around with any of the pre-existing components, but you can if you want.

The form also needs to accept a string (containing text to check), a reference to a form(to send the fixed text back to), and the name of the form to send the fixed text back to. I must have tried a million ways, but this is the only one that worked for me (well others worked, but this was more flexible - more on that in a minute). Here is the code for my form:

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Keyoti.RapidSpell;


namespace SpellCheckTest
{
    public partial class ChkForm : Keyoti.RapidSpell.RapidSpellGUI
    {
        public Form fTemp;
        public string sName;

        public ChkForm()
        {
            InitializeComponent();

            //size the text box
            txtFix.Location = new Point(306, 11);
            txtFix.Multiline = true;
            txtFix.Size = new Size(174, 250);
            txtFix.Visible = true;
            txtFix.ScrollBars = ScrollBars.Vertical;

        }

        public ChkForm(string txt, Form fIn, string controlName)
        {
            //need the text, a reference to the form, and the control on the form's name
            //in order to pass the text back once it is checked
            InitializeComponent();

            //size the text box
            txtFix.Location = new Point(306,11);
            txtFix.Multiline = true;
            txtFix.Size = new Size(174,250);
            txtFix.Visible = true;
            txtFix.ScrollBars = ScrollBars.Vertical;

            txtFix.Text = txt;
            fTemp = fIn;
            sName = controlName;
        }


        public void myCheck()
        {
            this.SetTextComponentToCheck(txtFix);
            
            this.Check();

        }

        public void myCheck(string txt)
        {
            this.txtFix.Text = txt;
            this.SetTextComponentToCheck(txtFix);
            this.Check();
        }

        public void setText(string txt)
        {
            txtFix.Text = txt;
        }

        public void setControlName(string controlName)
        {
            sName = controlName;
        }

    }
}

At this point, we are still not done. The check() method that we need to use seems to be calling dispose(), because everyt time I tried retrieving the text from the form's text box using a property or method (outside dispose()), it was already gone. So, I hacked the dispose() method to try and send back text. Here is the method (in the form designer) - make sure that you have referenced System.Reflection namespace on your form:

Code:
        protected override void Dispose(bool disposing)
        {
            try
            {
                fTemp.Controls[sName].Text = txtFix.Text;
            }
            catch (System.NullReferenceException ex)
            {
                //do nothing
            }
            finally
            {
                fTemp = null;
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
        }

Before putting this in production I would make sure the error handling is VERY strong!

Finally, here is how I called it from my main form:

Code:
private void button3_Click(object sender, EventArgs e)
{
    ChkForm myCHK = new ChkForm(txtOrig.Text, this, "txtOrig");
    myCHK.myCheck();
}

Like I said I'm sure there is a better way, but this works alright. There is a lot avaialable in there that you can use to customize your form further too. The hardest part seems to be making it return the text to your original form.

I hope this helps,

Alex

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
I think Alex deserves a star.

Christiaan Baes
Belgium

"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
Yes, Alex went above and beyond! Thank you Alex.

Not only does your solution solve my problem, but I know I'll be learning a lot from it and have multiple uses for it.

Thank you so much!
 
>>>Keyoti Forum posted what appears to be a solution to my question.

Darn, too late ;-)

I imagine that the sample project they reference is somewhat similar to what I did.

Out of curiousity, why are you doing this in C# if you are more familiar with VB.net? Just trying to learn the language?

Regardless, glad you've got it working now!

Alex

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top