Ticket #3225: test2.au3

File test2.au3, 3.0 KB (added by michael.szerencsits@…, 8 years ago)
Line 
1#include <Date.au3>
2#include <array.au3>
3;#include <string.au3>
4;#include <File.au3>
5
6#include <MsgBoxConstants.au3>
7#include <GUIConstantsEx.au3>
8#include <GuiEdit.au3>
9#include <WindowsConstants.au3>
10#include <EditConstants.au3>
11#include <GuiButton.au3>
12#include <ScrollBarsConstants.au3>
13#include <WinAPIFiles.au3>
14#include <ProgressConstants.au3>
15#include <FileConstants.au3>
16#include <StaticConstants.au3>
17#include <ButtonConstants.au3>
18#include <GuiRichEdit.au3>
19
20$Interrupt = 0
21Opt("GUIOnEventMode", 1)
22$Form1 = GUICreate("Automatischer File Copy", 470, 665)
23$iOKB = GUICtrlCreateButton("Sart", 10, 10, 50, 20, $BS_BITMAP)
24GUICtrlSetOnEvent(-1, "StartFunc")
25$iStop = GUICtrlCreateButton("Stop", 70, 10, 50, 20)
26GUICtrlSetOnEvent(-1, "StopFunc")
27$ExitID = GUICtrlCreateButton("Exit", 130, 10, 50, 20)
28GUICtrlSetOnEvent(-1, "_exit")
29$iBCE = GUICtrlCreateRadio("Edit", 190, 4, 150, 20)
30$iBRE = GUICtrlCreateRadio("RichEdit", 190, 22, 150, 20)
31GUICtrlSetState($iBCE, $GUI_CHECKED)
32GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
33GUISetState()
34GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
35GUICtrlCreateLabel("GUICtrlCreateEdit:", 10, 40, 100, 15)
36GUICtrlCreateLabel("GUICtrlRichEdit:", 240, 40, 100, 15)
37
38$LogWindowE = GUICtrlCreateEdit("", 10, 60, 220, 580, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_AUTOHSCROLL + $WS_HSCROLL + $ES_READONLY)
39GUICtrlSetBkColor(-1,0xFFFFFF)
40GUICtrlSetFont(-1, 8.5, 400, 0, "MS Sans Serif")
41GUICtrlSetLimit(-1,0x7FFFFFFF)
42$LogWindowR = _GUICtrlRichEdit_Create($Form1, "", 240, 60, 220, 580, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $WS_HSCROLL, $ES_AUTOHSCROLL, $ES_READONLY))
43
44While 1
45        Sleep(10)
46Wend
47
48Func StartFunc()
49        $Interrupt = 0
50        For $counter = 1 To 1000
51        If $Interrupt <> 0 Then Return
52        Select
53                Case BitAND(GUICtrlRead($iBCE), $GUI_CHECKED); Same
54                        _mylogE("Counter is: " & $counter & @CRLF)
55                Case BitAND(GUICtrlRead($iBRE), $GUI_CHECKED); Same
56                        _mylogR("Counter is: " & $counter & @CRLF)
57        EndSelect
58        Next
59
60EndFunc
61
62Func StopFunc()
63        Select
64                Case BitAND(GUICtrlRead($iBCE), $GUI_CHECKED); Same
65                        _mylogE("Stopped" & @CRLF)
66                Case BitAND(GUICtrlRead($iBRE), $GUI_CHECKED); Same
67                        _mylogR("Stopped" & @CRLF)
68        EndSelect
69EndFunc
70
71
72
73Func _myLogR($logtext, $color = "0x000000")
74        $iEndPoint = _GUICtrlRichEdit_GetTextLength($LogWindowR, True, True) - _GUICtrlRichEdit_GetLineCount($LogWindowR)
75        If $iEndPoint < 0 Then $iEndPoint = 0
76        _GUICtrlRichEdit_AppendText($LogWindowR, $logtext)
77    ;_GuiCtrlRichEdit_SetSel($LogWindowR, $iEndPoint, -1)
78    ;_GuiCtrlRichEdit_SetCharColor($LogwindowR, $color)
79        ;_GUICtrlRichEdit_Deselect($LogWindowR)
80EndFunc
81
82Func _mylogE($logtext)
83        $bEnd = StringLen(GUICtrlRead($LogWindowE))
84    _GUICtrlEdit_SetSel($LogWindowE, $bEnd, $bEnd)
85    _GUICtrlEdit_Scroll($LogWindowE, $SB_SCROLLCARET)
86    GUICtrlSetData($LogWindowE, $logtext, 1)
87EndFunc
88
89Func _exit()
90        Exit
91EndFunc
92
93Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
94        If BitAND($wParam, 0x0000FFFF) =  $iStop Then $Interrupt = 1
95        Return $GUI_RUNDEFMSG
96EndFunc