Advertisement
Facemix

GDI+ CountdownScreensaver with Feuerwerk

Dec 20th, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 23.33 KB | None | 0 0
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Outfile=Test.scr
  3. #AutoIt3Wrapper_Outfile_x64=Test2.scr
  4. #AutoIt3Wrapper_Compile_Both=y
  5. #AutoIt3Wrapper_UseX64=y
  6. #AutoIt3Wrapper_Res_Fileversion=1.0.0
  7. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  8.  
  9. #include <Date.au3>
  10. #include <GDIPlus.au3>
  11. #include <Misc.au3>
  12. #include <Timers.au3>
  13. #include <GUIConstantsEx.au3>
  14. #include <WindowsConstants.au3>
  15. #include <GuiListView.au3>
  16. #include <GuiImageList.au3>
  17.  
  18. Opt("GUIOnEventMode", 1)
  19. _Singleton(@AutoItExe)
  20.  
  21. ; -Authors: name22 (www.autoit.de), Andy (www.autoit.de), Facemix (www.autoit.de)
  22.  
  23. Global $idle_o, $idle_n, $parent_pid, $aChildProcess, $iFlakeCount, $iMaxRadius
  24.  
  25. #region WINDOWSTOOL
  26.  
  27. Global $iCount = 10, $iExplosion = 100, $iExplosionGround = 1, $iRadius = 600, $iBack = 0x09000000, $iSleep = 5
  28.  
  29. Global Const $app_name = "GDI+ Countdown-Screensaver by (C) Clemens 2012"
  30. Global Const $ver = "v1.0 build 2012-11-24"
  31. Global $hGUI, $iW, $iH, $GUI_H, $GUI_W, $GUI_X, $GUI_Y, $r, $show_FPS = 0
  32. Global $maxStars = 150, $size = 1
  33. Global $parent_pid, $aChildProcess
  34. Global Const $hFullScreen = WinGetHandle("Program Manager")
  35. Global Const $aFullScreen = WinGetPos($hFullScreen)
  36. Global $main_screen_x = Abs($aFullScreen[0])
  37. Global Const $ini_file = @ScriptDir & "\CountdownScreensaver.ini"
  38.  
  39. Global $cmdparam = "/s"
  40. If $CmdLine[0] Then $cmdparam = StringLeft($CmdLine[1], 2)
  41.  
  42. Switch $cmdparam
  43.     Case "/s"
  44.         $iW = @DesktopWidth
  45.         $iH = @DesktopHeight
  46.         $GUI_X = $aFullScreen[0]
  47.         $GUI_Y = $aFullScreen[1]
  48.         $GUI_W = $aFullScreen[2]
  49.         $GUI_H = $aFullScreen[3]
  50.         $hGUI = GUICreate($app_name, $GUI_W, $GUI_H, $GUI_X, $GUI_Y, $WS_POPUP, $WS_EX_TOPMOST)
  51.         $iFlakeCount = 500
  52.         $iMaxRadius = 3
  53.     Case "/c"
  54.         Opt("GUIOnEventMode", 0)
  55.         _Settings()
  56.         Exit
  57.  
  58.     Case "/p"
  59.         $iFlakeCount = 50
  60.         $iMaxRadius = 2
  61.         $iW = 152
  62.         $iH = 112
  63.         $GUI_X = 0
  64.         $GUI_Y = 0
  65.         $GUI_W = $iW
  66.         $GUI_H = $iH
  67.         $main_screen_x  = 0
  68.         $show_FPS = False
  69.         ;$maxStars = 30
  70.         $size = 1
  71.         $hGUI = GUICreate("GDI+ Countdown-Screensaver by (C) Clemens", $GUI_W, $GUI_H, $GUI_X, $GUI_Y, $WS_POPUP)
  72.         _WinAPI_SetParent($hGUI, $CmdLine[2])
  73.         $parent_pid = _WinAPI_GetParentProcess(@AutoItPID)
  74. EndSwitch
  75. #endregion WINDOWSTOOL
  76.  
  77. ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  78.  
  79. #region BILDSCHIRMSCHOHNER
  80. Global Const $nTau = ACos(-1) * 2
  81. Global $vNTdll = DllOpen("ntdll.dll")
  82. Global $tPrecSleep = DllStructCreate("int64 time;")
  83. Global $pPrecSleep = DllStructGetPtr($tPrecSleep)
  84.  
  85. #region SETTINGS
  86.  
  87. Global $iWidth = $iW
  88. Global $iHeight = $iH
  89. Global $nFPS = 25
  90.  
  91. Global $nStepSpeed = 1
  92.  
  93. #region COLORS
  94. ;Global $iARGB_BG = 0xFF505050
  95. Global $iARGB_Snow = 0xFFFFFFFF
  96. ;Global $iARGB_TextFill = 0xFF0000FF
  97.  
  98. Global $iARGB_BG = IniRead("CountdownScreensaver.ini", "Settings", "BgColor", "0xFF000000")
  99. Global $iARGB_TextFill = IniRead("CountdownScreensaver.ini", "Settings", "TextColor", "0xFF000000")
  100.  
  101. Global $iARGB_TextFill2 = 0xFFFF0000
  102. Global $iARGB_TextFill3 = 0xFF0000FF
  103. Global $iARGB_TextFill4 = 0xFF353535
  104. Global $iARGB_TextBorder = 0xFFA00000
  105. #endregion COLORS
  106.  
  107. #region SNOWFLAKES
  108. Global $iMinFallingSpeed = 20, $iMaxFallingSpeed = 50
  109. Global $iMinOscillations = 2, $iMaxOscillations = 5
  110. Global $iMinOscillationDist = 10, $iMaxOscillationDist = 50
  111. Global $iMinRadius = 1
  112. #endregion SNOWFLAKES
  113.  
  114. #region SNOWBLAST
  115. Global $iBlastRadius = 200
  116. Global $iBlastAccell = 300
  117. Global $nAirFriction = 0.95
  118. #endregion SNOWBLAST
  119.  
  120. #endregion SETTINGS
  121.  
  122. #region Global Variables
  123. Global $aFlakes[$iFlakeCount + 1][8] = [[$iFlakeCount]]
  124. Global $hDC_Window, $hDC_Bitmap, $hBitmap, $hGraphics, $hOldObj, $hBrush_Snow, $hBrush_TextFill, $hPen_Border
  125. Global $hMatrix, $tLayout, $hFormat, $hFamily, $hPath, $nScale, $nStep = 0, $iM, $iS, $iD, $sText, $sTextOld
  126. Global $nSleepTime = 1000 / $nFPS
  127. #endregion Global Variables
  128.  
  129. #region Generate Snow
  130. For $i = 1 To $aFlakes[0][0]
  131.     $aFlakes[$i][0] = Random(10, $iWidth - 10, 1)
  132.     $aFlakes[$i][1] = Random(-$iHeight, 0, 1)
  133.     $aFlakes[$i][2] = 0
  134.     $aFlakes[$i][3] = 0
  135.     $aFlakes[$i][4] = Random($iMinRadius, $iMaxRadius, 1)
  136.     $aFlakes[$i][5] = Random($iMinFallingSpeed, $iMaxFallingSpeed)
  137.     $aFlakes[$i][6] = Random($iMinOscillations, $iMaxOscillations, 1)
  138.     $aFlakes[$i][7] = Random($iMinOscillationDist, $iMaxOscillationDist) * (-1) ^ Random(1, 2, 1)
  139. Next
  140. #endregion Generate Snow
  141.  
  142. GUISetState()
  143.  
  144. #region Initialize GFX Resources
  145. $hDC_Window = _WinAPI_GetDC($hGUI)
  146. $hDC_Bitmap = _WinAPI_CreateCompatibleDC($hDC_Window)
  147. $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
  148. $hOldObj = _WinAPI_SelectObject($hDC_Bitmap, $hBitmap)
  149.  
  150. _GDIPlus_Startup()
  151.  
  152. ;Global $iARGB_Snow = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "/soother.png")
  153.  
  154. $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Bitmap)
  155. _GDIPlus_GraphicsSetClipRect($hGraphics, 0, 0, $iWidth, $iHeight)
  156. _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
  157.  
  158. $hBrush_Snow = _GDIPlus_BrushCreateSolid($iARGB_Snow)
  159. $hBrush_TextFill = _GDIPlus_BrushCreateSolid($iARGB_TextFill)
  160. $hPen_Border = _GDIPlus_PenCreate($iARGB_TextBorder, 3)
  161. DllCall($ghGDIPDll, "uint", "GdipSetPenLineJoin", "hwnd", $hPen_Border, "int", 2)
  162.  
  163. $hMatrix = _GDIPlus_MatrixCreate()
  164. $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
  165. $hFormat = _GDIPlus_StringFormatCreate()
  166. $hFamily = _GDIPlus_FontFamilyCreate("Arial")
  167. $hPath = _CreatePath("88 - 88:88:88")
  168.  
  169. _GDIPlus_GraphicsClear($hGraphics, "0x" & $iARGB_BG)
  170. _Redraw()
  171. #endregion Initialize GFX Resources
  172.  
  173. #region Register Events
  174. OnAutoItExitRegister("_Shutdown")
  175. GUIRegisterMsg($WM_PAINT, "_Redraw")
  176. GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
  177. GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_Click")
  178.  
  179. AdlibRegister("_UpdateTime", 100)
  180. #endregion Register Events
  181.  
  182. $nT_Sleep = TimerInit() + $nSleepTime
  183.  
  184. While True
  185.     If $cmdparam = "/s" Then
  186.         GUISetCursor(16, 1, $hGUI)
  187.         $idle_n = _Timer_GetIdleTime()
  188.         If $idle_n < $idle_o Then _Close()
  189.         $idle_o = $idle_n
  190.     Else
  191.         If Not BitAND(WinGetState($hGUI), 2) Then _Close()
  192.         $aChildProcess = _WinAPI_EnumChildProcess($parent_pid)
  193.         If $aChildProcess[0][0] > 1 Then _Close()
  194.     EndIf
  195.     DllStructSetData($tPrecSleep, "time", -10000 * ($nSleepTime - TimerDiff($nT_Sleep)))
  196.     DllCall($vNTdll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pPrecSleep)
  197.     $nFrameTime = TimerDiff($nT_Sleep)
  198.     $nT_Sleep = TimerInit()
  199.  
  200.     $nFPS_Cur = 1000 / $nFrameTime
  201.  
  202.     $nStep += $nStepSpeed / $nFPS_Cur
  203.     $nScale = Abs(Sin($nStep))
  204.  
  205.     _GDIPlus_GraphicsClear($hGraphics, $iARGB_BG)
  206.  
  207.     DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGraphics, "float", -$iWidth / 2, "float", -$iHeight / 2, "int", False)
  208.     DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGraphics, "float", $nScale, "float", $nScale, "int", True)
  209.     DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGraphics, "float", $iWidth / 2, "float", $iHeight / 2, "int", True)
  210.  
  211.     DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGraphics, "hwnd", $hPen_Border, "hwnd", $hPath)
  212.     DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGraphics, "hwnd", $hBrush_TextFill, "hwnd", $hPath)
  213.  
  214.     DllCall($ghGDIPDll, "uint", "GdipResetWorldTransform", "hwnd", $hGraphics)
  215.  
  216.     For $i = 1 To $aFlakes[0][0]
  217.         $aFlakes[$i][1] += ($aFlakes[$i][5] + $aFlakes[$i][3]) / $nFPS_Cur
  218.         $aFlakes[$i][0] += (Sin($aFlakes[$i][1] / $iHeight * $nTau * $aFlakes[$i][6]) * $aFlakes[$i][7] + $aFlakes[$i][2]) / $nFPS_Cur
  219.         $aFlakes[$i][2] *= $nAirFriction
  220.         $aFlakes[$i][3] *= $nAirFriction
  221.         If $aFlakes[$i][1] > $iHeight Or $aFlakes[$i][0] < -20 Or $aFlakes[$i][0] > $iWidth + 20 Then
  222.             $aFlakes[$i][0] = Random(10, $iWidth - 10, 1)
  223.             $aFlakes[$i][1] = Random(-$iHeight, 0, 1)
  224.             $aFlakes[$i][2] = 0
  225.             $aFlakes[$i][3] = 0
  226.             $aFlakes[$i][4] = Random($iMinRadius, $iMaxRadius, 1)
  227.             $aFlakes[$i][5] = Random($iMinFallingSpeed, $iMaxFallingSpeed)
  228.             $aFlakes[$i][6] = Random($iMinOscillations, $iMaxOscillations, 1)
  229.             $aFlakes[$i][7] = Random($iMinOscillationDist, $iMaxOscillationDist)
  230.         EndIf
  231.         _GDIPlus_GraphicsFillEllipse($hGraphics, $aFlakes[$i][0] - $aFlakes[$i][4] / 2, $aFlakes[$i][1] - $aFlakes[$i][4] / 2, $aFlakes[$i][4] * 2, $aFlakes[$i][4] * 2, $hBrush_Snow)
  232.     Next
  233.     _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
  234. WEnd
  235.  
  236. Func _UpdateTime()
  237.     _TicksToTime(_DateDiff('s', _NowCalc(), 2014 & "/01/01 00:00:00") * 1000, $iH, $iM, $iS)
  238.     ;_TicksToTime(_DateDiff('s', _NowCalc(), @YEAR + 1 & "/01/01 00:00:00") * 1000, $iH, $iM, $iS)
  239.     If $iH > 23 Then
  240.         $iD = StringFormat("%02i", $iH / 24); volle Tage
  241.         $iH = $iH - ($iD * 24); volle Tage abziehen
  242.     Else
  243.         $iD = 0
  244.     EndIf
  245.  
  246.     If $sText = "00 - 00:00:00" Then
  247.         AdlibUnRegister("_UpdateTime")
  248.         Feuerwerk() ; Funktion Feuerwerk soll dann ausgeführt werden
  249.     Else
  250.         $sText = StringFormat("%02i - %02i:%02i:%02i", $iD, $iH, $iM, $iS)
  251.     EndIf
  252.  
  253.     If $sText <> $sTextOld Then
  254.         $sTextOld = $sText
  255.         DllCall($ghGDIPDll, "uint", "GdipResetPath", "hwnd", $hPath)
  256.         DllCall($ghGDIPDll, "uint", "GdipAddPathString", "hwnd", $hPath, "wstr", $sText, "int", -1, "hwnd", $hFamily, "int", 1, "float", 100, "ptr", DllStructGetPtr($tLayout), "hwnd", $hFormat)
  257.         DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
  258.     EndIf
  259. EndFunc
  260.  
  261. Func _Click()
  262.     Local $tMousePos = _WinAPI_GetMousePos(True, $hGUI)
  263.     For $i = 1 To $aFlakes[0][0]
  264.         $iX_Dist = ($aFlakes[$i][0] - $aFlakes[$i][4]) - DllStructGetData($tMousePos, "X")
  265.         $iY_Dist = ($aFlakes[$i][1] - $aFlakes[$i][4]) - DllStructGetData($tMousePos, "Y")
  266.         $iDist = Sqrt($iX_Dist ^ 2 + $iY_Dist ^ 2)
  267.         If $iDist = 0 Then ContinueLoop
  268.         If $iDist < $iBlastRadius Then
  269.             $aFlakes[$i][2] = (1 - $iDist / $iBlastRadius) * ($iX_Dist / $iDist) * $iBlastAccell
  270.             $aFlakes[$i][3] = (1 - $iDist / $iBlastRadius) * ($iY_Dist / $iDist) * $iBlastAccell
  271.         EndIf
  272.     Next
  273. EndFunc   ;==>_Click
  274.  
  275. Func _Redraw()
  276.     _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
  277. EndFunc   ;==>_Redraw
  278.  
  279. Func _Close()
  280.     _Shutdown()
  281.     GUIDelete($hGUI)
  282.     Exit
  283. EndFunc   ;==>_Close
  284.  
  285. Func _Shutdown()
  286.     _WinAPI_SelectObject($hDC_Bitmap, $hOldObj)
  287.     _WinAPI_ReleaseDC($hGUI, $hDC_Window)
  288.     _WinAPI_DeleteDC($hDC_Bitmap)
  289.     _WinAPI_DeleteObject($hBitmap)
  290.  
  291.     _GDIPlus_GraphicsDispose($hGraphics)
  292.     _GDIPlus_BrushDispose($hBrush_Snow)
  293.     _GDIPlus_PenDispose($hPen_Border)
  294.     _GDIPlus_MatrixDispose($hMatrix)
  295.     _GDIPlus_StringFormatDispose($hFormat)
  296.     _GDIPlus_FontFamilyDispose($hFamily)
  297.     DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
  298.     _GDIPlus_Shutdown()
  299.  
  300.     DllClose($vNTdll)
  301. EndFunc   ;==>_Shutdown
  302.  
  303. Func _CreatePath($sText)
  304.  
  305.     Local $tBounds = _GDIPlus_RectFCreate(0, 0, 0, 0)
  306.  
  307.     Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
  308.     If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
  309.     Local $hPath = $aResult[2]
  310.  
  311.     DllCall($ghGDIPDll, "uint", "GdipAddPathString", "hwnd", $hPath, "wstr", $sText, "int", -1, "hwnd", $hFamily, "int", 1, "float", 100, "ptr", DllStructGetPtr($tLayout), "hwnd", $hFormat)
  312.     DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tBounds), "hwnd", 0, "hwnd", 0)
  313.  
  314.  
  315.     _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tBounds, "X"), -DllStructGetData($tBounds, "Y"))
  316.     _GDIPlus_MatrixScale($hMatrix, $iWidth / DllStructGetData($tBounds, "Width"), $iHeight / DllStructGetData($tBounds, "Height"), True)
  317.     DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
  318.  
  319.     Return $hPath
  320. EndFunc   ;==>_CreatePath
  321.  
  322.  
  323. #region FEUERWERK
  324.  
  325. Func Feuerwerk()
  326.     Local $aDraw
  327.     Local $iCount = 10, $iExplosion = 100, $iExplosionGround = 1, $iRadius = 600, $iBack = 0x09000000, $iSleep = 5
  328.     Global $iWidth2 = @DesktopWidth, $iHeight2 = @DesktopHeight, $aStart[$iCount][4] = [[Random(0, $iWidth2, 0), Random(0, $iHeight2, 0), 0, _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))],[Random(0, $iWidth2, 0), Random(0, $iHeight2, 0), 0, _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))]], $iSleeping = 0
  329.     For $i = 0 To UBound($aStart) - 1
  330.         $aStart[$i][0] = Random(0, $iWidth2, 0)
  331.         $aStart[$i][1] = Random(0, $iHeight2, 0)
  332.         $aStart[$i][2] = $iExplosion
  333.         $aStart[$i][3] = _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))
  334.     Next
  335.  
  336.  
  337.     While True
  338.         _GDIPlus_GraphicsClear($hGraphics, $iBack)
  339.         If $iSleeping = 0 Then
  340.             For $j = 0 To UBound($aStart) - 1
  341.                 For $i = 0 To 35
  342.                     $aDraw = Dreieck($i * 10, $aStart[$j][2] - $iExplosion)
  343.                     _GDIPlus_GraphicsDrawRect($hGraphics, $aStart[$j][0] + Round($aDraw[0], 0), $aStart[$j][1] + Round($aDraw[1], 0), 2, 2, $aStart[$j][3])
  344.                 Next
  345.                 $aStart[$j][2] += $iExplosionGround + Ceiling(10 * $iExplosion / ($aStart[$j][2]))
  346.                 If $aStart[$j][2] > $iRadius Then
  347.                     $iSleeping = $iSleep
  348.                     $aStart[$j][0] = Random(0, $iWidth2, 0)
  349.                     $aStart[$j][1] = Random(0, $iHeight2, 0)
  350.                     $aStart[$j][2] = $iExplosion
  351.                     _GDIPlus_PenDispose($aStart[$j][3])
  352.                     $aStart[$j][3] = _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))
  353.                 EndIf
  354.             Next
  355.         Else
  356.             $iSleeping -= 1
  357.         EndIf
  358.         _WinAPI_RedrawWindow($hGUI, 0, 0, 2)
  359.     WEnd
  360. EndFunc   ;==>Feuerwerk
  361.  
  362. Func Dreieck($iWinkel, $iLaenge)
  363.     Local $iDeg = 0.0174532925199433, $aRet[2]
  364.     $aRet[0] = Sin($iWinkel * $iDeg) * $iLaenge
  365.     $aRet[1] = Cos($iWinkel * $iDeg) * $iLaenge
  366.     Return $aRet
  367. EndFunc   ;==>Dreieck
  368.  
  369. #endregion FEUERWERK
  370.  
  371.  
  372. ; #FUNCTION# ====================================================================================================================
  373. ; Name...........: _GDIPlus_GraphicsSetClipRect
  374. ; Description ...: Updates the clipping region of a Graphics object to a region that is the combination of itself and a rectangle
  375. ; Syntax.........: _GDIPlus_GraphicsSetClipRect($hGraphics, $nX, $nY, $nWidth, $nHeight[, $iCombineMode = 0])
  376. ; Parameters ....: $hGraphics - Pointer to a Graphics object
  377. ;                  $nX        - X coordinate of the upper-left corner of the rectangle
  378. ;                  $nY        - Y coordinate of the upper-left corner of the rectangle
  379. ;                  $nWidth      - Width of the rectangle
  380. ;                  $nHeight      - Height of the rectangle
  381. ;                  $iCombineMode - Regions combination mode:
  382. ;                  |0 - The existing region is replaced by the new region
  383. ;                  |1 - The existing region is replaced by the intersection of itself and the new region
  384. ;                  |2 - The existing region is replaced by the union of itself and the new region
  385. ;                  |3 - The existing region is replaced by the result of performing an XOR on the two regions
  386. ;                  |4 - The existing region is replaced by the portion of itself that is outside of the new region
  387. ;                  |5 - The existing region is replaced by the portion of the new region that is outside of the existing region
  388. ; Return values .: Success      - True
  389. ;                  Failure      - False and either:
  390. ;                  |@error and @extended are set if DllCall failed
  391. ;                  |$GDIP_STATUS contains a non zero value specifying the error code
  392. ; Remarks .......: None
  393. ; Related .......: None
  394. ; Link ..........; @@MsdnLink@@ GdipSetClipRect
  395. ; Example .......; No
  396. ; ===============================================================================================================================
  397. Func _GDIPlus_GraphicsSetClipRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $iCombineMode = 0)
  398.     Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipRect", "hwnd", $hGraphics, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "int", $iCombineMode)
  399.  
  400.     If @error Then Return SetError(@error, @extended, False)
  401.     $GDIP_STATUS = $aResult[0]
  402.     Return $aResult[0] = 0
  403. EndFunc   ;==>_GDIPlus_GraphicsSetClipRect
  404.  
  405. #region WinAPIEx.au3 functions
  406. Func _WinAPI_GetParentProcess($PID = 0)
  407.     If Not $PID Then
  408.         $PID = _WinAPI_GetCurrentProcessID()
  409.         If Not $PID Then Return SetError(1, 0, 0)
  410.     EndIf
  411.  
  412.     Local $hSnapshot = DllCall('kernel32.dll', 'ptr', 'CreateToolhelp32Snapshot', 'dword', 0x00000002, 'dword', 0)
  413.     If (@error) Or (Not $hSnapshot[0]) Then Return SetError(1, 0, 0)
  414.  
  415.     Local $tPROCESSENTRY32 = DllStructCreate('dword Size;dword Usage;dword ProcessID;ulong_ptr DefaultHeapID;dword ModuleID;dword Threads;dword ParentProcessID;long PriClassBase;dword Flags;wchar ExeFile[260]')
  416.     Local $pPROCESSENTRY32 = DllStructGetPtr($tPROCESSENTRY32)
  417.     Local $Ret, $Result = 0
  418.  
  419.     $hSnapshot = $hSnapshot[0]
  420.     DllStructSetData($tPROCESSENTRY32, 'Size', DllStructGetSize($tPROCESSENTRY32))
  421.     $Ret = DllCall('kernel32.dll', 'int', 'Process32FirstW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
  422.     While (Not @error) And ($Ret[0])
  423.         If DllStructGetData($tPROCESSENTRY32, 'ProcessID') = $PID Then
  424.             $Result = DllStructGetData($tPROCESSENTRY32, 'ParentProcessID')
  425.             ExitLoop
  426.         EndIf
  427.         $Ret = DllCall('kernel32.dll', 'int', 'Process32NextW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
  428.     WEnd
  429.     _WinAPI_CloseHandle($hSnapshot)
  430.     If Not $Result Then Return SetError(1, 0, 0)
  431.     Return $Result
  432. EndFunc   ;==>_WinAPI_GetParentProcess
  433.  
  434. Func _WinAPI_EnumChildProcess($PID = 0)
  435.     If Not $PID Then
  436.         $PID = _WinAPI_GetCurrentProcessID()
  437.         If Not $PID Then Return SetError(1, 0, 0)
  438.     EndIf
  439.  
  440.     Local $hSnapshot = DllCall('kernel32.dll', 'ptr', 'CreateToolhelp32Snapshot', 'dword', 0x00000002, 'dword', 0)
  441.     If (@error) Or (Not $hSnapshot[0]) Then Return SetError(1, 0, 0)
  442.  
  443.     Local $tPROCESSENTRY32 = DllStructCreate('dword Size;dword Usage;dword ProcessID;ulong_ptr DefaultHeapID;dword ModuleID;dword Threads;dword ParentProcessID;long PriClassBase;dword Flags;wchar ExeFile[260]')
  444.     Local $pPROCESSENTRY32 = DllStructGetPtr($tPROCESSENTRY32)
  445.     Local $Ret, $Result[101][2] = [[0]]
  446.  
  447.     $hSnapshot = $hSnapshot[0]
  448.     DllStructSetData($tPROCESSENTRY32, 'Size', DllStructGetSize($tPROCESSENTRY32))
  449.     $Ret = DllCall('kernel32.dll', 'int', 'Process32FirstW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
  450.     While (Not @error) And ($Ret[0])
  451.         If DllStructGetData($tPROCESSENTRY32, 'ParentProcessID') = $PID Then
  452.             $Result[0][0] += 1
  453.             If $Result[0][0] > UBound($Result) - 1 Then
  454.                 ReDim $Result[$Result[0][0] + 100][2]
  455.             EndIf
  456.             $Result[$Result[0][0]][0] = DllStructGetData($tPROCESSENTRY32, 'ProcessID')
  457.             $Result[$Result[0][0]][1] = DllStructGetData($tPROCESSENTRY32, 'ExeFile')
  458.         EndIf
  459.         $Ret = DllCall('kernel32.dll', 'int', 'Process32NextW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
  460.     WEnd
  461.     _WinAPI_CloseHandle($hSnapshot)
  462.     If $Result[0][0] Then
  463.         ReDim $Result[$Result[0][0] + 1][2]
  464.     Else
  465.         Return SetError(1, 0, 0)
  466.     EndIf
  467.     Return $Result
  468. EndFunc   ;==>_WinAPI_EnumChildProcess
  469. #endregion
  470.  
  471. #region Einstellungen - Settings
  472. Func _Settings()
  473.  
  474.     Global $aColor[25][2] = [["Farbe belassen", 0xFFFFFF], _
  475.     ["Rot",        0xFFFF0000],["Grün",       0xFF00FF00],["Blau",       0xFF0000FF],["Schwarz",    0xFF000000],["Maroon",     0xFF800000],["DarkRed",    0xFF8B0000], _
  476.     ["FireBrick",  0xFFB22222],["Salmon",     0xFFFA8072],["OrangeRed",  0xFFFF4500],["Chocolate",  0xFFD2691E],["DarkOrange", 0xFFFF8C00],["Orange",     0xFFFFA500], _
  477.     ["Gold",       0xFFFFD700],["Yellow",     0xFFFFFF00],["YellowGreen",0xFF9ACD32],["GreenYellow",0xFFADFF2F],["Green",      0xFF008000],["Navy",       0xFF000080], _
  478.     ["Purple",     0xFF800080],["Crimson",    0xFFDC143C],["Brown",      0xFFA52A2A],["Gray",       0xFF808080],["Silver",     0xFFC0C0C0],["LightGray",  0xFFD3D3D3]]
  479.  
  480.     Global $Form1, $hImage1, $hImage2,$hListView1,$hListView2,$Button1,$Button2
  481.  
  482.     $Form1 = GUICreate("Einstellungen", 284, 388, 192, 124)
  483.     GUICtrlCreateLabel("Hier können Sie die Einstellungen vornehmen!", 8, 8, 266, 17)
  484.     GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  485.     GUICtrlCreateLabel("HintergrundFarbe:", 8, 48, 114, 17)
  486.     GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  487.     GUICtrlCreateLabel("TextFarbe:", 8, 200, 65, 17)
  488.     GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  489.     $Button1 = GUICtrlCreateButton("Abbrechen", 56, 352, 75, 25)
  490.     $Button2 = GUICtrlCreateButton("Übernehmen", 144, 352, 75, 25)
  491.     ;$List1 = GUICtrlCreateList("", 8, 80, 265, 97)
  492.     $hListView1 = GUICtrlCreateListView("", 8, 80, 265, 97)
  493.     $hListView2 = GUICtrlCreateListView("", 8, 232, 265, 97)
  494.  
  495.     ; Add columns
  496.     _GUICtrlListView_AddColumn($hListView1, "Hintergrundfarbe", 200)
  497.     _GUICtrlListView_AddColumn($hListView2, "Textfarbe", 200)
  498.  
  499.     ; Load images
  500.     $hImage1 = _GUIImageList_Create()
  501.     $hImage2 = _GUIImageList_Create()
  502.     For $l = 0 To 24
  503.         _GUIImageList_Add($hImage1, _GUICtrlListView_CreateSolidBitMap($hListView1, $aColor[$l][1], 16, 16))
  504.         _GUIImageList_Add($hImage2, _GUICtrlListView_CreateSolidBitMap($hListView2, $aColor[$l][1], 16, 16))
  505.         ; Add items
  506.         _GUICtrlListView_AddItem($hListView1, $aColor[$l][0], $l)
  507.         If $l = 0 Then
  508.             _GUICtrlListView_AddItem($hListView2, "Eingestellte Farbe", $l)
  509.         Else
  510.             _GUICtrlListView_AddItem($hListView2, $aColor[$l][0], $l)
  511.         EndIf
  512.     Next
  513.     _GUICtrlListView_SetImageList($hListView1, $hImage1, 1)
  514.     _GUICtrlListView_SetImageList($hListView2, $hImage2, 1)
  515.  
  516.     GUISetState(@SW_SHOW)
  517.  
  518.     While 1
  519.         Switch GUIGetMsg()
  520.             Case $GUI_EVENT_CLOSE, $Button1
  521.                 Exit
  522.             Case $Button2
  523.                 _RegWrite()
  524.         EndSwitch
  525.     WEnd
  526. EndFunc
  527.  
  528. Func _RegWrite()
  529.         Local $index1 = _GUICtrlListView_GetSelectedIndices($hListView1), $index2 = _GUICtrlListView_GetSelectedIndices($hListView2)
  530.         If $index1 < 0 Or $index2 < 0 Then Return MsgBox(0, 'Fehler', 'Bitte in beiden Listen auswählen')
  531.         If $index1 = 0 Then
  532.             For $l = 0 To 23
  533.                 _GUICtrlListView_SetItemChecked($hListView1, $l, False)  ; aber wozu das???  sind doch keine Checkboxen vorhanden
  534.             Next
  535.         Else
  536.             IniWrite("CountdownScreensaver.ini", "Settings", "BgColor", "0x" & Hex( $aColor[$index1][1]))
  537.             ;RegWrite("HKEY_CURRENT_USER\SOFTWARE\CountdownScreensaver", "BgColor", "REG_DWORD", "0x" & Hex( $aColor[$index1][1], 6) )
  538.         ; ConsoleWrite('REG: BgCol: 0x' & Hex($aColor[$index1][1],6) & @CRLF)
  539.         EndIf
  540.         If $index2 = 0 Then
  541.             For $i = 0 To 23
  542.                 _GUICtrlListView_SetItemChecked($hListView2, $i, False)
  543.             Next
  544.         Else
  545.             IniWrite("CountdownScreensaver.ini", "Settings", "TextColor", "0x" & Hex( $aColor[$index2][1]))
  546.             ;RegWrite("HKEY_CURRENT_USER\SOFTWARE\CountdownScreensaver", "TextColor", "REG_DWORD", "0x" & Hex( $aColor[$index2][1], 6) )
  547.     ;       ConsoleWrite('REG: TextCol: 0x' & Hex($aColor[$index2][1],6) & @CRLF)
  548.         EndIf
  549.     EndFunc
  550.  
  551. #endregion Einstellungen - Settings
  552. #endregion BILDSCHIRMSCHOHNER
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement