Click here to Skip to main content
15,910,872 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: linking managed dll to standard c++ Pin
Emiliano28-Jun-04 23:59
Emiliano28-Jun-04 23:59 
QuestionProblem connecting to server -difference managed C++ and C#? Pin
EnkelIk2-Jun-04 21:46
EnkelIk2-Jun-04 21:46 
GeneralOutlook Express [Mail Compose] Pin
kmcguire2-Jun-04 16:29
kmcguire2-Jun-04 16:29 
GeneralPassing managed object through clipboard Pin
rkvs1-Jun-04 10:35
rkvs1-Jun-04 10:35 
Generalfirewall Pin
shahrokh nabavi1-Jun-04 7:07
shahrokh nabavi1-Jun-04 7:07 
GeneralRe: firewall Pin
kmcguire1-Jun-04 15:52
kmcguire1-Jun-04 15:52 
GeneralHTML edit and view control. Pin
kmcguire27-May-04 22:54
kmcguire27-May-04 22:54 
GeneralRe: HTML edit and view control. Pin
kmcguire28-May-04 3:23
kmcguire28-May-04 3:23 
nm; I figured out how to do it.

Using label and picture box controls. Smile | :)
I convert HTML into my own structored format of
text, image, and tag classes linked together then
the main class displays these onto a surface and using
autoscrolling - *magic* it looks just like a webpage..
Well, almost. With a little work it would.
----------------------------------------------------------------------------
<br />
// The header<br />
#pragma once<br />
<br />
using namespace System;<br />
using namespace System::Drawing;<br />
using namespace System::Drawing::Drawing2D;<br />
using namespace System::Windows::Forms;<br />
<br />
__gc class mlr_lb {<br />
public:<br />
	mlr_lb();<br />
	~mlr_lb();<br />
};<br />
__gc class mlr_txt {<br />
public:<br />
	mlr_txt();<br />
	~mlr_txt();<br />
<br />
	Drawing::Color color;<br />
	Drawing::Font * font;<br />
	String * txt;<br />
};<br />
__gc class mlr_img {<br />
public:<br />
	mlr_img();<br />
	~mlr_img();<br />
<br />
	PictureBoxSizeMode sizemode;<br />
	String * path;<br />
	Int32 width;<br />
	Int32 height;<br />
};<br />
__gc struct mlr_lnk {<br />
	Object * obj;<br />
	mlr_lnk * next;<br />
};<br />
__gc class mlr {<br />
public:<br />
	mlr(void);<br />
	~mlr(void);<br />
	Int32 x;<br />
	Int32 y;<br />
	mlr_lnk * lnk;<br />
	Boolean RemovePrevCtrls( Form * f );<br />
	Boolean Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h );<br />
};<br />

