News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

DrawTextEXT - DrawHTMLCODE and DrawBBCODE

Started by fearless, August 26, 2018, 04:36:54 AM

Previous topic - Next topic

fearless

I done some work in porting over, adapting and adding to DrawHTML code from Ukkie9: https://www.codeproject.com/Articles/7936/DrawHTML

Added a few more tags and made the color and list stacks local to the DrawHTMLCODE functions. The stack functions where made for future use that if the functions are used in more than one custom control for example, each control will have its own stack and not a global one as in the original article and code. And for adapting it to x64 code later on.

I plan to rejig what I have done currently to add it into the ModernUI stuff, most likely the ModernUI_Text control, but maybe others, havent decided that exactly yet. A lot of the variables and stacks would be stored as properties (internal to the control or external) once i made the conversion.

Also similarly a DrawBBCODE function will handle bbcode tags - but thats work in progress.

One tag, the hyperlink one <a href="url">title</a> is incomplete in the DrawHTMLCODE function, it just displays the title in blue color and underlined. Ive yet to decide how to handle this, although I have some todo notes in the code regarding using a control placed where the text would be (and not drawing the text underneath), and i was also playing around with an invisible window (doesnt paint itself, but responds to mousemove and clicks etc) in another test project that rests over the url link title text and is in effect transparent, but the cursor changes to hand etc. But might as well do the whole thing instead of an invisible window.

Anyhow the initial release and demo is available on github: https://github.com/mrfearless/DrawTextEXT



Colors and fonts for quote and code/pre tags can be changed. I just put some stuff together for testing mainly. Im sure that there is probably edge cases where something doesnt show correctly or renders on the wrong line or suchlike. Anyhow hopefully its useful for someone else as well.

fearless

Initial version of DrawBBCODE is now included. Tests for lists and listitems hasn't been done yet, but the rest seems to work ok.

fearless

Have most of the tags I wanted to support in the code now and done some more testing with both functions, along with hyperlinks <a> for html and url (surrounded by square brackets) for bbcode. And the hyperlinks work with internal ids, so you can specify a url with #112 and it will pass that id (converted from string to integer) to the parent via WM_COMMAND.

Biterider


fearless

Thanks.

The hyperlink tags where the most awkward to add in, had to create a custom control for them that and add small combined regions for each of them that sits over the text displayed, so that the mouseover, cursor changes to hand etc would work. Might be a better way of doing it, and initially I couldnt think of any way to do it inside the routines, but lying in bed trying to sleep one night I came up with the current solution.



jj2007


fearless

Thanks JJ,
I hope to add in this to my ModernUI_Text control - along with wide unicode support and possibly the UTF8 stuff as well (based on info from the other threads about that stuff recently)