Lessons Learned(from the Simple HTML Editor)
A Presentation for the
Microsoft Access SIG
of the North Texas PC User Group
by Larry Linson
.© Copyright 2000 by L.M. Linson, all rights reserved
Specifications
Prepare a Microsoft Access database Simple text editor for SIG Leader Allow addition of new records Allow deletion of existing records Allow editing of new and existing records
Specifications
Automate insertion of HTML markup– <P> for paragraph– <BR> for break (new line)– <B> for bold– <I> for italic– <A> for link or anchor
Supply appropriate ending markup
The Plan . . .
Main form allows:– Display– Selection– Addition– Deletion– Editing
Click button for function
The Plan, cont’d
Popup Form for Link– Universal Resource Locator (URL)– Option to open in new Window– Text to be displayed
Anchor markup deferred (not to be done)
Seems Simple Enough . . .
Combo Box for Selection Text Box for Title / Identification Text Box for Date (default to Today) Text Box for HTML Text Buttons for Add, Delete, Close, Markup
Seems Simple Enough, cont’d
Processing markup– when a Markup button is clicked
– use the Text Box .SelStart and .SelLength properties to
– Split the text,
– Insert the beginning markup,» precede by new line if <P> or <B>
– Reinsert highlighted text, if appropriate,
– Insert the ending markup, if appropriate,
– Append the remainder of the original
Seems Simple Enough, cont’d Processing a Link
– When the Link button is clicked
– Open the popup, dialog Form
– Text Box for URL
– Disabled Selection, Text Boxes for Anchor
– Text Box for Display Text
– OK Button
– Cancel Button
Seems Simple Enough, cont’d Processing a Link
– Display the highlighted text in URL Text Box
– Display the highlighted text in Display Text Box» if no text was highlighted, leave both empty
– Allow Cancel
– If OK, create a link of the form<A href=“http://www.abc.com” target = “_new”> Site Name </A>
– where href contains contents of URL Text Box
– “Site Name” is contents of Display Text Box
Seems Simple Enough, cont’d When done with any markup, return the
cursor To the HTML Text Box on the main Form With the originally highlighted text still
highlighted Except, if a Link, with the Display Text
highlighted
Let’s Take a Look
at how the
SIG Leaders HTML Editor
turned out
First Lesson Learned When you move off a TextBox
– Highlighting vanishes– No SelStart– No SelText
Workaround– Save SelStart and SelText in the LostFocus
event
Another Lesson Learned When you store modified text
– Back into the text box– You are back at the beginning – Nothing highlighted
Workaround– Modify the saved SelStart and SelText values
and reset them so the same text is highlighted as before the markup
Side Lesson When you reset the SelStart and SelText
– Highlighted code will be visible– But not where you left it positioned – May be at bottom of box
Workaround– I couldn’t find one
Yet Another Lesson Learned Vanishing highlights
– If the modal popup dialog had been used– Sometimes no SelStart and SelText– Why? I didn’t figure it out!
Workaround– Save SelStart and SelText values in the KeyUp
event instead of Lost Focus
Conclusion
There are some unobvious stumbling blocks There are workarounds for most There are no workarounds for a few You can write an editor in Access BUT There are probably better tools for writing
editors
Thank you
Thank you for your kind attention
Please come again And, please . . .
– Gently wake your neighbor before leaving
Top Related