<br />
// The source.<br />
#include "StdAfx.h"<br />
#include ".\mlr.h"<br />
#using <mscorlib.dll><br />
<br />
String * JoinStrAr( String * s[], Int32 x, Int32 l, String * d )<br />
{<br />
	String * str = S"";<br />
	for( Int32 index = x; index < x+l; index++ )<br />
	{<br />
		str = S""->Concat( str->Trim(), d, s[index]->Trim(), d);<br />
	}<br />
	if(str->Length < 1)<br />
		return str;<br />
	return str->Substring( 0, str->Length - d->Length );<br />
}<br />
String * MakeWidthFit( String * s, System::Windows::Forms::Label * l, Int32 w )<br />
{<br />
	l->Text = s;<br />
	if( l->Width > w )<br />
	{<br />
		String * ls[] = s->Trim()->Split( S" "->ToCharArray() );<br />
		for( Int32 index = ls->Length; index > -1; index-- )<br />
		{<br />
			l->Text = JoinStrAr( ls, 0, index, " " )->Trim();<br />
			if( l->Width <= w )<br />
			{<br />
				return JoinStrAr( ls, index, ls->Count - index, " " );<br />
			}<br />
		}<br />
		return s; /* it's just a long long line. :-) */<br />
	}<br />
	return NULL;<br />
}<br />
//<br />
mlr::mlr(void) { }<br />
mlr::~mlr(void) { }<br />
Boolean mlr::RemovePrevCtrls( Form * f )<br />
{<br />
	Int32 cnt;<br />
start:;<br />
	cnt = f->Controls->Count;<br />
	for( Int32 index = 1; index < cnt; index++ )<br />
		if( f->Controls->get_Item( index )->Tag->ToString()->CompareTo( S"MLR_CTRL" ) == 0 )<br />
		{<br />
			f->Controls->RemoveAt( index );<br />
			goto start;<br />
		}<br />
	return true;<br />
}<br />
Boolean mlr::Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h )<br />
{<br />
	String * str;<br />
	Int32 cx = x;<br />
	Int32 cy = y;<br />
	Int32 clh = 0;<br />
	mlr_lnk * l = lnk;<br />
<br />
	RemovePrevCtrls( f );<br />
	f->Update();<br />
<br />
	while( lnk != NULL )<br />
	{<br />
		if( lnk->obj->GetType()->FullName->CompareTo( "mlr_txt" ) == 0 )<br />
		{<br />
			mlr_txt * txt = static_cast<mlr_txt*>( lnk->obj );<br />
			str = static_cast<mlr_txt*>( lnk->obj )->txt;<br />
			while( str != NULL )<br />
			{<br />
				/* [create] label control */<br />
				System::Windows::Forms::Label * newl = new System::Windows::Forms::Label();<br />
				newl->Tag = S"MLR_CTRL"; /* quick removal */<br />
				newl->AutoSize = true;<br />
				newl->Location = Point( cx, cy );<br />
				newl->Font = txt->font;<br />
				str = MakeWidthFit( str, newl, w - (cx - x) );<br />
				if( str != NULL )<br />
				{<br />
					/* no more room left on line */<br />
					cx = x;<br />
					if( newl->Height > clh )<br />
						clh = newl->Height;<br />
					cy = cy + clh;<br />
					clh = 0;<br />
				}else {<br />
					clh = newl->Height;<br />
					cx += newl->Width;<br />
				}<br />
				f->Controls->Add( newl );<br />
			}<br />
<br />
		}<br />
		if( lnk->obj->GetType()->FullName->CompareTo( "mlr_lb" ) == 0 )<br />
		{<br />
			cx = x;<br />
			cy = cy + clh;<br />
			clh = 0;<br />
		}<br />
		if( lnk->obj->GetType()->FullName->CompareTo( "mlr_img" ) == 0 )<br />
		{<br />
			mlr_img * img = static_cast<mlr_img*>( lnk->obj );<br />
			System::Windows::Forms::PictureBox * newpb = new System::Windows::Forms::PictureBox();<br />
			newpb->Tag = S"MLR_CTRL";<br />
			newpb->Width = img->width;<br />
			newpb->Height = img->height;<br />
			newpb->BackColor = Color::AliceBlue;<br />
			newpb->Image = Image::FromFile( img->path );<br />
			newpb->SizeMode = img->sizemode;<br />
			/* can we fit image on existing line? */<br />
			if( cx == x ) /* no choice */<br />
			{<br />
imgnochoice:;<br />
				newpb->Location = Point( cx, cy );<br />
			} else {<br />
				if( w - (cx - x) >= img->height ) /* it can fit */<br />
				{<br />
					newpb->Location = Point( cx, cy );<br />
					cx += img->width;<br />
					if( img->height > clh )<br />
						clh = img->height;<br />
				}else{<br />
					/* move down a line */<br />
					cx = x;<br />
					cy = cy + clh;<br />
					goto imgnochoice;<br />
				}<br />
			}<br />
			f->Controls->Add( newpb );<br />
		}<br />
		lnk = lnk->next;<br />
	}<br />
	return true;<br />
}<br />
//<br />
mlr_txt::mlr_txt(void) { }<br />
mlr_txt::~mlr_txt(void) { }<br />
//<br />
mlr_img::mlr_img(void) { }<br />
mlr_img::~mlr_img(void) { }<br />
//<br />
mlr_lb::mlr_lb(void) { }<br />
mlr_lb::~mlr_lb(void) { }<br />


