Advertisement
AZJIO

Стили GUI

Sep 16th, 2011
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.58 KB | None | 0 0
  1. #include <WindowsConstants.au3>
  2. #include <Array.au3>
  3. #include <EditConstants.au3>
  4. #include <ListboxConstants.au3>
  5. Opt('GUIResizeMode', 802)
  6.  
  7. HotKeySet('!{ESC}', '_Reset')
  8.  
  9. Local $hGui, $GuiStyles, $LStyle, $iList, $iCombo, $Input_Styles, $n
  10. Local $sTitle, $sDefEdit, $sExm
  11.  
  12. Local $aStyle[9][3] = [ _
  13.         [8, 0, 0], _
  14.         ['Reset', '$GuiStyles[0]', '$GuiStyles[1]'], _
  15.         ['With border', 'BitOr($WS_BORDER, $WS_POPUP, $WS_SYSMENU)', '0'], _
  16.         ['Stretching window', 'BitOr($WS_OVERLAPPEDWINDOW, $WS_POPUP)', '0'], _
  17.         ['Dragging using the client area', '0', '$WS_EX_CONTROLPARENT'], _
  18.         ['Tool panel', '$GUI_SS_DEFAULT_GUI', '$WS_EX_TOOLWINDOW'], _
  19.         ['Unavailable', 'BitOr($GUI_SS_DEFAULT_GUI, $WS_DISABLED)', '0'], _
  20.         ['System question mark', 'BitOr($WS_SYSMENU, $WS_CAPTION)', '$WS_EX_CONTEXTHELP'], _
  21.         ['About, Credits', 'BitOR($WS_CAPTION, $WS_SYSMENU, $WS_POPUP)', '0']]
  22. $sTitle = 'Choose a window style'
  23. $sDefEdit = 'There are styles'
  24. $sExm = 'Example'
  25.  
  26. ; Ru
  27. ; если русская локализация, то русский язык
  28. If @OSLang = 0419 Then
  29.     $aStyle[1][0] = 'Сброс'
  30.     $aStyle[2][0] = 'С контуром'
  31.     $aStyle[3][0] = 'Растягивание окна'
  32.     $aStyle[4][0] = 'Перетаскивание за клиентскую область'
  33.     $aStyle[5][0] = 'Инструментальная панелька'
  34.     $aStyle[6][0] = 'Недоступное'
  35.     $aStyle[7][0] = 'Системный знак вопроса'
  36.     $aStyle[8][0] = 'О программе'
  37.     $sTitle = 'Выбирайте стиль окна'
  38.     $sDefEdit = 'Здесь будут стили'
  39.     $sExm = 'Пример'
  40. EndIf
  41.  
  42. $hGui = GUICreate($sTitle, 520, 520)
  43. $GuiStyles = GUIGetStyle($hGui)
  44.  
  45. ; Создаём заполняющий список
  46. For $i = 1 To $aStyle[0][0]
  47.     $LStyle &= $aStyle[$i][0] & '|'
  48. Next
  49. $LStyle = StringTrimRight($LStyle, 1)
  50.  
  51. $iList = GUICtrlCreateList('', 5, 5, 240, 420, $LBS_NOINTEGRALHEIGHT)
  52. GUICtrlSetData(-1, $LStyle, $aStyle[1][0])
  53. $iCombo = GUICtrlCreateCombo('', 5, 430, 240)
  54. GUICtrlSetData(-1, $LStyle, $aStyle[1][0])
  55. $Input_Styles = GUICtrlCreateEdit($sDefEdit, 5, 460, 510, 50, $ES_AUTOVSCROLL)
  56.  
  57. GUISetState()
  58. While 1
  59.     Switch GUIGetMsg()
  60.         Case $iList
  61.             $n = _Style(GUICtrlRead($iList))
  62.             GUICtrlSetData($iCombo, $aStyle[$n][0])
  63.         Case $iCombo
  64.             $n = _Style(GUICtrlRead($iCombo))
  65.             GUICtrlSetData($iList, $aStyle[$n][0])
  66.         Case -3
  67.             Exit
  68.     EndSwitch
  69. WEnd
  70.  
  71. Func _Style($item)
  72.     Local $n = _ArraySearch($aStyle, $item)
  73.     GUISetStyle(1, 1)
  74.     GUISetStyle(Execute($aStyle[$n][1]), Execute($aStyle[$n][2]))
  75.     If $item = $aStyle[1][0] Then
  76.         GUICtrlSetData($Input_Styles, 'GUICreate("' & $sExm & '", 300, 220) ')
  77.     Else
  78.         If $aStyle[$n][2] = '0' Then
  79.             GUICtrlSetData($Input_Styles, 'GUICreate("' & $sExm & '", 300, 220, -1, -1, ' & $aStyle[$n][1] & ')')
  80.         Else
  81.             GUICtrlSetData($Input_Styles, 'GUICreate("' & $sExm & '", 300, 220, -1, -1, ' & $aStyle[$n][1] & ', ' & $aStyle[$n][2] & ')')
  82.         EndIf
  83.     EndIf
  84.     Switch $item
  85.         Case $aStyle[6][0]
  86.             _Enable()
  87.         Case $aStyle[2][0], $aStyle[5][0] ; Случай требующий перерисовки окна
  88.             $aPos = WinGetPos($hGui)
  89.             WinMove($hGui, '', Default, Default, Default, $aPos[3] + 1)
  90.             WinMove($hGui, '', Default, Default, Default, $aPos[3])
  91.     EndSwitch
  92.     Return $n
  93. EndFunc   ;==>_Style
  94.  
  95. Func _Reset()
  96.     GUISetStyle($GuiStyles[0], $GuiStyles[1])
  97.     GUICtrlSetData($Input_Styles, $sDefEdit)
  98. EndFunc   ;==>_Reset
  99.  
  100. Func _Enable()
  101.     GUICtrlSetBkColor($iList, 0xffd7d7)
  102.     Sleep(2000)
  103.     GUISetStyle($GuiStyles[0], $GuiStyles[1])
  104.     GUICtrlSetBkColor($iList, 0xffffff)
  105. EndFunc   ;==>_Enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement