Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Text Editor
I have posted this in the works forum, so please excuse me for posting it here as well.
I need a editable text field (say-TextBox) on a form where some of the text needs to be formatted - Bold/FontSize/Italics.
The text will also need to be printed as part of a report using OIPI (TABLE)
Can anyone tell me how I can implement this and provide code(where applicable)
OR tell me it cant be done.
I need a editable text field (say-TextBox) on a form where some of the text needs to be formatted - Bold/FontSize/Italics.
The text will also need to be printed as part of a report using OIPI (TABLE)
Can anyone tell me how I can implement this and provide code(where applicable)
OR tell me it cant be done.
Comments
I saw your post there but hadn't the time to respond. There are two ways I've seen this done. The first is to enable RTF mode with the edit box control. The other is to use an ActiveX control that supports formatted text. In OI 10, they are doing this with the new Message and QuickHelp designers via the browser control but switched to edit mode.
In either case, you need to take the formatting used in the control and convert it to OIPI formatting.
But there is no formatting options, and, help says rtfmode for display only
>>The other is to use an ActiveX control that supports formatted text
tried RICHTEXT.RichtextCtrl as per the help, but it is not letting me enter text. The help shows loadfile and savefile buttons, which worries me a bit as I want to save it in the oi record, should you be able to do this.
Is RICHTEXT.RichtextCtrl still 'working' in Windows 10.
>>you need to take the formatting used in the control and convert it to OIPI formatting.
Far beyond what I am capable of!!
I am really after a working example and code.
However, I created an 'edit' window with basically just a rtf editbox and a button that called utility("choosefont")
Click the button and you had to do some smoke and mirrors stuff before making the call though.
The smoke and mirrors looks something like this.
Equ CharFmt_Selection$ to 1 CurrCharFmt = send_message(EB_Text$, 'GETCHARFORMAT', CharFmt_Selection$) CurrFont = empty CurrFont<1,1,1> = CurrCharFmt<7> CurrFont<1,1,2> = CurrCharFmt<2> If CurrCharFmt<1,1> then CurrFont<1,1,3> = 700 end CurrFont<1,1,4> = CurrCharFmt<1,2> CurrFont<1,1,5> = CurrCharFmt<1,3> CurrFont<1,1,7> = CurrCharFmt<5> CurrFont<1,1,8> = CurrCharFmt<6> CurrFont<1,1,9> = CurrCharFmt<1,4> NewFont = Utility('CHOOSEFONT', @Window, CurrFont)
Depending on the actual formatting, the stored data will look something like this.
{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fswiss\fprq2\fcharset0 MS Sans Serif;}}
{\colortbl ;\red255\green0\blue0;\red0\green0\blue0;}
\viewkind4\uc1\pard\ltrpar\cf1\ul\b\f0\fs32 WESLEY ON CALL PROCEDURE:\par
\cf0\ulnone\b0\fs22\par
\cf2\b\fs28 1\super ST\nosupersub : Phone On Call - 0408 255 nnn \par
\par
\cf1\ul If after 15 Mins you have no reply from the 1\super st\nosupersub Call then\par
\cf2\ulnone\par
2\super nd\nosupersub : Phone Back up On Call - 0408 nnn nnn\par
\par
Advise them you have had no response from the 1\super st\nosupersub on call person \par
\cf0\b0\fs22\par
\pard\ltrpar\f1\fs17\par
}
As not all data gets formatted, we have to check for the string "{\rtf" at the beginning of the data. That indicates that the data is formatted and we know whether to set the textval or the rtftext property of the editbox.
All that said, I don't believe that is the last iteration of the code and I'd need to dig to find the real one. It might help get you started though.
If you could dig out the final working code, when you have time, that would be great.
TEXTRTF says specifically that you can including the rtf header, but, ENABLERTF did not, so, was very surprised when it worked.
Yes thank you.
If I stumble across the complete working source, I'll send it to you. I'm pretty sure there wouldn't have been much more to it but I can see in what I've got, that after retrieving the new font, I'm not doing anything with it so there's something missing to complete the picture.
Here's all the font stuff part of it.
/********************************************************************************** * User is displaying the font window to modify appearance. Several conversions * are needed to pass the correct details to the font utility and then again * when the new selections are returned, we need to convert back to values * understood by the setcharformat function. **********************************************************************************/ click.font: // Get and Set Charformat refer to font size as twips. We need to convert this to pixels for passing to the font utility // To do this we need the 'logpixelsy' value from the WinAPI GetDeviceCaps() function. hwnd = GetDC('') logPixelsY = GetDeviceCaps(hwnd, 90) dcRetval = ReleaseDC('', hwnd) // Retrieve the current format of the selected text. CurrCharFmt = send_message(EB_Text$, 'GETCHARFORMAT', CharFmt_Selection$) CurrFont = empty // Fontsize is in twips twipsize = CurrCharFmt<2> // Convert twips to points (which is what the user will see but not what we need to pass in) pointsize = Iconv(twipsize/20, 'MD0') // Convert the points to pixels pixelSize = - int( (pointsize * logPixelsY /72 ) ) // Now define the font structure required to pass into utility choosefont CurrFont<1,1,1> = CurrCharFmt<7> ; // FaceName CurrFont<1,1,2> = pixelSize ; // Height If CurrCharFmt<1,1> then // selected text is bold so make the font weight 700 CurrFont<1,1,3> = 700 ; // Weight end CurrFont<1,1,4> = CurrCharFmt<1,2> ; // Itallic CurrFont<1,1,5> = CurrCharFmt<1,3> ; // Underline CurrFont<1,1,7> = CurrCharFmt<5> ; // CharSet CurrFont<1,1,8> = CurrCharFmt<6> ; // PitchAndFamily CurrFont<1,1,9> = CurrCharFmt<1,4> ; // StrikeOut Colour = CurrCharFmt<4> // Font structure requires the integer to be broken down into the separate RGB components Temp = Colour ;* don't modify the Color value for i = 13 to 15 CurrFont<1, 1, i> = mod(Temp, 256) Temp = int(Temp / 256) next i // Display the font window with the current selected structure NewFont = Utility('CHOOSEFONT', @Window, CurrFont) // If the user clicked 'Ok' then reverse all the conversions back to those required for setcharformat If NewFont then pixelSize = NewFont<1,1,2> pointSize = - int( (pixelSize * 72 / logPixelsY) + 0.5 ) twipsize = pointsize * 20 If Newfont<1,1,3> ge 700 then isbold = true$ end else isbold = false$ end NewColour = rgb(NewFont<1,1,13>, NewFont<1,1,14>, NewFont<1,1,15>) NewCharFmt = '' NewCharFmt<1,1> = isbold NewCharFmt<1,2> = NewFont<1,1,4> NewCharFmt<1,3> = NewFont<1,1,5> NewCharFmt<1,4> = NewFont<1,1,9> NewCharFmt<2> = twipsize NewCharFmt<4> = NewColour NewCharFmt<5> = NewFont<1,1,7> NewCharFmt<6> = NewFont<1,1,8> NewCharFmt<7> = NewFont<1,1,1> // Now apply the new formatting to the selected text Status = send_message(EB_Text$, 'SETCHARFORMAT', CharFmt_Selection$, NewCharFmt) end Return