<br />
// The demo/testing code<br />
	private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)<br />
			 {<br />
 				 mlr * m = new mlr();<br />
				 //<br />
				 mlr_txt * txt1 = new mlr_txt();<br />
				 mlr_txt * txt2 = new mlr_txt();<br />
				 mlr_img * img1 = new mlr_img();<br />
				 mlr_lb * lb1 = new mlr_lb();<br />
				 //<br />
				 txt1->font = new Drawing::Font( "Arial", 15 );<br />
				 txt1->color = Color::Red;<br />
				 txt1->txt = S"Hello, my name is kevin. I am writting this long lone for a reason can you guess what the reason is?";<br />
				 m->lnk = new mlr_lnk;<br />
				 m->lnk->obj = txt1;<br />
				 m->lnk->next = new mlr_lnk;<br />
				 //<br />
				 img1->width = 250;<br />
				 img1->height = 250;<br />
				 img1->path = "c:\\b.jpg";<br />
				 img1->sizemode = PictureBoxSizeMode::StretchImage;<br />
				 m->lnk->next->obj = img1;<br />
				 m->lnk->next->next = new mlr_lnk;<br />
				 //<br />
 				 m->lnk->next->next->obj = lb1;<br />
				 m->lnk->next->next->next = new mlr_lnk;<br />
				 //<br />
				 txt2->font = new Drawing::Font( "Arial", 10 );<br />
				 txt2->color = Color::Red;<br />
				 txt2->txt = S"Alright, im just going to start talking about some apples that fell off a tree and landed into a truck then got driven towards the town and a bird pecked one off and fly over the river back to it's next and feed its babys while it watch a hunter track a deer!";<br />
				 m->lnk->next->next->next->obj = txt2;<br />
				 m->lnk->next->next->next->next = NULL;<br />
				 //<br />
				 m->Render( this, this->CreateGraphics(), 10, 10, this->Width - 10, this->Height - 10 );<br />
			 }<br />


Big Grin | :-D
GeneralVSPackage load failure after incorporating PLK Pin
ManSus27-May-04 10:59
ManSus27-May-04 10:59 
GeneralAbout a graph algorithm! It is very diffcult , I think! Pin
ymq832827-May-04 0:09
ymq832827-May-04 0:09 
GeneralRe: About a graph algorithm! It is very diffcult , I think! Pin
Curi0us_George27-May-04 19:52
Curi0us_George27-May-04 19:52 
Generalsocket Pin
Ni@m26-May-04 23:42
Ni@m26-May-04 23:42 
GeneralRe: socket Pin
toxcct27-May-04 23:43
toxcct27-May-04 23:43 
GeneralRe: socket Pin
kmcguire28-May-04 3:35
kmcguire28-May-04 3:35 
GeneralRe: socket Pin
neurorebel6-Jun-04 22:11
neurorebel6-Jun-04 22:11 
Generalconsole timer Pin
nikoladsp26-May-04 23:03
nikoladsp26-May-04 23:03 
GeneralThe VC++ 2003 Toolkit Pin
--BoB--25-May-04 18:23
suss--BoB--25-May-04 18:23 
GeneralCall proc inside namespace from outside the namespace Pin
Member 62566624-May-04 8:41
Member 62566624-May-04 8:41 
GeneralRe: Call proc inside namespace from outside the namespace Pin
kmcguire30-May-04 17:28
kmcguire30-May-04 17:28 
GeneralTaking input while in some form of waiting/sleeping -- plz help Pin
Makutu21-May-04 20:32
Makutu21-May-04 20:32 
GeneralRe: Taking input while in some form of waiting/sleeping -- plz help Pin
Curi0us_George27-May-04 19:19
Curi0us_George27-May-04 19:19 
GeneralRe: Taking input while in some form of waiting/sleeping -- plz help Pin
Makutu2-Jun-04 15:20
Makutu2-Jun-04 15:20 
GeneralRe: Taking input while in some form of waiting/sleeping -- plz help Pin
Curi0us_George3-Jun-04 2:03
Curi0us_George3-Jun-04 2:03 
Generalneed help !! Pin
ormax321-May-04 9:09
sussormax321-May-04 9:09 
GeneralRe: need help !! Pin
kmcguire3-Jun-04 11:41
kmcguire3-Jun-04 11:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.