Click here to Skip to main content
11,709,537 members (52,078 online)
Click here to Skip to main content
Add your own
alternative version

MaChat - a chat with a browser for LANs

, 30 Jul 2002 277.4K 10.6K 117
This article shows how to create a Chat for Local Area Networks which uses the WebBrowser control to display the messages.
lsetup.zip
lSetup.msi
machatproject.zip
MaChatproject
Chat.suo
ChatLibrary
map
snChatLibrary.snk
MaChat
bin
Debug
AxSHDocVw.dll
data
html
line.jpg
smiley
rose.gif
smiley_biggrin.gif
smiley_confused.gif
smiley_cool.gif
smiley_cry.gif
smiley_dead.gif
smiley_eek.gif
smiley_frown.gif
smiley_laugh.gif
smiley_line.gif
smiley_mad.gif
smiley_OMG.gif
smiley_redface.gif
smiley_rolleyes.gif
smiley_smile.gif
smiley_snore.gif
smiley_squeamish.gif
smiley_suss.gif
smiley_tongue.gif
smiley_wink.gif
smiley_WTF.gif
icons
away.ico
brb.ico
browser.ico
dnd.ico
local.ico
offline.ico
private.ico
public.ico
remote.ico
user.ico
pl
SHDocVw.dll
temp
Release
AxSHDocVw.dll
data
html
line.jpg
smiley
rose.gif
smiley_biggrin.gif
smiley_confused.gif
smiley_cool.gif
smiley_cry.gif
smiley_dead.gif
smiley_eek.gif
smiley_frown.gif
smiley_laugh.gif
smiley_line.gif
smiley_mad.gif
smiley_OMG.gif
smiley_redface.gif
smiley_rolleyes.gif
smiley_smile.gif
smiley_snore.gif
smiley_squeamish.gif
smiley_suss.gif
smiley_tongue.gif
smiley_wink.gif
smiley_WTF.gif
icons
away.ico
brb.ico
browser.ico
dnd.ico
local.ico
offline.ico
private.ico
public.ico
remote.ico
user.ico
pl
SHDocVw.dll
temp
obj
Release
Resources
chat.ico
Images.resources
MagicLibrary
bin
Debug
Release
Collections
Common
Controls
InertButton.bmp
TabControl.bmp
Docking
MagicLibrary.csproj.user
Menus
MenuControl.bmp
obj
Debug
MagicLibrary.projdata
temp
TempPE
Release
MagicLibrary.projdata
temp
TempPE
Resources
ImagesCaptionIDE.bmp
ImagesCaptionPlain.bmp
ImagesMenuControl.bmp
ImagesPopupMenu.bmp
ImagesTabControl.bmp
LibraryIcon.ico
Win32
Resources
bin
obj
Setup
Setup.vdproj
Setup
ssetup.zip
sSetup.msi
// This script was created by Michael Mac and can be used as a freeware
var m_arMessages = new Array(0);
var m_nCurMsg = 0;
var m_strNoMoreMsg = "";
function AddMessage( strTitle, strText )
{
	// Create a new bigger array
	var array = new Array( m_arMessages.length + 2 );
	
	// Copy the old messages
	for( i=0; i<m_arMessages.length; i++ )
		array[i] = m_arMessages[i];
	
	// Add a new message at the end
	array[array.length-2] = strTitle;
	array[array.length-1] = strText;
			
	m_arMessages = array;
}
		
function Remove( nPos )
{
	// Create a new smaller array
	var array = new Array( m_arMessages.length - 2 );

	var nAddIndex=0;
	// Copy  messages
	for( i=0; i<m_arMessages.length; i++ )
	{
		if ( i == (nPos*2) || i == (nPos*2+1) )
			continue;
		
		array[nAddIndex] = m_arMessages[i];
		nAddIndex++;
	}
			
	m_arMessages = array;
						
	if ( m_nCurMsg >=1  )
	{
		m_nCurMsg--;
		ShowMsg( m_nCurMsg );
	}
	else
		ShowMsg( m_nCurMsg );
}
		
function ShowMsg( nMsg )
{
	if ( m_arMessages.length == 0 )
	{
		// Disable back, next and remove buttons
		document.getElementById( "back" ).style.visibility = "hidden";
		document.getElementById( "next" ).style.visibility = "hidden";
		document.getElementById( "remove" ).style.visibility = "hidden";

		// Show appropriate message
		text.innerHTML = m_strNoMoreMsg;
		title.innerHTML = m_strNoMoreMsg;
		info.innerHTML = "0/0";
		show();
		return;
	}
			
	m_nCurMsg = nMsg;
	title.innerHTML = m_arMessages[nMsg*2];
	text.innerHTML = m_arMessages[nMsg*2 + 1];
	show();
			
	// Enable or disable buttons
	if ( nMsg == 0 )
		document.getElementById( "back" ).style.visibility = "hidden";
	else
		document.getElementById( "back" ).style.visibility = "visible";
	
	if ( nMsg >= ( m_arMessages.length / 2 ) - 1 )
		document.getElementById( "next" ).style.visibility = "hidden";
	else
		document.getElementById( "next" ).style.visibility = "visible";
				
	// Set info
	info.innerHTML = ( m_nCurMsg + 1 ) + "/" + ( m_arMessages.length / 2 );
}
		
function Back()
{
	m_nCurMsg--;
	ShowMsg( m_nCurMsg );
}
		
function Next()
{
	m_nCurMsg++;
	ShowMsg( m_nCurMsg );
}

function SetNoMoreMsgString( strText )
{
	m_strNoMoreMsg = strText;
}

// This part of the script is a modification of the orginal one which you can download from www.dynamicdrive.com

var bouncelimit = 32;

function show()
{	
	// Start
	crossobj = document.getElementById( "msg" ).style;
	crossobj.left = 45;
	scroll_top = document.body.scrollTop;
	crossobj.top = scroll_top - 250;
	crossobj.visibility = "visible";
	dropstart = setInterval( "dropin()", 50 );
}

function dropin()
{
	scroll_top = document.body.scrollTop;
	if ( parseInt( crossobj.top ) < 100 + scroll_top )
		crossobj.top = parseInt( crossobj.top ) + 40;
	else
	{
		clearInterval( dropstart );
		bouncestart = setInterval( "bouncein()" , 50) ;
	}
}

function bouncein()
{
	crossobj.top = parseInt( crossobj.top ) - bouncelimit;
	if ( bouncelimit < 0 )
		bouncelimit += 8;
	bouncelimit = bouncelimit * -1;
	if ( bouncelimit == 0 )
		clearInterval( bouncestart );
}

function dismissbox()
{
	if ( window.bouncestart )
		clearInterval( bouncestart );
		
	bouncelimit = 32; //(must be divisible by 8)
	crossobj.visibility = "hidden";
	clearInterval( dropstart );
	clearInterval( bouncestart );
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Michael Mac
Architect macmichal.pl
Poland Poland
Micheal is an independent consultant - www.macmichal.pl.
He's main areas of interest are: DDD\CqRS, TDD, SaaS, Design Patterns, Architecture. He specializes in .Net/C# for the early beginning of it and T-SQL. He's a writer, blogger (blog.macmichal.pl) and speaker.

In his spare time, he's climbing the mountains all over the Europe.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150819.1 | Last Updated 31 Jul 2002
Article Copyright 2002 by Michael Mac
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid