| 1 | #include <GUIConstantsEx.au3>
|
|---|
| 2 | #include <GuiRichEdit.au3>
|
|---|
| 3 | #include <WindowsConstants.au3>
|
|---|
| 4 |
|
|---|
| 5 | Example()
|
|---|
| 6 |
|
|---|
| 7 | Func Example()
|
|---|
| 8 | Local $hGui, $hRichEdit, $hRichEdit2, $hRichEdit3, $hRichEdit123
|
|---|
| 9 | Local $iMsg
|
|---|
| 10 | $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 1300, 350, -1, -1)
|
|---|
| 11 |
|
|---|
| 12 | #Region Create all RichEdit controls
|
|---|
| 13 | $hRichEdit1 = _GUICtrlRichEdit_Create($hGui, "This is a first test.", 10, 10, 300, 220, _
|
|---|
| 14 | BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
|
|---|
| 15 | _GUICtrlRichEdit_AppendText($hRichEdit1, @CRLF & "This is more text" & @CRLF)
|
|---|
| 16 |
|
|---|
| 17 | $hRichEdit2 = _GUICtrlRichEdit_Create($hGui, "This is a second test.", 320, 10, 300, 220, _
|
|---|
| 18 | BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
|
|---|
| 19 | _GUICtrlRichEdit_AppendText($hRichEdit2, @CRLF & "This is more text" & @CRLF)
|
|---|
| 20 |
|
|---|
| 21 | $hRichEdit3 = _GUICtrlRichEdit_Create($hGui, "This is a third test.", 630, 10, 300, 220, _
|
|---|
| 22 | BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
|
|---|
| 23 | _GUICtrlRichEdit_AppendText($hRichEdit3, @CRLF & "This is more text" & @CRLF)
|
|---|
| 24 |
|
|---|
| 25 | $hRichEdit123 = _GUICtrlRichEdit_Create($hGui, "This is a combined test.", 940, 10, 300, 220, _
|
|---|
| 26 | BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
|
|---|
| 27 | _GUICtrlRichEdit_AppendText($hRichEdit123, @CRLF & @CRLF)
|
|---|
| 28 | #EndRegion Create all RichEdit controls
|
|---|
| 29 |
|
|---|
| 30 | ; Copying $hRichEdit1 to $hRichEdit123
|
|---|
| 31 | _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit1, $hRichEdit123)
|
|---|
| 32 |
|
|---|
| 33 | ; Copying $hRichEdit2 to $hRichEdit123
|
|---|
| 34 | _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit2, $hRichEdit123)
|
|---|
| 35 |
|
|---|
| 36 | ; Copying $hRichEdit3 to $hRichEdit123
|
|---|
| 37 | _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit3, $hRichEdit123)
|
|---|
| 38 |
|
|---|
| 39 | GUISetState(@SW_SHOW)
|
|---|
| 40 |
|
|---|
| 41 | While True
|
|---|
| 42 | $iMsg = GUIGetMsg()
|
|---|
| 43 | Select
|
|---|
| 44 | Case $iMsg = $GUI_EVENT_CLOSE
|
|---|
| 45 | _GUICtrlRichEdit_Destroy($hRichEdit1) ; needed unless script crashes
|
|---|
| 46 | _GUICtrlRichEdit_Destroy($hRichEdit2) ; needed unless script crashes
|
|---|
| 47 | _GUICtrlRichEdit_Destroy($hRichEdit3) ; needed unless script crashes
|
|---|
| 48 | _GUICtrlRichEdit_Destroy($hRichEdit123) ; needed unless script crashes
|
|---|
| 49 | ; GUIDelete() ; is OK too
|
|---|
| 50 | Exit
|
|---|
| 51 | EndSelect
|
|---|
| 52 | WEnd
|
|---|
| 53 | EndFunc ;==>Example
|
|---|
| 54 |
|
|---|
| 55 | Func _GUICtrlRichEdit_CopyAllToRichEdit(ByRef $hSourceRichEdit, ByRef $hDestinationRichEdit)
|
|---|
| 56 |
|
|---|
| 57 | ; check for current selection in source control
|
|---|
| 58 | Local $aSelection = _GUICtrlRichEdit_GetSel($hSourceRichEdit)
|
|---|
| 59 |
|
|---|
| 60 | ; select all contents in source control
|
|---|
| 61 | _GUICtrlRichEdit_SetSel($hSourceRichEdit, 0, -1)
|
|---|
| 62 |
|
|---|
| 63 | ; select selected contents in source control
|
|---|
| 64 | _GUICtrlRichEdit_Copy($hSourceRichEdit)
|
|---|
| 65 |
|
|---|
| 66 | ; paste content to destination control
|
|---|
| 67 | _GUICtrlRichEdit_Paste($hDestinationRichEdit)
|
|---|
| 68 |
|
|---|
| 69 | ; revert back selection in source control
|
|---|
| 70 | _GUICtrlRichEdit_SetSel($hSourceRichEdit, $aSelection[0], $aSelection[1])
|
|---|
| 71 |
|
|---|
| 72 | EndFunc ;==>_GUICtrlRichEdit_CopyAllToRichEdit
|
|---|