Ticket #3630: SuperBug.au3

File SuperBug.au3, 1.6 KB (added by davidjudysmith@…, 6 years ago)

Demonstrates that superscripting in the Rich Edit control doesn't work

Line 
1; Test program for setting superscripts in a Rich Edit control
2#include <GUIConstantsEx.au3>
3#include <GuiRichEdit.au3>
4Local $hGui, $hRichEdit, $hEdit, $hBtnDoit, $hBtnExit
5Local $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)
15GUISetState(@SW_SHOW, $hGUI)
16
17While 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
34WEnd
35_GUICtrlRichEdit_Destroy($hRichEdit)
36GUIDelete($hGUI)
37Exit