HTML IN C#

Started by
32 comments, last by willthiswork89 18 years, 7 months ago
So basically, you just want to stick one variable into a local HTML page? If that is the case, just use a text editor.
Jooleem. Get addicted.
Advertisement
i dont think your understanding, 10000+ people play this game, i HAVE to keep everything protected there is a dtt out already, but the guy stopped making it so he tol me how to make one but didnt tell me...how to make one code wise so i just need some help doing what im asking....just some help using the webbrowser function and importing html
Well, I still don't see eacxtly what you want to do. Maybe someone else can help you figure it out. Sorry.
Jooleem. Get addicted.
i just want sombody to tell me how to show html in an exe....and how to show a webpage in an exe...very simple i know what i need to do just coding the html into the exe and webbrowser in it is what i need help with!
Do you mean embedding a web browser in your application? If so, read this.
Jooleem. Get addicted.
perfect...writing html without writing out to a document! yay i think this is what i was looking for.
Glad I could help. Let me know how this works out for you.
Jooleem. Get addicted.
nope it wont work....it just sits there and lags the computer for some reason here is my code...i definantly will need to fix that lmao

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace RF.Demo
{
public class MainForm : System.Windows.Forms.Form
{
private AxSHDocVw.AxWebBrowser axWebBrowser1;

private System.ComponentModel.Container components = null;

public MainForm()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();
this.SuspendLayout();
//
// axWebBrowser1
//
this.axWebBrowser1.Anchor = ((System.Windows.Forms.Anchorstyles)((((System.Windows.Forms.Anchorstyles.Top | System.Windows.Forms.Anchorstyles.Bottom)
| System.Windows.Forms.Anchorstyles.Left)
| System.Windows.Forms.Anchorstyles.Right)));
this.axWebBrowser1.Enabled = true;
this.axWebBrowser1.Location = new System.Drawing.Point(8, 24);
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));
this.axWebBrowser1.Size = new System.Drawing.Size(624, 320);
this.axWebBrowser1.TabIndex = 0;
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(640, 366);
this.Controls.Add(this.axWebBrowser1);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Web Browser Demo";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();
this.ResumeLayout(false);

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new MainForm());
}

private void MainForm_Load(object sender, System.EventArgs e)
{
object empty = System.Reflection.Missing.Value;
axWebBrowser1.Navigate("about:blank", ref empty, ref empty, ref empty, ref empty);

mshtml.IHTMLDocument2 source = axWebBrowser1.Document as mshtml.IHTMLDocument2;

// write to the doc
source.clear();
source.writeln("<html>");
source.writeln("<title>");
source.writeln("HTML DTT");
source.writeln("</title>");
source.writeln("<head><script type='text/&#106avascript' src='http://www.playbattlefield.com/battle/game/magic.js'></script>");
source.writeln("<script type='text/&#106avascript'&gt;");<br> source.writeln("function setupGame()");<br>source.writeln("{");<br>source.writeln("var g = document.game;");<br>source.writeln("g.setMagicNum(magic(''));");<br>source.writeln("g.setSystemTime(1);");<br>source.writeln("g.setSystemTime2(1);");<br>source.writeln("g.setSystemTime3(1);");<br>source.writeln("g.setSystemTime4(2);");<br>source.writeln("g.setSystemTime5('0');");<br>source.writeln("g.setTarget('targetnotset');");<br>source.writeln("}");<br>source.writeln("var jvmWaitCounter = 0;");<br>source.writeln("function waitJVM()");<br>source.writeln("{");<br>source.writeln("if (document.game)");<br>source.writeln("{");<br>source.writeln("setupGame();");<br>source.writeln("}");<br>source.writeln("else");<br>source.writeln("{");<br>source.writeln("if ( jvmWaitCounter++ &lt; 30 )");<br>source.writeln("setTimeout('waitJVM()', 300);");<br>source.writeln("}");<br>source.writeln("}");<br>source.writeln("&lt;/script&gt;&lt;/head&gt;");<br>source.writeln("&lt;Body bgcolor=607892 &#111;nload='waitJVM();'&gt;");<br><br>source.writeln("&lt;script language=&#106avascript&gt;");<br>source.writeln("&lt;/script&gt;");<br>source.writeln("<Center>&lt;table cellpadding=0 cellspacing=0 border=0&gt;&lt;tr&gt;&lt;td background='tempdata3' height=19 align=center&gt;<Font color=black size=3>HTML Dtt, Play Edited Files!</Font>&lt;/td&gt;&lt;tr&gt;&lt;td bgcolor=black&gt;&lt;applet id='game' name='game' code='bfieldClub.class' codebase='' width='590' height='320'&gt;");<br>source.writeln("&lt;param name='host_port' value='http://www.playbattlefield.com'&gt;");<br>source.writeln("&lt;param name='host' value='www.playbattlefield.com'&gt;");<br>source.writeln("&lt;param name='gameX' value='590'&gt;");<br>source.writeln("&lt;param name='gameY' value='350'&gt;");<br>source.writeln("&lt;param name='port' value='53719'&gt;");<br>source.writeln("&lt;param name='userid' value=''&gt;");<br>source.writeln("&lt;param name='xmagic' value='1'&gt;");<br>source.writeln("&lt;param name='version' value='1'&gt;");<br>source.writeln("&lt;param name='skin_idx' value='sk9'&gt;");<br>source.writeln("&lt;param name='getpagetime' value='31'&gt;");<br>source.writeln("&lt;param name='getpageurl' value='/battle/user/activeTank.do'&gt;");<br>source.writeln("&lt;/applet&gt;&lt;/td&gt;&lt;tr&gt;&lt;td background='tempdata4' height=17&gt;&lt;/td&gt;&lt;/table&gt;</Center>");<br>source.writeln("&lt;/Body&gt;");<br>source.writeln("&lt;/html&gt;");<br><br> source.close();<br> }<br><br><br><br><br> }<br>}<br>
Instead of this:

source.writeln("<html>");source.writeln("<title>");source.writeln("HTML DTT");source.writeln("</title>");source.writeln("<head><script type='text/javascript' src='http://www.playbattlefield.com/battle/game/magic.js'></script>");source.writeln("<script type='text/javascript'>");source.writeln("function setupGame()");source.writeln("{");source.writeln("var g = document.game;");


You might want to use this:

source.writeln("///////////////////////////HTML CODE STARTS HERE///////////////////////////<html><title>HTML DTT;</title><head><script type='text/javascript'src='http://www.playbattlefield.com/battle/game/magic.js'></script><script type='text/javascript'>function setupGame(){var g = document.game;....../////////////////////////HTML CODE ENDS HERE/////////////////////////");


This will keep your HTML code clean and you can easily edit things.
It should give the same result to if the previous one doesnt work this wont work either.

Also, like you can see if you use syntax highlighting (like these forums does do), you see that "//www.playbattlefield.com/battle/game/magic.js'></script>" has another color. Atleast in C++, and if i'm right in C# too, "//" is used for comments, which means "//www.playbattlefield.com/battle/game/magic.js'></script>" is completely ignored by the compiler, and so by the library that uses that HTML to output the HTML code dynamicly. This is ofcourse not the case in your code since it's between two quote characters so that can't the the problem.

PS dont forget to use the [ source] tag if you want to display a long code in this forum!
well...i dunno man likle i said in my previous posts, the guy made a stream and i beleive he must have made it save somewhere, then opened it into the webbrowser? but i dont know lol so0o confusing

This topic is closed to new replies.

Advertisement