Ticket #1992: scrollbar_code.au3

File scrollbar_code.au3, 2.6 KB (added by Stilez, 13 years ago)
Line 
1; 'Help' layout
2Global $gui_width = 700
3Global $gui_height = 500
4Global $gui_topmargin = 5
5Global $gui_sidemargin = 10
6Global $gui_bottommargin = 55
7Global $gui_okbuttonwidth = 100
8Global $gui_okbuttonheight = 30
9Global $gui_winbkcolor = 0xFFFFD8
10
11#include <GUIConstantsEx.au3>
12#include <EditConstants.au3>
13#include <WindowsConstants.au3>
14#include <StaticConstants.au3>
15#Include <Array.au3>
16#Include <String.au3>
17#Include <GuiRichEdit.au3>
18OnAutoItExitRegister("CleanExit")
19
20Global $gui_winhandle = -1
21
22$text  = FileRead(@Scriptdir & "\Help-en.rtf")
23
24
25
26; create GUI styles
27$winstyle = BitOR($WS_CAPTION, $WS_SIZEBOX, $WS_MAXIMIZEBOX)
28$ctrlstyle = BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_READONLY)
29
30; create GUI window
31$gui_win = GUICreate("Classic Quick Launch:  Help", $gui_width, $gui_height, -1, -1, $winstyle)
32GUISetBkColor($gui_winbkcolor)
33; crerate and fill "help" textbox, focus it, go to top (ctrl-home)
34$gui_textbox = _GUICtrlRichEdit_Create($gui_win, $text, $gui_sidemargin, $gui_topmargin, $gui_width - 2 * $gui_sidemargin, $gui_height - $gui_topmargin - $gui_bottommargin, $ctrlstyle)
35GUICtrlSetState($gui_textbox, $GUI_FOCUS)
36Send("^{HOME}")
37; version/build label
38GUICtrlCreateLabel("Build:   1234.5", $gui_sidemargin + 8, $gui_height - 20, ($gui_width - $gui_okbuttonwidth)/2 - 60)
39GUICtrlSetColor(-1, 0xff0000)
40; "ok" button
41$gui_okbutton = GUICtrlCreateButton("OK", ($gui_width - $gui_okbuttonwidth)/2, $gui_height - ($gui_topmargin + $gui_bottommargin)/2 - $gui_okbuttonheight/2, $gui_okbuttonwidth, $gui_okbuttonheight)
42
43; display it and loop while checking GUI signals
44; Written this way to allow other buttons in future
45GUISetState(@SW_SHOW, $gui_win)
46While 1
47        $msg = GUIGetMsg()
48        Select
49                Case $msg = $gui_okbutton Or $msg = $GUI_EVENT_CLOSE Or $msg = -3
50                        ExitLoop
51                Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE
52                        $a = WinGetClientSize($gui_win)
53                        ControlMove($gui_win, "", $gui_textbox, 10, 10, $a[0] - 20, $a[1] - 20)
54                        ControlMove($gui_win, "", $gui_textbox, $gui_sidemargin, $gui_topmargin, $a[0] - 2 * $gui_sidemargin, $a[1] - $gui_topmargin - $gui_bottommargin)
55        EndSelect
56
57WEnd
58
59; close and leave help
60_GUICtrlRichEdit_Destroy($gui_textbox)
61GUIDelete()
62
63
64
65Exit
66
67
68Func CleanExit()
69        ; Re-enable input first whatever the reason
70        BlockInput(0)
71        ; Destroy any rich text GUI used for HELP/INFO, if it exists - this is important (Help:_GUICtrlRichEdit_Destroy)
72        If WinExists($gui_win) Then _GUICtrlRichEdit_Destroy($gui_textbox)
73        ; And exit
74        Exit
75EndFunc