Advertisement
Facemix

UDF - ImageGUI

Dec 20th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.76 KB | None | 0 0
  1.  
  2. #include <GDIPlus.au3>
  3. #Include <WinAPI.au3>
  4.  
  5. _GDIPlus_Startup()
  6.  
  7. Global Const $SC_DRAGMOVE = 0xF012
  8.  
  9. Func _ImageGUI_Create($Title, $GUIImage, $ExitImage, $MinImage, $X, $Y) ; Erstelle ImageGUI
  10.     ; Lade Images für GUI
  11.     ;_WinAPI_SetLayeredWindowAttributes($HWND, 0x01, 0xFF, 3)
  12.     Global $MainImage = _GDIPlus_ImageLoadFromFile($GUIImage)
  13.     Global $hExit = _GDIPlus_BitmapCreateFromFile($ExitImage)
  14.     Global $hMin = _GDIPlus_BitmapCreateFromFile($MinImage)
  15.     ;==================================================
  16.  
  17.     ; GUIImage Größe ermitteln
  18.     $iWidth = _GDIPlus_ImageGetWidth($MainImage)
  19.     $iHeight = _GDIPlus_ImageGetHeight($MainImage)
  20.     ;==================================================
  21.  
  22.     ; erstelle GUI
  23.     $GUI = GUICreate($Title, $iWidth, $iHeight, $X, $Y, $WS_POPUP, $WS_EX_LAYERED)
  24.     GUISetBkColor(0x01, $GUI)
  25.     ;GUISetState(@SW_SHOW)
  26.     _WinAPI_SetLayeredWindowAttributes($GUI, 0x01, 0xFF, 3)
  27.     ;==================================================
  28.  
  29.     Global $hGrafics1 = _GDIPlus_GraphicsCreateFromHWND($GUI)
  30.  
  31.     ;Exit- und MinImage Größe ermitteln
  32.     $iwExit = _GDIPlus_ImageGetWidth($hExit)
  33.     $ihExit = _GDIPlus_ImageGetHeight($hExit)
  34.     $iwMin = _GDIPlus_ImageGetWidth($hMin)
  35.     $ihMin = _GDIPlus_ImageGetHeight($hMin)
  36.     ;==================================================
  37.  
  38.     ; zeige Grafiken an
  39.     _GDIPlus_GraphicsDrawImage($hGrafics1, $MainImage, 0, 0)
  40.     _GDIPlus_GraphicsDrawImage($hGrafics1, $hExit, $iWidth - $iwExit, 0)
  41.     _GDIPlus_GraphicsDrawImage($hGrafics1, $hMin, $iWidth - $iwExit - $iwMin, 0)
  42.     GUIRegisterMsg($WM_PAINT, "ImageGUI_PAINT")
  43.     ;==================================================
  44.     Return $GUI
  45. EndFunc
  46.  
  47. Func _ImageGUI_CreateSplash($Title, $SplashImage, $Secs, $X, $Y) ; erstellt ein SplashScreen basierend auf GDIPlus
  48.     $SplImage = _GDIPlus_ImageLoadFromFile($SplashImage)
  49.  
  50.     ; SplashImage Größe ermitteln
  51.     $iWidth = _GDIPlus_ImageGetWidth($SplImage)
  52.     $iHeight = _GDIPlus_ImageGetHeight($SplImage)
  53.  
  54.     ; erstelle SplashGUI
  55.     $hSplash = GUICreate($Title, $iWidth, $iHeight, $X, $Y, $WS_POPUP, $WS_EX_LAYERED)
  56.     GUISetBkColor(0x01, $hSplash)
  57.     GUISetState(@SW_SHOW)
  58.     _WinAPI_SetLayeredWindowAttributes($hSplash, 0x01, 0xFF, 3)
  59.  
  60.     $hSplGrafics = _GDIPlus_GraphicsCreateFromHWND($hSplash)
  61.  
  62.     ; zeige Grafiken an
  63.     _GDIPlus_GraphicsDrawImage($hSplGrafics, $SplImage, 0, 0)
  64.  
  65.     For $i = $Secs To 0 Step -1
  66.         Sleep(1000)
  67.         If $i = 0 Then
  68.             _GDIPlus_GraphicsDispose($hSplGrafics)
  69.             _GDIPlus_Shutdown()
  70.             Exit
  71.         EndIf
  72.     Next
  73.  
  74.     Return $hSplash
  75. EndFunc
  76.  
  77.  
  78. ; Grafiken anzeigen
  79. Func ImageGUI_PAINT($hWnd, $Msg, $wParam, $lParam)
  80.  
  81.     ;Exit-, Max- und MinImage Größe ermitteln
  82.     $iwExit = _GDIPlus_ImageGetWidth($hExit)
  83.     $ihExit = _GDIPlus_ImageGetHeight($hExit)
  84.     $iwMin = _GDIPlus_ImageGetWidth($hMin)
  85.     $ihMin = _GDIPlus_ImageGetHeight($hMin)
  86.  
  87.     ; GUIImage Größe ermitteln
  88.     $iWidth = _GDIPlus_ImageGetWidth($MainImage)
  89.     $iHeight = _GDIPlus_ImageGetHeight($MainImage)
  90.     ; Grafiken anzeigen
  91.     _GDIPlus_GraphicsDrawImage($hGrafics1, $MainImage, 0, 0)
  92.     _GDIPlus_GraphicsDrawImage($hGrafics1, $hExit, $iWidth - $iwExit, 0)
  93.     _GDIPlus_GraphicsDrawImage($hGrafics1, $hMin, $iWidth - $iwExit - $iwMin, 0)
  94. ;~     _WinAPI_RedrawWindow($hGUI, 0, 0, 1)
  95.     Return $GUI_RUNDEFMSG
  96. EndFunc
  97.  
  98.  
  99. Func _ImageGUI_GetWidth($ImageGetSize) ; ermittelt die Breitengröße der Grafik
  100.     $BigImage = _GDIPlus_ImageLoadFromFile($ImageGetSize)
  101.     $iW = _GDIPlus_ImageGetWidth($BigImage)
  102.     Return $iW
  103. EndFunc
  104.  
  105. Func _ImageGUI_GetHeight($ImageGetSize) ; ermittelt die Höhengröße der Grafik
  106.     $BigImage = _GDIPlus_ImageLoadFromFile($ImageGetSize)
  107.     $iH = _GDIPlus_ImageGetHeight($BigImage)
  108.     Return $iH
  109. EndFunc
  110.  
  111.  
  112. Func _Exit()
  113.     _GDIPlus_GraphicsDispose($hGrafics1)
  114.     ;_GDIPlus_GraphicsDispose($hSplGrafics)
  115.     ;_GDIPlus_ImageDispose()
  116.     ;_GDIPlus_BitmapDispose()
  117.     _GDIPlus_Shutdown()
  118.     Exit
  119. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement