June 13, 2024, 01:07:35 AM


Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........

Wysiwyg html help editor

Started by sapero, December 17, 2008, 03:37:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


December 17, 2008, 03:37:37 PM Last Edit: January 11, 2009, 01:27:59 PM by sapero
This project is targeted for creating documentations in html format. It uses the DHTML Edit Control for IE5 control hosted by ATL.
I have already a template file, working editor with MDI and have implemented basic set of editing and formatting commands. There is also a raw html editor based on scintilla control (view source only, yet).

I have some questions, maybe someone previously was using the html edit control:
1. How to open a document without user interface? If I set vPrompt to false, this method will fail:V_BSTR(&vPath, L"somedir\\Template.htm");
hr = g_dedit->LoadDocument(&vPath, &vPrompt);
If vPrompt is false, vPath is the path to initialize file path and name in file-open box. Sure, I can use other ways to open it, like document.URL.

2. In Format menu you can set what tag will be used on pressing Enter key. The BR tag you can choose anytime because it is handled in my message loop - when detected, a \n is pasted. But to switch between P and DIV, you need to open new document. The put_UseDivOnCarriageReturn is working only before the control is visible (before attaching it to ATL window).

3. CreateBookmark command seems to not work. It is executed in "case 123" in main.src, OnCommand function (toolbar button with anchor icon). SysAllocStrng for command name does not help.
Added PasteHtml function.

4. What color palette should I use for font color?
5. How to check if the document has been modified? (without comparing html code with local file, or caching a html-hash)
   Solved in version 1.9 - keep track of IOleUndoUnit interface returned from document.IServiceProvider.IOleUndoManager.EnumUndoable.Next


Excellent work Sapero... :)
I allways want make something similiar, but my knowlege is small for such a thing...


That's really great stuff.
i'll definitly use it to write my html pages.

Peter B.


Ok, I have progressed.
Changes from v3 to v6:

  • Settings.xml added. This file is only read, but you can manually change some settings like start with maximized window, reopen html files, initialize the htmledit control, change lexer styles or html templates.
  • Recent file list with maximum of 999 items.
  • ColorPicker is finished, but 'More Colors' button fires the default system color picker.
  • Font size bug fixed, the range is one based, not zero.
  • On statusbar you'll see the current html element tag, and all parent tags up to <HTML> (primitive drawing).
  • Separate context menu without undo and redo commands.
  • The Insert/syntax,parameters menu commands are now working, appended html is read from settings.xml
  • Added option to always use BR when pressing Enter key if the caret is inside PRE tag.
  • Insert table displays a dialog where you can set the number of columns, rows, and enter attributes for table and cells (styles too).
There are still many things to do, I'm trying to create second Frontpage insted focusing on small, template based help maker.


Quote from: sapero on December 20, 2008, 04:32:30 PM
There are still many things to do, I'm trying to create second Frontpage insted focusing on small, template based help maker.

Just do it !
As long as you have great fun doing it  ;)

Peter B.


Fantastic work, sapero. Your knowledge and your energy to create all these marvels is incredible and is only dwarfed in comparison with your generosity in sharing them with us. Thank you.



December 26, 2008, 11:23:27 PM #6 Last Edit: December 26, 2008, 11:35:58 PM by sapero
I've uploaded next release. Added tab control, simple project manager, three table templates, and many other I do not remember. Html source editor has folding option, css and javascript editor is now styled.
From context menu you can turn on/off the tooltip for parameters in Syntax area, add a link to local file and add/remove a row from table, and insert file into project.
If you doubleclick a word in the dhtml editor, the leading space(s) will be removed from selection.
Single click inside scintilla with Control key pressed will select whole word.

The two included xml files are used as templates. settings.xml will be copied to \Documents and Settings\username\Application Data\ChmMaker, and the project.xml to directory where you create new project.

I have changed also the existing templates - changed BLOCKQUOTE and P tags to simple DIV.


Fantastic work... :)
I must say that my next help for ABasic will be written in CHM Maker.
Thanks again Sapero on Excellent software!
Here you can find testing chm , wich is compiled with Vistanita CHM.
all best


Version 1.1 is out.

Added drag-drop in project window (and a splitter to resize it). Finished option "Add existing items" from project context menu, so you can select multiple files at once and add it to project.
Added tab control with auto-hide option. It will hide if there is no window open.
Added syntax colorizing for Aurora and Ebasic - right click on the html window in 'example code' area and select Paste Aurora/Ebasic code.
From now, if you paste text with unsafe characters ( < > & ), it will be handled correctly, even tabs and newline's are pasted. All this is handled in paste.src.
To paste a tab or newline I have used a SPAN tag with inner text set to n (new line) or t (tab). After pasting the formated html, _ReplaceSpanWithTab function is called where SPAN's are manipulated with DOMNode methods (span node is replaced with span.child.text).

