Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. HTML edit and view control.

HTML edit and view control.

Scheduled Pinned Locked Moved Managed C++/CLI
c++graphicshelpcsharphtml
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kmcguire
    wrote on last edited by
    #1

    Hello, and thanks for reading my post hopefully you can help me. :(( My problem is i need code or a control that is native with low-overhead using Microsoft Visual C++ .NET that allows a user to add images and text. Exactly like a wordpad, however, it needs to also be able to display (and edit). It seems quite simple but i need to display HTML code. I took a look at the RichTextBox control and choked, it seemed to have a complicated format for storeing the images and text formatting.. I was hopeing to be able to write a function that takes a argument of HTML code and convert this into some cordinates for the text and images (supporting only basic HTML) and use the System::Drawing2D to draw the text but i run into a problem. I can not figure out a way to tell how long in pixels or whatever how long the string will be when it is written out onto the picturebox or form. Graphics * g = this->CreateGraphics(); g->DrawString( ... blah .. blah , 10, 10 ); No, way i can know where to start drawing my image if for instance i had something like. "blah blah blah [img src=...]" :(( btw: This is for the compose form of my mail application. So user can write their email, insert images, and view emails.

    K 1 Reply Last reply
    0
    • K kmcguire

      Hello, and thanks for reading my post hopefully you can help me. :(( My problem is i need code or a control that is native with low-overhead using Microsoft Visual C++ .NET that allows a user to add images and text. Exactly like a wordpad, however, it needs to also be able to display (and edit). It seems quite simple but i need to display HTML code. I took a look at the RichTextBox control and choked, it seemed to have a complicated format for storeing the images and text formatting.. I was hopeing to be able to write a function that takes a argument of HTML code and convert this into some cordinates for the text and images (supporting only basic HTML) and use the System::Drawing2D to draw the text but i run into a problem. I can not figure out a way to tell how long in pixels or whatever how long the string will be when it is written out onto the picturebox or form. Graphics * g = this->CreateGraphics(); g->DrawString( ... blah .. blah , 10, 10 ); No, way i can know where to start drawing my image if for instance i had something like. "blah blah blah [img src=...]" :(( btw: This is for the compose form of my mail application. So user can write their email, insert images, and view emails.

      K Offline
      K Offline
      kmcguire
      wrote on last edited by
      #2

      nm; I figured out how to do it. Using label and picture box controls. :-) 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. ---------------------------------------------------------------------------- // The header #pragma once using namespace System; using namespace System::Drawing; using namespace System::Drawing::Drawing2D; using namespace System::Windows::Forms; __gc class mlr_lb { public: mlr_lb(); ~mlr_lb(); }; __gc class mlr_txt { public: mlr_txt(); ~mlr_txt(); Drawing::Color color; Drawing::Font * font; String * txt; }; __gc class mlr_img { public: mlr_img(); ~mlr_img(); PictureBoxSizeMode sizemode; String * path; Int32 width; Int32 height; }; __gc struct mlr_lnk { Object * obj; mlr_lnk * next; }; __gc class mlr { public: mlr(void); ~mlr(void); Int32 x; Int32 y; mlr_lnk * lnk; Boolean RemovePrevCtrls( Form * f ); Boolean Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h ); }; // The source. #include "StdAfx.h" #include ".\mlr.h" #using String * JoinStrAr( String * s[], Int32 x, Int32 l, String * d ) { String * str = S""; for( Int32 index = x; index < x+l; index++ ) { str = S""->Concat( str->Trim(), d, s[index]->Trim(), d); } if(str->Length < 1) return str; return str->Substring( 0, str->Length - d->Length ); } String * MakeWidthFit( String * s, System::Windows::Forms::Label * l, Int32 w ) { l->Text = s; if( l->Width > w ) { String * ls[] = s->Trim()->Split( S" "->ToCharArray() ); for( Int32 index = ls->Length; index > -1; index-- ) { l->Text = JoinStrAr( ls, 0, index, " " )->Trim(); if( l->Width <= w ) { return JoinStrAr( ls, index, ls->Count - index, " " ); } } return s; /* it's just a long long line. :-) */ } return NULL; } // mlr::mlr(void) { } mlr::~mlr(void) { } Boolean mlr::RemovePrevCtrls( Form * f ) { Int32 cnt; start:; cnt = f->Controls->Count; for( Int32 index = 1; index < cnt; index++ ) if( f->Controls->get_Item( index )->Tag->ToString()->CompareTo( S"MLR_CTRL" ) == 0 ) { f->Controls->RemoveAt( index ); goto start; } return true; } Boolean mlr::Render( Form * f, Graphics * g, Int32 x, Int32 y, Int32 w, Int32 h ) { String * str; Int32 cx = x; Int32 cy

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups