I'm currently working on a project but I can't get any further I have a tab and a button that creates another tab, the code for it looks like this
public void newtab()
{
tabpage ++;
string namesys = tabpage + " - Script";
Random rnd = new Random();
this.web = new System.Windows.Forms.WebBrowser();
this.bt = new System.Windows.Forms.Button();
this.tp = new System.Windows.Forms.TabPage();
this.lb = new System.Windows.Forms.Label();
tp.Text = namesys;
bt.Location = new Point(3, 374);
bt.Text = "Execute";
this.bt.Click += new System.EventHandler(this.tabexecute);
for (int j = 0; j < 4; j++)
{
Console.WriteLine(rnd.Next());
}
int randit = rnd.Next();
lb.Location = new Point(414 ,377);
lb.Text = randit.ToString();
lb.ForeColor = Color.Black;
lb.Name = "Code";
web.Name = lb.Text;
web.Url = new Uri(string.Format("file:///{0}/Ace/AceEditor.html", Directory.GetCurrentDirectory()));
web.Location = new Point(3, 8);
web.Size = new Size(919 ,360) ;
tp.Controls.Add(web);
tp.Controls.Add(lb);
tp.Controls.Add(bt);
tabControl1.Controls.Add(tp);
}
but now I have the problem when you are in the tab created above the code, private void tabexecute was not working (see code)
private void tabexecute(object sender, EventArgs e)
{
HtmlDocument document = webBrowser1.Document;
string scriptName = "GetText";
object[] args = new string[0];
object obj = document.InvokeScript(scriptName, args);
string script = obj.ToString();
API.SendLuaCScript(script);
API.SendLuaCScript(txt_inject.Text);
}
Because I don't know how to do HtmlDocument document = webBrowser1.Document;
can be rebuilt so that it always uses the web browser where it is currently in the tab. The web browser name is randomly generated each time a tab is created.
Here is a screenshot that might clarify the issue: