Page 1 of 1 1
Topic Options
#206731 - 2013-02-19 02:10 PM RichTextBox.html not working correctly?
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
I'm currently working on a small script that uses Kixforms to present the gui. I use a RichtTextBox object to be able to do some formatting of the text (bold, line breaks).

I am able to load html code into the object via RichTextBox.html, but when I add some additional text, RichTextBox.html doesn't return the actual content of the RichtTextBox, but RichTextBox.text shows the correct text. Is this an error or am I missing something?

 Code:
Break On
Dim $Ret, $System, $TestForm, $cmd
$Ret = SetOption("explicit", "on")
$TestForm = CreateObject("Kixtart.Form")
If @ERROR
  $cmd = 'msiexec /i "' + @SCRIPTDIR + '\KiXforms.msi" /qb /norestart'
  Shell $Cmd
EndIf
$System = CreateObject("KiXtart.System")
Dim $Form1
$Form1 = $System.Form()
$Form1.Text = "Test"
Dim $RichTextBox1
$RichTextBox1 = $Form1.Controls.RichTextBox()
$RichTextBox1.Location = 13, 13
$RichTextBox1.Size = 259, 195

Dim $Button1
$Button1 = $Form1.Controls.Button()
$Button1.Text = "Done"
$Button1.Size = 75, 23
$Button1.Location = 96, 227
$Button1.OnClick = "onDone($$Form1, $$RichTextBox1)"

$RichTextBox1.html = "This is an example test. <Br><Br><Br>Text you add here is not shown via .html, but via .text, try it!<p> An example of <b>BoldText</b></p>"

Dim $Null
$Form1.Show
While $Form1.Visible
	$Null=Execute($System.Application.DoEvents)
Loop

Function onDone($Form1, $RichTextBox1)
  Dim $Ret
  $Ret = MessageBox($RichTextBox1.html, "HTML code is", 16)
  $Ret = MessageBox($RichTextBox1.text, "Text code is", 16)
  $Form1.visible = false
EndFunction

Top
#206732 - 2013-02-19 03:35 PM Re: RichTextBox.html not working correctly? [Re: Sam_B]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4400
Loc: New Jersey
Sam,

Not sure what you're seeing but when I run the code (only deleting the If @ERROR block as I don't have an MSI to invoke) I don't see the issue. The first window displays the text just as I'd expect, with a line, 3 blank lines, 2 lines, a paragraph break, and text with some bold.

Clicking DONE shows the HTML popup, with the HTM code just as it is in the script. OK again and just the text displays WITH the extra blank lines but without any bold formatting - as expected. Also, no distinction between break and paragraph spacing in text mode, also as expected.

What version of KixForms are you running? I have 2.47.5 here.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#206738 - 2013-02-20 05:58 AM Re: RichTextBox.html not working correctly? [Re: Glenn Barnas]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Glenn, I think he is wanting to be able to type into the rich text box and the entered text to be included with the .html property when it is later retrieved, as it is in the .text property. If you type additional text into the test script and click Done, the entered text shows up in the 2nd messagebox, but not in the first.

Not sure that it's feasible though, or why it would be useful.

Top
#206739 - 2013-02-20 08:21 AM Re: RichTextBox.html not working correctly? [Re: ShaneEP]
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
Hi Shane,

the idea behind my script is to enable a user to select some template text from a list and then add some specific details. The template text is read from a ini file. To not loose the formatting, it would be nice to get the content of the rich text box with the .html property to later use it in the body of a mail message.

Top
#206744 - 2013-02-20 07:41 PM Re: RichTextBox.html not working correctly? [Re: Sam_B]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I see. It appears that the .html property is probably not going to work for you, and since the development of kixforms is at a stand still for the foreseeable future, I think it would be best to start thinking of other methods.

Perhaps create a series of different forms that are shown depending on which options is selected from the list using text boxes, labels, and so forth. Then take the information that is entered into this form and format at you would like into html?

You can also save the modified richtext as a rtf file that could maybe be read and inserted into an email? Probably depends on the email client.

Top
#206755 - 2013-02-22 03:19 PM Re: RichTextBox.html not working correctly? [Re: ShaneEP]
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
Thanks Shane for your feedback, I fully agree with your outcome, I'll implement it differently.
Top
#206756 - 2013-02-22 04:31 PM Re: RichTextBox.html not working correctly? [Re: Sam_B]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
No problem. Sorry couldn't help more. It is odd that inserted text is formatted to match the HTML, but is not included with the .HTML property. Perhaps Shawn the kixforms developer will happen upon this thread and shed some light, but unfortunately the genius doesn't come around too much these days.
Top
#206761 - 2013-02-23 03:10 AM Re: RichTextBox.html not working correctly? [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think the problem is that richtextbox does not support html natively.
at least in .net

rtf is the actual format to use to get the rich content in and out.
_________________________
!

download KiXnet

Top
#206762 - 2013-02-23 03:17 AM Re: RichTextBox.html not working correctly? [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I think Shawn designed it to simply parse out some of the simpler html tags which are then applied using the RTF formatting options.
I can see how it would be a nightmare to try to reformat the RTF back into html to get it back out again.

 Quote:
