Results 1 to 20 of 20

Thread: [2008] WYSIWYG - MSHTML Editor Project

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    [2008] WYSIWYG - MSHTML Editor Project

    Hey all,

    Out of necessity, I need to build a ContentAdmin for clients so they can edit restricted html pages using a WYSIWYG editor.
    The only source code I found was for .NET framework 1.0 (VS Studio 2003). Finding one for VB 2005-2008 was non-existant.
    So, I have already hooked up MSHTML.DLL to VB.NET 2008 and have some of the functions working. And so far, it really is easy.
    The hardest part is going to be inserting tables etc...
    I would like to ask for anyones help and then share the basic version with everyone later if it is truly workable.
    I will post changes and updates as to how I am doing.

    WHAT IS MSHTML?
    MSHTML is a dll used by Internet Explorer that allows editing of the html document. You can use the DLL as a WYSWYG editor. It goes beyond the RichTextEditor.

    Last edited by epixelman; Aug 22nd, 2008 at 10:52 PM.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Update...

    I have the following functions working:
    - DesignMode On/Off
    - Save html
    - Bold text
    - Color text
    - Font size
    Last edited by epixelman; Aug 22nd, 2008 at 10:52 PM.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Update... I have added...

    - Italic
    - Underline
    - Font Name
    - Horz Line
    - Align Left - Center - Right
    - Link
    - Insert image

    All works 1 to 3 lines of code each.

    Now the hard part... the Table
    Any ideas?


  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Hmmm...
    After researching about inserting tables. In the past you could use the DHTML.OCX and TREDIT.DLL controls. And this would allow inserting of tables fairly easily.

    However.... those controls are not being provided in Vista, and the OS (for security reasons) will balk at them.

    Read this... http://msdn.microsoft.com/en-us/library/aa663363.aspx

    So... I haven't found out how to insert tables using MSHTML.DLL yet.


  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Well...
    I found a C# version of a control that has "inserting of tables"

    However, I want to do this in VB

    I am getting an erro trying to call MSHTML directly...

    Code:
            Try
                Dim myTableObj As Object
                mshtml.IHTMLTable(myTableObj) = (mshtml.IHTMLTable,WebB.Document.createElement("table"));
            Catch ex As Exception
    
            End Try
    2nd line is error.
    "mshtml.ihtml is a type and can not be used as an expression.

    I am missing something.


  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    I am kind of stuck.

    I have the correct reference.
    I can see the events in the ObjBrowser

    But I can not seem to find out how to get it to do what I want.

    Any experience MSHTML users out there?

    Last edited by epixelman; Aug 23rd, 2008 at 08:34 PM.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Well... I found a bad work around to insert tables.

    I created a form with a Browser on it.
    I load an html file of a table (this would be a template)
    I then use SendKeys to copy the table in EditMode then paste into the main browser window.

    This is not how I want to do it, but it works.

    Also, there is no setting rows-cols etc. They are already made htm file.
    So, to use as a template system, I would need quite of few different layouts.

    And... If I want a table with no border being visible. It is like that in the main browser. So I would have to figure out a way to turn the border on when in design mode, then off when EditMode is off.

    I knew this would be hard.


  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    I think it is time to show everyone what I have so far.

    Name:  htmleditor01.jpg
Views: 2354
Size:  196.4 KB


    Q: How do I keep the below box from displaying after I make changes to the html file?

    Name:  htmleditor02.jpg
Views: 1386
Size:  39.2 KB


  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    I kind of got around the save box. I don't think it is completely fool proof depending on how you use it.

    Code:
    'we have to have this to avoid the "save changes" dialog in a browser.
    WebB.Document.Write(String.Empty)
    
    'save html file
    Dim sw As StreamWriter = New StreamWriter(HtmlFile)
    
    'save text box
    sw.Write(txtHtml.Text)
    
    'close file
    sw.Close()
    
    'refresh browser page
    WebB.Navigate(HtmlFile)
    I am sure there has to be a better way to disable that in the browser. Maybe it is a setting on IE

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Kliemna
    I downloaded your sample and got some tips.

    But, I have a couple questions.

    1) How do I get and replace tags (with accompaning html code)

    2) Is there a way I can double-click on tables and load the tag/code and make changes and send back to the document.

    Last edited by epixelman; Aug 24th, 2008 at 07:36 PM.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Also, I have spent roughly 4 hours scouring MSDN on inserting tables. And I still can not seem to get it to insert directly without having to use my work around.

    I need an experience pro!!


  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Kliemna, you our there?


  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Kliemna,

    I seen you were here today.
    Can you reply?


  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    I know this is a tough one... isn't it?


  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Where are you Kliemna?


  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Well... it looks like no one has any input.

    Does anyone want to put the sample app (picture above) in the code bank as it is?

    The inserting of tables works, but not the right way that it should be done.


  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Hmmm.... Looks like this is a dead thread. No one is replying. I guess no one is interested.


  18. #18
    New Member
    Join Date
    Apr 2008
    Posts
    10

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Hi, I'm fairly new to .net (I'm a small time vb6 coder who finally made the switch )

    I've just started to code something similar but haven't got much so far. I was wondering if you might be posting your source for us to take a look at?
    I'm trying to code a wysiwyg editor for a web based platform rather than a web design app.

    I was also wondering if this stuff can be used to code/view xhtml an stuff as it seems it can only do html.

    It seems like you've been talking to yourself quite a bit in this thread sorry i can't help.

  19. #19
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2008] WYSIWYG - MSHTML Editor Project

    did you ever solve this? I don't think I ever looked at this thread before, and I randomly came across it today...

  20. #20
    New Member
    Join Date
    Apr 2008
    Posts
    10

    Re: [2008] WYSIWYG - MSHTML Editor Project

    Hey kleinma,

    I'm still here

    I've not worked on my editor project for a while as I've been busy with work.

    while googling I didn't find out much and sort of got the impression I was barking up the wrong tree with mshtml.
    I'm trying to build an app similar to a lite version of expression web or dreamweaver where you can edit code or design. I also need it to be able to handle different code like dhtml and xhtml and stuff.

    You have any ideas on how to start a project like this? Is there an api or something?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width