![]() |
![]() |
|
![]() |
Changing Formatted Memo Field Font Attributes © 2001 Mark Bannister Explanation Here's a sample of how to change a memo field's font attributes dynamically. Changing a field's attributes is about the closest thing you will get in Paradox to writing macros. That is because you use action commands to modify the selection and to move the cursor to the appropriate position. You must understand what the selection of a text object is. The selected text of an object is that text which is hilighted. You can modify the selection in ObjectPAL with the action select commands (i.e., SelectRight, SelectLeft, SelectBeginLine, etc). When you apply formatting commands to a text object they are applied to the selected text only (if there is any), or they are applied to new text from that point forward. You may also change the value of the selection. Thus if the text hilighted is "HELLO" and your ObjectPAL statements says, HelpFld.SelectedText="PIG" , the "HELLO" will be replaced by "PIG".Besides the ActionSelectCommands you need to know how to move around in a field. Use the ActionMoveCommands to put the cursor in the appropriate position. After moving to the appropriate point and selecting any text required you will use the field’s properties (color, font.color, font.style, etc.) to alter the appearance of the field contents. Because you are using the actions commands, the best way to see how everything works is to use the tracer and step through the code below and watch what happens. To use the code, create a blank form with a field object named HelpFld. Create a button, and in the pushButton method, paste the code. Sample Code ;HelpFld is the name of a field ui object on the form. ;you have to have focus!!!!!!!! HelpFld.moveto() If not HelpFld.focus then MsgStop("YIPE","No focus!") return endif ;you MUST be in memo view HelpFld.action(EditEnterMemoView) ;inserts a blank line HelpFld.action(EditInsertLine) ;select one character right HelpFld.action(SelectRight) { End of line in this case, you have essentially selected a blank} ;changes selection from blank to "Title Line" HelpFld.SelectedText = "Title Line" { and stays selected. This is important. You can change the selected text (which in this case was just a blank) and after you do it stays selected.... so... the following styles get applied only to the selected text!!!!! } ;property of field HelpFld.alignment = "Center" ;change to bold HelpFld.font.style = FontAttribBold HelpFld.font.color = DarkGreen { all the above were only applied to the selection } ;"unselects" HelpFld.action(moveEnd) { moveing without selecting cancels any selected text. HelpFld.SelectedText will now = "" } ; put in a blank line HelpFld.action(EditInsertLine) HelpFld.action(EditInsertLine) ;create a valid selection HelpFld.action(SelectRight) HelpFld.SelectedText = "This is the text in the body\n"+ "And this is more body text" { above will replace the selection with the text and it will remain selected} ;these are applied to the selection HelpFld.font.style = FontAttribNormal HelpFld.font.color = Black ;removes selection HelpFld.action(MoveEnd) ;insert some space HelpFld.action(EditInsertLine) HelpFld.action(EditInsertLine) HelpFld.action(MoveEndLine) { Here is an alternative. There is no selection but the cursor pos is at the end of the line. Now any attributes will be active from now on until we change... not just for the selection } HelpFld.font.color = DarkRed HelpFld.font.style = FontAttribBold ;now select a blank to replace HelpFld.action(SelectRight) ;replace it HelpFld.SelectedText = "This is DarkRed!" ;change alignment while selected HelpFld.alignment = "Right" HelpFld.action(MoveEnd) HelpFld.action(EditInsertLine) HelpFld.action(SelectRight) HelpFld.SelectedText = "Very Last Line" ;can you guess what formatting I will have? Discussion of this article |
![]() Feedback | Paradox Day | Who Uses Paradox | I Use Paradox | Downloads ![]() |
|
![]() The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation. Paradox is a registered trademark of Corel Corporation. ![]() |
|
![]() Modified: 15 May 2003 Terms of Use / Legal Disclaimer ![]() |
![]() Copyright © 2001- 2003 Paradox Community. All rights reserved. Company and product names are trademarks or registered trademarks of their respective companies. Authors hold the copyrights to their own works. Please contact the author of any article for details. ![]() |
![]() |
|