Kixforms scans the HTML document and ignores most of the tags (the ones that
it does not understand). It picks out a few of them and uses them as formatting codes.
Some tag attributes and even a few style attributes are supported.

Top
#206763 - 2013-02-23 06:16 AM Re: RichTextBox.html not working correctly? [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
nightmare? I thought rtf was a simple format...
_________________________
!

download KiXnet

Top
#206771 - 2013-02-23 08:17 PM Re: RichTextBox.html not working correctly? [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Here is a rough work around that might work for you...IF the machines that run the forms have MS Word installed. It essentially saves the edited richtextbox text to a rtf, then uses Word in the background to convert it to html.

 Code:
Break On
Dim $Ret, $System, $TestForm, $cmd
$Ret = SetOption("explicit", "on")
$TestForm = CreateObject("Kixtart.Form")
If @ERROR
  $cmd = 'msiexec /i "' + @SCRIPTDIR + '\KiXforms.msi" /qb /norestart'
  Shell $Cmd
EndIf
$System = CreateObject("KiXtart.System")
Dim $Form1
$Form1 = $System.Form()
$Form1.Text = "Test"
Dim $RichTextBox1
$RichTextBox1 = $Form1.Controls.RichTextBox()
$RichTextBox1.Location = 13, 13
$RichTextBox1.Size = 259, 195

Dim $Button1
$Button1 = $Form1.Controls.Button()
$Button1.Text = "Done"
$Button1.Size = 75, 23
$Button1.Location = 96, 227
$Button1.OnClick = "onDone($$Form1, $$RichTextBox1)"

$RichTextBox1.html = "This is an example test. <Br><Br><Br>Text you add here is not shown via .html, but via .text, try it!<p> An example of <b>BoldText</b></p>"

Dim $Null
$Form1.Show
While $Form1.Visible
	$Null=Execute($System.Application.DoEvents)
Loop

Function onDone($Form1,$RichTextBox)
   Dim $html,$nul
   $html = RTFBoxHTML($RichTextBox)
   $nul = MessageBox($html,"HTML",0)
   $Form1.visible = 0
EndFunction

Function RTFBoxHTML($RichTextBox)
   Dim $rtffile,$htmlfile,$nul,$word,$doc,$fso
   $rtffile = "%temp%\"+@Ticks+".rtf"
   $htmlfile = "%temp%\"+@Ticks+".html"
   $nul = Execute('$$RichTextBox.SaveFile($$rtffile)')
   $word = CreateObject("Word.Application")
   $doc = $word.Documents.Open($rtffile)
   $doc = $word.ActiveDocument()
   $doc.SaveAs($htmlfile, 10)
   $doc.Close()
   $word.Quit()
   $fso = CreateObject("Scripting.FileSystemObject").GetFile($htmlfile)
   $RTFBoxHTML = $fso.OpenAsTextStream(1,-2).Read($fso.size)
   Del $rtffile
   del $htmlfile
EndFunction

Top
#206788 - 2013-02-25 10:24 AM Re: RichTextBox.html not working correctly? [Re: ShaneEP]
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
This sounds interesting, thanks Shane, I'll try this!
Top
#206789 - 2013-02-25 11:04 AM Re: RichTextBox.html not working correctly? [Re: Sam_B]
It_took_my_meds Offline
Hey THIS is FUN
*****

Registered: 2003-05-07
Posts: 273
Loc: Sydney, Australia
I can vouch for the EasyByte RTF to HTML COM object. It's not free but it works really well.
Top
#206799 - 2013-02-25 05:57 PM Re: RichTextBox.html not working correctly? [Re: It_took_my_meds]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
In theory it would be possible to write a native rtf to html converter in kix. But it would require more time than i have at the moment.
Top
#206836 - 2013-03-01 01:43 AM Re: RichTextBox.html not working correctly? [Re: ShaneEP]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
The RichTextBox method was meant to be a "write-only" value. Bascially meant to be a more "intuitive" way to get RTF formatting without having to specify RTF codes which if memory serves, is a god-awfull thing to even read much less understand.

Shane said "I think Shawn designed it to simply parse out some of the simpler html tags which are then applied using the RTF formatting options.". That's exactly how it works. The "HTML" is lost once applied. Well, not really "lost" but there is no RTF back to HTML logic.




Top
#206837 - 2013-03-01 01:59 AM Re: RichTextBox.html not working correctly? [Re: Shawn]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Thanks for stopping by with the info Shawn. Nice to still see you post from time to time!
Top
#206838 - 2013-03-01 04:25 AM Re: RichTextBox.html not working correctly? [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
nice to see you are still alive, old fart.
_________________________
!

download KiXnet

Top
#206850 - 2013-03-02 03:22 AM Re: RichTextBox.html not working correctly? [Re: Lonkero]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
ROFL - Here I thought I was going to have to revoke his forum drivers license
Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 323 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.065 seconds in which 0.022 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org