| 1 | ; Test program for setting superscripts in a Rich Edit control
|
|---|
| 2 | #include <GUIConstantsEx.au3>
|
|---|
| 3 | #include <GuiRichEdit.au3>
|
|---|
| 4 | Local $hGui, $hRichEdit, $hEdit, $hBtnDoit, $hBtnExit
|
|---|
| 5 | Local $iPtr, $Char, $Length
|
|---|
| 6 | $hGui = GUICreate ("Superscript bug demo", 400, 300)
|
|---|
| 7 | $hRichEdit = _GUICtrlRichEdit_Create ($hGui, "x + x2 + x3 + x4 + x5", 25, 25, 350, 75)
|
|---|
| 8 | _GUICtrlRichEdit_SetSel ($hRichEdit, 0, -1)
|
|---|
| 9 | _GUICtrlRichEdit_SetFont($hRichEdit, 15, "Times New Roman")
|
|---|
| 10 | _GUICtrlRichEdit_SetSel ($hRichEdit, 0, 0)
|
|---|
| 11 | $Length = _GUICtrlRichEdit_GetTextLength ($hRichEdit)
|
|---|
| 12 | $hEdit = GUICtrlCreateEdit ("", 25, 125, 350, 100, $ES_MULTILINE + $ES_READONLY)
|
|---|
| 13 | $hBtnDoit = GUICtrlCreateButton ("Do It", 125, 250, 50, 25)
|
|---|
| 14 | $hBtnExit = GUICtrlCreateButton ("Exit", 250, 250, 50, 25)
|
|---|
| 15 | GUISetState(@SW_SHOW, $hGUI)
|
|---|
| 16 |
|
|---|
| 17 | While 1
|
|---|
| 18 | Switch GUIGetMsg ()
|
|---|
| 19 | Case $GUI_EVENT_CLOSE, $hBtnExit ; "Exit" button: Exit from the program
|
|---|
| 20 | ExitLoop
|
|---|
| 21 | Case $hBtnDoit ; "Do It" button: try to set each digit to a superscript
|
|---|
| 22 | For $iPtr = 0 to $Length
|
|---|
| 23 | $Char = _GUICtrlRichEdit_GetTextInRange ( $hRichEdit, $iPtr, $iPtr+1 )
|
|---|
| 24 | If @Error = 0 Then
|
|---|
| 25 | If StringIsDigit ($Char) Then ; This character is a digit, so superscript it
|
|---|
| 26 | _GUICtrlRichEdit_SetSel ( $hRichEdit, $iPtr, $iPtr+1)
|
|---|
| 27 | _GUICtrlRichEdit_SetCharAttributes ($hRichEdit, "+sp")
|
|---|
| 28 | _GUICtrlRichEdit_Deselect ($hRichEdit)
|
|---|
| 29 | EndIf
|
|---|
| 30 | EndIf
|
|---|
| 31 | Next
|
|---|
| 32 | GUICtrlSetData ($hEdit, _GUICtrlRichEdit_StreamToVar ($hRichEdit)) ; Send the RTF to the Edit control
|
|---|
| 33 | EndSwitch
|
|---|
| 34 | WEnd
|
|---|
| 35 | _GUICtrlRichEdit_Destroy($hRichEdit)
|
|---|
| 36 | GUIDelete($hGUI)
|
|---|
| 37 | Exit
|
|---|