The XML class has been extended - added CopyTo, MoveTo, EnumNodesByName.
The local settings.xml has been updated (ebasic keywords added), please copy it to profile directory CSIDL_APPDATA\ChmMaker\.

A bug inside documentRepairLinks has been fixed - SafeArrayDestroy was called with invalid VARIANT (after SysFreeString). Crashed today while saving a huge file.
Please report any missing keyword.

Note, the colorizing processor uses different css classes to difference a keyword, comment, variable, string or ID - a short "FONT CLASS=k" is used for keywords...
If you copy a chunk of code from your IDE and paste it to chmmaker with CTRL+V, ony the formatting without colors will be applied.


Uploaded again with fixed pasting - ctrl+V will paste even HTML is available, shift+ctrl+V will paste text only with formatted tabs.
Updated tokenizer and the colorizer, Tab key will switch between windows, and the project category folders have a dialog with simple properties.
Setings.xml again updated - added asm keywords. The keywords from <Lexer> nodes are saved as sorted after using them.


January 04, 2009, 04:16:33 PM #10 Last Edit: January 05, 2009, 01:33:18 PM by sapero
Next version uploaded - 1.5
* Added (floating always) properties editor for html elements. You cannot currently change inline styles because both methods in OnPropertyChange (properties.src) are failing to set style attribute. If a element has attribute with default set of values (like align=left|top|bottom) the list will be available in listbox. For elements with SRC attribute there will be a file-open dialog. Doubleclick on attribute value will allow to edit the attribute directly.
IHTMLElement::setAttribute never fails, but does nothing for 'style'.
IHTMLDOMAttribute::put_nodeValue fails for 'style'.
IHTMLDOMAttribute2::put_value fails for 'style'.

* Save As will always save to file.
* Richedit (as alternative for scintilla) is finished, smoth scrolling has been disabled for mouse wheel.
* Added option to add and remove a column from table.
* Highlighting menu items will display a short help in status bar.
* Tab control has its own context menu.
* Changed the GetRelativePath() function to use PathRelativePathTo() from shlwapi.dll
* Find Text is now working for any document type.
* Added tools menu with single option to register application for html/js/css files in explorer context menu "Open With" popup. For details see in main.src menuRegisterOpenWith().

Added direct command line support. If you are not an advanced Windows user, or do not know how to use winstartup.o, before compiling the sources please remove parameters from main().

Version 1.6
* will launch much faster because all recent documents are loaded in the background.
* The option from tools menu registers also this program as optional html editor for IE (edit button on the toolbar). This is done in the second call to RegCreateKeyEx in menuRegisterOpenWith function.
* Project context menu has additional "Shell" popup with default explorer menu items (see in projectInitShellMenu, projectHandleMessage).


January 10, 2009, 12:32:22 PM #11 Last Edit: January 15, 2009, 12:25:29 PM by sapero
Next version uploaded - 1.8

* Finally found a way to paste formatted source code in less than on second (when talking about pasting main.src) without losing the undo buffer and whole document reloading. Previous versions needed 18 seconds to do it. Now there are no additional SPAN tags for spaces/tabs/br's but simpler, three unused characters: one for tab, one for new line, and another for space.
After formatting the html code, the html string is scanned for three unused characters, starting from 255 (function EncodeSpecialCharacters in paste.src). Then all tabs are replaced with first found characters, alll spaces with second, and all new lines with third unused characters. So formatted html is pasted into temporary DIV element, and a call to DecodeSpecialCharacters restores tabs and spaces back.
I have posted on another coders forum (with students and advanced coders only) to get help, but nobody was familiar with IE internals!

You may notice additional spaces on the left margin after pasting multiline code with tabs. This is a display-only bug in mshtml, if you view source or save the document, all the spaces will disappear. If you switch to preview mode, the pasted code will be clean also.

* To undo the latest paste you need to click Undo only once, instead n-times (n=number of additional SPANs in previous version). Search for BeginUndoUnit in
AppendColorizedText function.
* Fixed styles editing in property window. Had to directly call to IHTMLStyles::get/put_cssText.

More updates described in whatsnew.txt
All previous and new versions - thanks for downloading!


You are amazing, sapero. :)

This is turning into a really useful application. Thank you very much for sharing.