Luigi Posted December 25, 2011 Share Posted December 25, 2011 (edited) Greetings! Merry christmas! ^^Hi search many examples in the forum using png alpha, but all examples change alpha in a new GUI or change alpha from all elements from a new GUI.I seek a example for change a alpha for only one element from solid GUI.I build a didatic example and build a lamp off whit a slicer comand change your bright. For this I thinking build a solid GUI, with a pic's lamp off, with a lamp on with 100% transparency over lamp off, when slicer is changed, the alpha from lamp on is changed too...The problem is to find a example to change only element with another elements on GUI, not all in same time...Someone can help me?Best regards.Detefon.---I am use this UDF but the transparency work with bmp pic only (not png), and have not transparency...expandcollapse popup#include-once #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #Include <APIConstants.au3> #Include <WinAPIEx.au3> Opt("MustDeclareVars", 1) Global $GUI Global $Group01 Global $Botton01 Global $SliText, $Slider Global $Button01Status Global $Lamp, $msg, $on, $off Global $hForm, $Msg, $Pic, $tSIZE, $W, $H, $hBitmap Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 $hBitmap = _WinAPI_LoadImage(0, "on.bmp", $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE) $tSIZE = _WinAPI_GetBitmapDimension($hBitmap) $W = DllStructGetData($tSIZE, "X") $H = DllStructGetData($tSIZE, "Y") $GUI = GUICreate("Switch",250,450,-1,-1) $Group01 = GUICtrlCreateGroup("",25,125,100,300) $Botton01 = GUICtrlCreateCheckbox("Light 01",45,150,70,27) $Slider = GUICtrlCreateSlider(50,180,60,240,$TBS_VERT) $Lamp = GUICtrlCreatePic("",25,15,100,100) $SliText = GUICtrlCreateLabel(255,150,180,40,27) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlSetLimit($Slider, 255, 0) GUICtrlSetData ($Slider, 255) $Pic = GUICtrlCreatePic("", 125, 15, $W, $H) GUICtrlCreateGraphic(0, $H, $W, 1) GUICtrlSetBkColor(-1, 0xDFDFDF) GUISetState() _SetBitmapAlpha($Pic, $hBitmap, 255) GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") If FileExists("config.ini") = 0 Then IniWrite("config.ini","Lamp","01",4) $Button01Status = Number(IniRead("config.ini","Lamp","01",4)) Switch $Button01Status Case 1 GUICtrlSetImage($Lamp,"on.jpg") GUICtrlSetState($Botton01,$GUI_CHECKED) Case 4 GUICtrlSetImage($Lamp,"off.jpg") GUICtrlSetState($Botton01,$GUI_UNCHECKED) Case Else GUICtrlSetImage($Lamp,"off.jpg") GUICtrlSetState($Botton01,$GUI_UNCHECKED) EndSwitch While 1 $msg = GUIGetMsg() Switch $msg Case -3 _Exit() Case $Botton01 _Botton01() EndSwitch WEnd Func _Botton01() Switch GUICtrlRead($Botton01) Case 1 GUICtrlSetImage($Lamp,"on.jpg") Case 4 GUICtrlSetImage($Lamp,"off.jpg") EndSwitch EndFunc Func _Exit() IniWrite("config.ini","Lamp","01",GUICtrlRead($Botton01)) Exit EndFunc Func WM_VSCROLL($hWnd, $iMsg, $iwParam, $ilParam) GUICtrlSetData($SliText,GUICtrlRead($Slider)) Switch _WinAPI_GetDlgCtrlID($ilParam) Case $Slider _SetBitmapAlpha($Pic, $hBitmap, GUICtrlRead($Slider)) EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _SetBitmapAlpha($hWnd, $hBitmap, $iAlpha) Local $tRECT, $tSIZE, $W[2], $H[2], $hDC, $hDestDC, $hDestSv, $hSrcDC, $hSrcSv, $hBmp, $hObj If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If Not $hWnd Then Return 0 EndIf EndIf $tRECT = _WinAPI_GetClientRect($hWnd) $W[0] = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1) $H[0] = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) $tSIZE = _WinAPI_GetBitmapDimension($hBitmap) $W[1] = DllStructGetData($tSIZE, 1) $H[1] = DllStructGetData($tSIZE, 2) $hDC = _WinAPI_GetDC($hWnd) $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $hBmp = _WinAPI_CreateCompatibleBitmapEx($hDC, $W[0], $H[0], 0xD4D0C8) $hDestSv = _WinAPI_SelectObject($hDestDC, $hBmp) $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap) _WinAPI_AlphaBlend($hDestDC, 0, 0, $W[0], $H[0], $hSrcDC, 0, 0, $W[1], $H[1], $iAlpha, 0) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_DeleteDC($hDestDC) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hSrcDC) _WinAPI_ReleaseDC($hWnd, $hDC) $hObj = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp) If $hObj Then _WinAPI_DeleteObject($hObj) EndIf $hObj = _SendMessage($hWnd, $STM_GETIMAGE) If $hObj <> $hBmp Then _WinAPI_DeleteObject($hBmp) EndIf Return 1 EndFunc ;==>_SetBitmapAlphaon.bmp Edited December 26, 2011 by detefon Visit my repository Link to comment Share on other sites More sharing options...
Luigi Posted December 26, 2011 Author Share Posted December 26, 2011 (edited) Sorry my insistence... perhaps I unknow correcty way to search the answer for my doubt... I searching for: "fade + png" and try many examples, but all examples change an alpha's child GUI, I dont want this... I want change the alpha for a GUI's element, like example above, to put a light in on lamp. Someone can tell me a correct terms to search please? ^^ Thanks. Edited December 26, 2011 by detefon Visit my repository Link to comment Share on other sites More sharing options...
taietel Posted December 27, 2011 Share Posted December 27, 2011 (edited) datefon, test this with the two pictures and see if it's ok when you move the slider:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> _Test() Func _Test() Local $hMain = GUICreate("Form1", 220, 310) Local $hTrans = GUICtrlCreateSlider(10, 280, 200, 25, 0) GUICtrlSetLimit(-1, 254, 0) Local $hWhite = _Child($hMain, 200, 260, 10, 10) Local $hPicWhite = GUICtrlCreatePic("", 0, 0, 200, 260) _SetPNGIntoPicControl($hPicWhite, @ScriptDir & "1.png") Local $hYellow = _Child($hMain, 200, 260, 10, 10) Local $hPicYellow = GUICtrlCreatePic("", 0, 0, 200, 260) _SetPNGIntoPicControl($hPicYellow, @ScriptDir & "2.png") WinSetTrans($hYellow, "", 0) GUISetState(@SW_SHOW, $hMain) GUISetState(@SW_SHOW, $hWhite) GUISetState(@SW_SHOW, $hYellow) While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hTrans WinSetTrans($hYellow, "", GUICtrlRead($hTrans)) EndSwitch WEnd EndFunc ;==>_Test Func _Child($hParent, $iW, $iH, $iX, $iY) Local $hChild = GUICreate("", $iW - $iX - 5, $iH - $iY - 10, $iX, $iY + 6, $WS_POPUP, $WS_EX_MDICHILD, $hParent) Return $hChild EndFunc ;==>_Child Func _SetPNGIntoPicControl($iPic, $sPNGFile) ;thanks to Monoscout _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sPNGFile) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x172, 0, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>_SetPNGIntoPicControlImages: 1.png, 2.png Edited December 27, 2011 by taietel Luigi 1 Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Luigi Posted December 27, 2011 Author Share Posted December 27, 2011 Thanky you for you reply taietel! You example works! I'll study your script carefully. But I have some questions, I see that you wrote two GUICreate(), and I presumed have one GUI over another GUI, is correctly? If yes, this is a commum way to write this or should be so this way? I assume that work with PNG should be easier, but I intend to build this script otherwise, instead of having a light on over the off, I would put a mask as if it were only light I could have a single lamp erased with various colors of lights. So how to do something like this is a CHILD with the color of light for every lamp off? I accept suggestions. ^^ Visit my repository Link to comment Share on other sites More sharing options...
taietel Posted December 27, 2011 Share Posted December 27, 2011 Yes, there are child gui's that hold the pictures. The one with the lamp on is transparent. I'm sure there are other ways to handle the mask for the png, but this is the first solution I had in mind. Another solution would be using colour matrix: expandcollapse popup#include <GDIPlus.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <misc.au3> ; Colour Matrix Reference Sites (some) ; http://www.codeproject.com/KB/GDI-plus/colormatrix.aspx ; http://boredzo.org/blog/archives/category/...hics/core-image ; http://www.reflectiveimages.com/digitalvelvia.htm ; http://www.imagemagick.org/Usage/color/ ; http://blog.zacharcher.com/2007/10/ ; Big Thanks Siao ;http://www.autoitscript.com/forum/index.php?s=&showtopic=69930&view=findpost&p=513472 Opt("GUIOnEventMode", 0) Opt('MustDeclareVars', 1) HotKeySet("{ESC}", "Quit") Opt("GUICloseOnESC", 0) Global $dll = DllOpen("user32.dll") Global $iOpacity = 255 Global Const $STM_SETIMAGE = 0x0172 ;Local Const $ULW_ALPHA = 2 ;Global Const $IMAGE_BITMAP = 0 ;Global Const $WM_LBUTTONDOWN = 0x0201 ; Drag Window 1 of 3 addin Global $hBitmap, $hImage, $hImage1, $hGui1, $MatMenuChk = 0, $OrigImageChk = 0 Global $hGui, $hBitmapG, $hGraphic, $hGraphicG, $num, $hWnd, $hDC Global $hBitmapG1, $hGraphic1, $hWnd1, $hDC1, $hGraphicG1, $tColorMatrix Global $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend, $m, $n Global $ColMatBut1, $ColMatBut2, $ColMatBut3, $ColMatBut4, $Combo1 Global $ColMatForm, $comboData, $iX, $iY, $Add2MatrixStr Global $ContextMenu, $viewOrigImg, $viewMatrix, $Demos, $PreSetMat, $ChangeColMat, $MenuItemExit Global $separator1, $Cell[26], $init = 1 Global $LastMatrix, $num Global $a,$b,$c ; To use inside matrix in display. e.g. Assign( "a",0.9) = 1; $a = 0.9 Global $CA[17][26] = [[ "Identity Martix", 1, 0, 0, 0, 0, _ 0, 1, 0, 0, 0, _ 0, 0, 1, 0, 0, _ 0, 0, 0, 1, 0, _ 0, 0, 0, 0, 1], _ [ "Gray Shade", 0.3, 0.3, 0.3, 0, 0, 0.59, 0.59, 0.59, 0, 0, _ 0.11, 0.11, 0.11, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "Pink Shade", 0.4, 0.3, 0.3, 0, 0, 0.7, 0.59, 0.59, 0, 0, _ 0.2, 0.11, 0.11, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "Yellow Shade", 0.4, 0.4, 0.3, 0, 0, 0.7, 0.7, 0.59, 0, 0, _ 0.2, 0.2, 0.11, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "Green Shade", 0.3, 0.4, 0.3, 0, 0, 0.59, 0.7, 0.59, 0, 0, _ 0.11, 0.2, 0.11, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "Blue Shade", 0.3, 0.3, 0.4, 0, 0, 0.59, 0.59, 0.7, 0, 0, _ 0.11, 0.11, 0.2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "Gray Shade Alternate", 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, _ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0.2, 0.2, 0.2, 0, 1], _ [ "Brighter", 1.5, 0, 0, 0, 0, 0, 1.5, 0, 0, 0, _ 0, 0, 1.5, 0, 0, 0, 0, 0, 1, 0, 0.05, 0.05, 0.05, 0, 1], _ [ "Colour Boost", 1.4, 0, 0, 0, 0, 0, 1.4, 0, 0, 0, _ 0, 0, 1.4, 0, 0, 0, 0, 0, 1, 0, -0.2, -0.2, -0.2, 0, 1], _ [ "Swap Color RGB2GBR", 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, _ 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ ["Swap Color RGB2BRG", 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, _ 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ ["Swap Color RGB2RBG", 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, _ 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "Swap Colors Transparent", 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, _ 1, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 1], _ ["Trial insert in array", 0.7, 0, 0, 0, 0, 0, -0.9, 0, 0, 0, _ 0, 0, -0.9, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "All White", 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, _ 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 01, 1], _ [ "All Black", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], _ [ "Test Martix", 0xff / 0xff + 0.11, 0, 0, 0, 0, _ 0, Assign( "a",0.9), 0, 0, 0, _ 0, 0, -$a/3, 0, 0, _ 0, 0, 0, 1, 0, _ 0, 0, 0, 0, 1 ]] ; In the ReadMat() Function, Execute(GUICtrlRead($Cell[$P])) is used to read Matrix data displayed. ; Test Matrix above works Local $iI, $iSize, $tBits, $tBMI, $hDC $LastMatrix = UBound($CA, 1) - 1 $num = $LastMatrix ColorMatForm() _GDIPlus_Startup () Local $ImageSrce, $Button1, $Button2, $Button3, $Button4, $Label1 $ImageSrce = GUICreate("Source of Image", 204, 221, 351, 250, BitOR($WS_DLGFRAME, $WS_CLIPSIBLINGS)) GUISetIcon("D:002.ico") GUISetBkColor(0xFFFFE1) $Button1 = GUICtrlCreateButton("Screen Capture", 33, 37, 127, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetTip($Button1, "Capture Top Left quarter of desktop") $Button2 = GUICtrlCreateButton("Download Image", 34, 77, 127, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetTip($Button2, "If the 'autoit_builder_wall_800x600.jpg' file (122KB) is not in this script directory" & @CRLF & _ "The file will auto-download from www.autoitscript.com, and be saved to this script directory. ") $Button3 = GUICtrlCreateButton("Open File ", 34, 117, 127, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetTip($Button3, "Opens Dialog for selection of an image.") $Button4 = GUICtrlCreateButton("Exit", 61, 157, 75, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFF0000) $Label1 = GUICtrlCreateLabel("Choose Image Source", 7, 4, 192, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $Button4 Exit Case $Button1 $hBitmap = _ScreenCapture_Capture ("", 0, 0, @DesktopWidth / 2.1, @DesktopHeight / 2.1, False) If Not @error Then ExitLoop Case $Button2 If Not FileExists("autoit_builder_wall_800x600.jpg") Then InetGet("http://www.autoitscript.com/autoit3/files/graphics/autoit_builder_wall_800x600.jpg", _ @ScriptDir & "autoit_builder_wall_800x600.jpg", 1, 0) ;While @InetGetActive ; TrayTip("Downloading", "Bytes = " & @InetGetBytesRead, 10, 16) ; Sleep(250) ;Wend EndIf Local $hImg = _GDIPlus_ImageLoadFromFile (@ScriptDir & "autoit_builder_wall_800x600.jpg") If $hImg = 0 Then SetError(1, 0, 0) $hBitmap = _GDIPlus_ImageCreateGDICompatibleHBITMAP($hImg) _GDIPlus_ImageDispose ($hImg) If Not @error Then ExitLoop Case $Button3 Local $Path = FileOpenDialog("Choose Image File", @ScriptDir & "", _ "Images (*.gif;*.png;*.jpg;*.bmp)| All (*.*)") If $Path <> "" Then Local $hImg = _GDIPlus_ImageLoadFromFile ($Path) If $hImg = 0 Then SetError(1, 0, 0) Local $hBitmap = _GDIPlus_ImageCreateGDICompatibleHBITMAP($hImg) _GDIPlus_ImageDispose ($hImg) If Not @error Then ExitLoop EndIf EndSwitch WEnd GUIDelete($ImageSrce) Opt("GUIOnEventMode", 1) ShowaColMatFrm() $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap) $iX = _GDIPlus_ImageGetWidth ($hImage) $iY = _GDIPlus_ImageGetHeight ($hImage) _WinAPI_DeleteObject ($hBitmap) $hGui = GUICreate("GDI+", $iX, $iY, 10, 10, $WS_POPUP, $WS_EX_LAYERED) ;BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; Drag Window 2 of 3 addin GUISetState(@SW_HIDE, $hGui) ;@SW_SHOW $hWnd = _WinAPI_GetDC ($hGui) $hDC = _WinAPI_CreateCompatibleDC ($hWnd) $hBitmapG = _WinAPI_CreateCompatibleBitmap ($hWnd, $iX, $iY) ; $iWidth, $iHeight) _WinAPI_SelectObject ($hDC, $hBitmapG) $hGraphicG = _GDIPlus_GraphicsCreateFromHDC ($hDC) _GDIPlus_GraphicsDrawImage ($hGraphicG, $hImage, 0, 0) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $iX) ;$iWidth ) DllStructSetData($tSize, "Y", $iY) ;$iHeight) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow ($hGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) $hGui1 = GUICreate("GDI1", $iX, $iY, $iX, 20, $WS_POPUP, $WS_EX_LAYERED) ; BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) $ContextMenu = GUICtrlCreateContextMenu() $viewOrigImg = GUICtrlCreateMenuItem("Show Original Image", $ContextMenu) GUICtrlSetOnEvent($viewOrigImg, "ShowaOrig") GUICtrlSetState($viewOrigImg, $GUI_UNCHECKED) $viewMatrix = GUICtrlCreateMenuItem("Show Matrix", $ContextMenu) GUICtrlSetOnEvent($viewMatrix, "ShowaColMatFrm") GUICtrlSetState($viewMatrix, $GUI_CHECKED) $Demos = GUICtrlCreateMenu("Demos", $ContextMenu) $PreSetMat = GUICtrlCreateMenuItem("Preset Matrices - Press Crtl key to scroll thru array of matrices.", $Demos) GUICtrlSetOnEvent($PreSetMat, "ScrollMatArray") $ChangeColMat = GUICtrlCreateMenuItem("Auto Change Colors (Press Shift once) @ Esc once to stop", $Demos) GUICtrlSetOnEvent($ChangeColMat, "AutoColChange") $separator1 = GUICtrlCreateMenuItem("", $ContextMenu) ; create a separator line $MenuItemExit = GUICtrlCreateMenuItem("Exit (Esc)", $ContextMenu) GUICtrlSetOnEvent($MenuItemExit, "Quit") GUISetState() $hWnd1 = _WinAPI_GetDC ($hGui1) $hDC1 = _WinAPI_CreateCompatibleDC ($hWnd1) $hImage1 = $hImage While 1 If _IsPressed("11") Or $init = 1 Then ;Ctrl key and initial run ScrollMatArray() EndIf If _IsPressed("A1") Or _IsPressed("A0") Then ; Right Shift and Left Shift keys AutoColChange() EndIf $init = 0 Sleep(10) WEnd DllClose($dll) _GDIPlus_GraphicsDispose ($hGraphicG) _WinAPI_ReleaseDC ($hGui, $hWnd) _WinAPI_DeleteObject ($hBitmap) _WinAPI_DeleteDC ($hDC) _GDIPlus_ImageDispose ($hImage) _WinAPI_ReleaseDC ($hGui1, $hWnd1) _WinAPI_DeleteDC ($hDC1) _GDIPlus_ImageDispose ($hImage1) _GDIPlus_Shutdown () ; Displays image with the applied matrix Func ImageMatrix() Local $pSize1, $tSize1, $pSource1, $tSource1, $pBlend1, $tBlend1, $tColorMatrix Local $x, $hImgAttrib, $iW = _GDIPlus_ImageGetWidth ($hImage1), _ $iH = _GDIPlus_ImageGetHeight ($hImage1), $hGraphics, $hBitmap $hBitmapG1 = _WinAPI_CreateCompatibleBitmap ($hWnd1, $iX, $iY) ; $iWidth, $iHeight) _WinAPI_SelectObject ($hDC1, $hBitmapG1) $hGraphicG1 = _GDIPlus_GraphicsCreateFromHDC ($hDC1) $tColorMatrix = DllStructCreate("float[5];float[5];float[5];float[5];float[5]") ;; Loads current Matrix int matrix display Gui LoadMat2Display($num) ;;Color adjustment values: $x = DllStructSetData($tColorMatrix, 1, $CA[$num][1], 1) * DllStructSetData($tColorMatrix, 1, $CA[$num][2], 2) * _ DllStructSetData($tColorMatrix, 1, $CA[$num][3], 3) * DllStructSetData($tColorMatrix, 2, $CA[$num][6], 1) * _ DllStructSetData($tColorMatrix, 2, $CA[$num][7], 2) * DllStructSetData($tColorMatrix, 2, $CA[$num][8], 3) * _ DllStructSetData($tColorMatrix, 3, $CA[$num][11], 1) * DllStructSetData($tColorMatrix, 3, $CA[$num][12], 2) * _ DllStructSetData($tColorMatrix, 3, $CA[$num][13], 3) * DllStructSetData($tColorMatrix, 4, $CA[$num][19], 4) * _ DllStructSetData($tColorMatrix, 5, $CA[$num][21], 1) * DllStructSetData($tColorMatrix, 5, $CA[$num][22], 2) * _ DllStructSetData($tColorMatrix, 5, $CA[$num][23], 3) * _ DllStructSetData($tColorMatrix, 5, $CA[$num][24], 4) * DllStructSetData($tColorMatrix, 5, $CA[$num][25], 5) ;;create an image attributes object and update its color matrix $hImgAttrib = _GDIPlus_ImageAttributesCreate() _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, 1, DllStructGetPtr($tColorMatrix)) ;;draw original into copy with attributes _GDIPlus_GraphicsDrawImageRectRectEx($hGraphicG1, $hImage1, 0, 0, $iW, $iH, 0, 0, $iW, $iH, 2, $hImgAttrib) $tSize1 = DllStructCreate($tagSIZE) $pSize1 = DllStructGetPtr($tSize1) DllStructSetData($tSize1, "X", $iX) ;$iWidth ) DllStructSetData($tSize1, "Y", $iY) ;$iHeight) $tSource1 = DllStructCreate($tagPOINT) $pSource1 = DllStructGetPtr($tSource1) $tBlend1 = DllStructCreate($tagBLENDFUNCTION) $pBlend1 = DllStructGetPtr($tBlend1) DllStructSetData($tBlend1, "Alpha", $iOpacity) DllStructSetData($tBlend1, "Format", 1) _WinAPI_UpdateLayeredWindow ($hGui1, $hWnd1, 0, $pSize1, $hDC1, $pSource1, 0, $pBlend1, $ULW_ALPHA) ;;clean up _GDIPlus_GraphicsDispose ($hGraphics) _GDIPlus_GraphicsDispose ($hGraphicG1) _GDIPlus_ImageAttributesDispose($hImgAttrib) _WinAPI_DeleteObject ($hBitmap) _WinAPI_DeleteObject ($hBitmapG1) Return 1 EndFunc ;==>ImageMatrix Func _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, $iColorAdjustType, _ $pColorMatrix = 0, $pGreyMatrix = 0, $iColorMatrixFlags = 0) Local $fEnable = 1, $aResult = DllCall($ghGDIPDll, "int", _ "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", $iColorAdjustType, _ "int", $fEnable, "ptr", $pColorMatrix, "ptr", $pGreyMatrix, "int", $iColorMatrixFlags) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_ImageAttributesSetColorMatrix ;;Creates ImageAttributes object Func _GDIPlus_ImageAttributesCreate() Local $aResult = DllCall($ghGDIPDll, "int", _ "GdipCreateImageAttributes", "ptr*", 0) Return SetError($aResult[0], 0, $aResult[1]) EndFunc ;==>_GDIPlus_ImageAttributesCreate ;;Deletes ImageAttributes object Func _GDIPlus_ImageAttributesDispose($hImgAttrib) Local $aResult = DllCall($ghGDIPDll, "int", _ "GdipDisposeImageAttributes", "ptr", $hImgAttrib) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_ImageAttributesDispose ; _GDIPlus_GraphicsDrawImageRectRectEx() ; Same as _GDIPlus_GraphicsDrawImageRectRect(), ; but adds 1 optional parameter - $hImgAttrib (handle to ImageAttributes object) Func _GDIPlus_GraphicsDrawImageRectRectEx($hGraphics, $hImage, $iSrcX, $iSrcY, $iSrcWidth, _ $iSrcHeight, $iDstX, $iDstY, $iDstWidth, $iDstHeight, $iUnit = 2, $hImgAttrib = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", _ $hGraphics, "hwnd", $hImage, "int", $iDstX, "int", _ $iDstY, "int", $iDstWidth, "int", $iDstHeight, "int", $iSrcX, "int", $iSrcY, "int", _ $iSrcWidth, "int", $iSrcHeight, "int", $iUnit, "ptr", $hImgAttrib, "int", 0, "int", 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectEx ; Demo - Scroll thru Matrix Array Func ScrollMatArray() $init = 0 $num = Mod($num + 1, $LastMatrix + 1) ;$num = 13 GUICtrlSetData($Combo1, $CA[$num][0]) ImageMatrix() Return 1 EndFunc ;==>ScrollMatArray ; Demo - Auto Colour Change Func AutoColChange() If $init = 2 Then $init = 0 Else $init = 2 $num = 0 LoadMat2Display($num) $num = $LastMatrix GUICtrlSetData($Combo1, $CA[$num][0]) EndIf While $init = 2 If _IsPressed("11") Or _IsPressed("1B") Then ExitLoop ;CTRL key and Escape key $m = Mod($m + 1, 20) $n = Mod($n + 1, 24) $CA[$LastMatrix][1] = -($m - 8) / 10 $CA[$LastMatrix][7] = ($m - 10) / 10 $CA[$LastMatrix][13] = -($n - 12) / 10 ImageMatrix() Sleep(1000) WEnd $init = 0 Sleep(800) Return 1 EndFunc ;==>AutoColChange ; Toggles show/hide original image Func ShowaOrig() If $OrigImageChk = 1 Then GUICtrlSetState($viewOrigImg, $GUI_UNCHECKED) GUISetState(@SW_HIDE, $hGui) $OrigImageChk = 0 Else GUICtrlSetState($viewOrigImg, $GUI_CHECKED) GUISetState(@SW_SHOW, $hGui) $OrigImageChk = 1 EndIf Return 1 EndFunc ;==>ShowaOrig ; Toggles show/hide matrix Gui Func ShowaColMatFrm() If $MatMenuChk = 1 Then GUICtrlSetState($viewMatrix, $GUI_UNCHECKED) GUISetState(@SW_HIDE, $ColMatForm) $MatMenuChk = 0 Else GUICtrlSetState($viewMatrix, $GUI_CHECKED) GUISetState(@SW_SHOW, $ColMatForm) $MatMenuChk = 1 EndIf ; ;MsgBox(0,"",GUICtrlRead($viewMatrix)) Return 1 EndFunc ;==>ShowaColMatFrm ;When selection in combo, load corresponding matrix Func ComboLoadMatDat() Local $dat, $f $dat = GUICtrlRead($Combo1) For $f = 0 To $LastMatrix If $CA[$f][0] = $dat Then $num = $f Next ;ReadMat($num) ;GUICtrlSetData($Combo1, $CA[$num][0]) ImageMatrix() Return 1 EndFunc ;==>ComboLoadMatDat ; Loads current Matrix int matrix display Gui Func LoadMat2Display($number = $LastMatrix) If $MatMenuChk = 1 Then For $P = 1 To 25 GUICtrlSetData($Cell[$P], $CA[$number][$P]) Next EndIf Return 1 EndFunc ;==>LoadMat2Display ;When Apply Matrix is pressed, Stores Matrix's element values to last matrix in array Func ApplyColMat() $num = $LastMatrix ReadMat($num) GUICtrlSetData($Combo1, $CA[$num][0]) ImageMatrix() Return 1 EndFunc ;==>ApplyColMat ; Reads Matrix in Gui and enters into last matrix in array of matrices Func ReadMat($number = $LastMatrix) For $P = 1 To 25 $CA[$number][$P] = Execute(GUICtrlRead($Cell[$P])) Next Return 1 EndFunc ;==>ReadMat ; To save matrix data - writes to console. Formatted to copy into $CA matrix array at top of script. Func WriteConsole() $Add2MatrixStr &= "[" & '"' & "Change to your label" & '"' & ", " For $x = 1 To 10 $Add2MatrixStr &= $CA[$LastMatrix][$x] & ", " Next $Add2MatrixStr &= "_" & @CRLF For $x = 11 To 25 $Add2MatrixStr &= $CA[$LastMatrix][$x] & ", " Next $Add2MatrixStr = StringTrimRight($Add2MatrixStr, 2) $Add2MatrixStr &= "], _" & @CRLF & @CRLF ConsoleWrite($Add2MatrixStr) ConsoleWrite("Copy above matrix. Insert between existing matrices in declaration of Global $CA[14][26]" & @CRLF & _ " in script. Also, increase number of matrices in array. " & @CRLF & _ "eg. if $CA[14][26] increase to $CA[15][26] Then re-run script. " & @CRLF) EndFunc ;==>WriteConsole ;Saves generated image to disk Func SaveImage() Local $ext, $sCLSID Local $Path = FileSaveDialog("Save Current Image", @ScriptDir, "Images (*.gif;*.png;*.jpg;*.bmp)| All (*.*)", 16) If $Path <> "" Then $ext = StringUpper(StringRight($Path, 3)) If $ext = "GIF" Or $ext = "PNG" Or $ext = "JPG" Or $ext = "BMP" Then $sCLSID = _GDIPlus_EncodersGetCLSID ($ext) ;$SaveFlag = 1 ApplyColMat() Local $tColorMatrix, $x, $hImgAttrib, $iW = _GDIPlus_ImageGetWidth ($hImage1) Local $iH = _GDIPlus_ImageGetHeight ($hImage1), $hGraphics Local $hGraphics2, $hBitmap ;;create color matrix data $tColorMatrix = DllStructCreate("float[5];float[5];float[5];float[5];float[5]") LoadMat2Display($num) $x = DllStructSetData($tColorMatrix, 1, $CA[$num][1], 1) * DllStructSetData($tColorMatrix, 1, $CA[$num][2], 2) * _ DllStructSetData($tColorMatrix, 1, $CA[$num][3], 3) * DllStructSetData($tColorMatrix, 2, $CA[$num][6], 1) * _ DllStructSetData($tColorMatrix, 2, $CA[$num][7], 2) * DllStructSetData($tColorMatrix, 2, $CA[$num][8], 3) * _ DllStructSetData($tColorMatrix, 3, $CA[$num][11], 1) * DllStructSetData($tColorMatrix, 3, $CA[$num][12], 2) * _ DllStructSetData($tColorMatrix, 3, $CA[$num][13], 3) * DllStructSetData($tColorMatrix, 4, $CA[$num][19], 4) * _ DllStructSetData($tColorMatrix, 5, $CA[$num][21], 1) * DllStructSetData($tColorMatrix, 5, $CA[$num][22], 2) * _ DllStructSetData($tColorMatrix, 5, $CA[$num][23], 3) * _ DllStructSetData($tColorMatrix, 5, $CA[$num][24], 4) * DllStructSetData($tColorMatrix, 5, $CA[$num][25], 5) ;;create an image attributes object and update its color matrix $hImgAttrib = _GDIPlus_ImageAttributesCreate() _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, 1, DllStructGetPtr($tColorMatrix)) ;;copy image $hGraphics = _GDIPlus_ImageGetGraphicsContext ($hImage1) $hBitmap = _GDIPlus_BitmapCreateFromGraphics ($iW, $iH, $hGraphics) $hGraphics2 = _GDIPlus_ImageGetGraphicsContext ($hBitmap) ;;draw original into copy with attributes _GDIPlus_GraphicsDrawImageRectRectEx($hGraphics2, $hImage1, 0, 0, $iW, $iH, 0, 0, $iW, $iH, 2, $hImgAttrib) ;;clean up _GDIPlus_GraphicsDispose ($hGraphics) _GDIPlus_GraphicsDispose ($hGraphics2) _GDIPlus_ImageAttributesDispose($hImgAttrib) ; Save image _GDIPlus_ImageSaveToFileEx ($hBitmap, $Path, $sCLSID) _GDIPlus_GraphicsDispose ($hGraphics) _GDIPlus_GraphicsDispose ($hGraphics2) _GDIPlus_ImageAttributesDispose($hImgAttrib) _GDIPlus_ImageDispose ($hBitmap) EndIf EndIf Return 1 EndFunc ;==>SaveImage ; If in Auto-generate demo Esc exits that loop. Otherwise, exits script. Func Quit() Local $e If $init = 2 Then ; For AutoColChange() while loop $init = 0 Else $e = MsgBox(1, "Exit", "Press OK to Exit") If $e = 1 Then Exit EndIf Return 1 EndFunc ;==>Quit ; The Gui contains matrix data display, buttons and combobox of pre-defined matrices from array. Func ColorMatForm() Local $Group1, $Group2, $Group3, $Group4, $Group5, $Group6, $Group7, $Label1, $Label2 $ColMatForm = GUICreate("Form1", 775, 243, 290, @DesktopHeight * 0.7, BitOR($WS_POPUP, $WS_BORDER)) $Group1 = GUICtrlCreateGroup("Color Matrix 5x5", 6, 4, 760, 197) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Group2 = GUICtrlCreateGroup(" Red ", 148, 19, 137, 101) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Cell[1] = GUICtrlCreateInput("0xff / 0xff + 0.11", 154, 36, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[2] = GUICtrlCreateInput("0", 293, 36, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[3] = GUICtrlCreateInput("0", 430, 36, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Green", 288, 19, 137, 101) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00A000) $Cell[4] = GUICtrlCreateInput("0", 564, 36, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) $Cell[5] = GUICtrlCreateInput("0", 692, 36, 49, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) $Cell[6] = GUICtrlCreateInput("0", 154, 64, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup(" Blue ", 425, 19, 133, 101) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $Cell[7] = GUICtrlCreateInput("1", 293, 64, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[8] = GUICtrlCreateInput("0", 430, 64, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[9] = GUICtrlCreateInput("0", 564, 64, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group5 = GUICtrlCreateGroup(" Unused ", 558, 19, 191, 101) $Cell[10] = GUICtrlCreateInput("0", 692, 64, 49, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) $Cell[11] = GUICtrlCreateInput("0", 154, 92, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[12] = GUICtrlCreateInput("0", 293, 92, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[13] = GUICtrlCreateInput("1", 430, 93, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[14] = GUICtrlCreateInput("0", 564, 93, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) $Cell[15] = GUICtrlCreateInput("0", 693, 93, 49, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group6 = GUICtrlCreateGroup("", 148, 114, 601, 39) $Cell[16] = GUICtrlCreateInput("0", 154, 124, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) $Cell[17] = GUICtrlCreateInput("0", 293, 124, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) $Cell[18] = GUICtrlCreateInput("0", 430, 124, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) $Cell[19] = GUICtrlCreateInput("1", 564, 124, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[20] = GUICtrlCreateInput("0", 692, 124, 49, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group7 = GUICtrlCreateGroup("", 148, 146, 601, 39) $Cell[21] = GUICtrlCreateInput("0", 154, 156, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[22] = GUICtrlCreateInput("0", 293, 156, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[23] = GUICtrlCreateInput("0", 430, 156, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[24] = GUICtrlCreateInput("0", 564, 156, 125, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) $Cell[25] = GUICtrlCreateInput("1", 692, 156, 49, 24, BitOR($ES_RIGHT, $ES_AUTOHSCROLL)) GUICtrlSetBkColor(-1, 0xD4D0C8) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label1 = GUICtrlCreateLabel("Alpha Channel", 44, 128, 106, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("RGBA Additive Row", 8, 158, 142, 21) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") For $f = 0 To $LastMatrix $comboData &= $CA[$f][0] & "|" Next $Combo1 = GUICtrlCreateCombo("", 10, 28, 133, 25) GUICtrlSetData($Combo1, StringTrimRight($comboData, 1)) GUICtrlSetOnEvent($Combo1, "ComboLoadMatDat") GUICtrlCreateGroup("", -99, -99, 1, 1) $ColMatBut1 = GUICtrlCreateButton("Save Current Image", 4, 206, 120, 30, $BS_FLAT) GUICtrlSetBkColor(-1, 0x00FFFF) GUICtrlSetOnEvent($ColMatBut1, "SaveImage") $ColMatBut2 = GUICtrlCreateButton("Write Matrix to Console", 132, 207, 118, 30, $BS_FLAT) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlSetOnEvent($ColMatBut2, "WriteConsole") $ColMatBut3 = GUICtrlCreateButton("Apply Matrix ", 260, 207, 125, 30, $BS_FLAT) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetOnEvent($ColMatBut3, "ApplyColMat") $ColMatBut4 = GUICtrlCreateButton("Hide Matrix Display", 393, 206, 100, 30, $BS_FLAT) GUICtrlSetBkColor(-1, 0xFF00FF) GUICtrlSetOnEvent($ColMatBut4, "ShowaColMatFrm") Return 1 EndFunc ;==>ColorMatForm ; Description:: Converts a GDIPlus-Image to GDI-combatible HBITMAP ; Parameter(s): $hImg -> GDIplus Image object ; Requirement(s): GDIPlus.au3 ; Return Value(s): HBITMAP, compatible with ClipBoard ; Author(s): Prog@ndy Func _GDIPlus_ImageCreateGDICompatibleHBITMAP($hImg) Local $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($hImg) Local $hBitmap = _WinAPI_CopyImage($hBitmap2, 0, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG) _WinAPI_DeleteObject ($hBitmap2) Return $hBitmap EndFunc ;==>_GDIPlus_ImageCreateGDICompatibleHBITMAP ; Description:: Copies an image, also makes GDIPlus-HBITMAP to GDI32-BITMAP ; Parameter(s): $hImg -> HBITMAP Object, GDI or GDIPlus ; Requirement(s): WinAPI.au3 ; Return Value(s): Succes: Handle to new Bitmap, Error: 0 ; Author(s): Prog@ndy Func _WinAPI_CopyImage($hImg, $uType = 0, $x = 0, $y = 0, $flags = 0) Local $aResult $aResult = DllCall("User32.dll", "hwnd", "CopyImage", "hwnd", $hImg, "UINT", $uType, "int", $x, "int", $y, "UINT", $flags) ;_WinAPI_Check ("_WinAPI_CopyImage", ($aResult[0] = 0), 0, True) Return $aResult[0] EndFunc ;==>_WinAPI_CopyImage ; Drag Window 3 of 3 addin Func _WinMove($hWnd, $Command, $wParam, $lParam) If BitAND(WinGetState($hWnd), 32) Then Return $GUI_RUNDEFMSG ;DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hWnd", $hWnd, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) Return 1 EndFunc ;==>_WinMove Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
JScript Posted December 27, 2011 Share Posted December 27, 2011 (edited) Little modification:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Global $iSlider, $hSlider, $iDumSlider _Test() Func _Test() Local $hMain = GUICreate("Form1", 220, 310) $iDumSlider = GUICtrlCreateDummy() $iSlider = GUICtrlCreateSlider(10, 280, 200, 25, 0) GUICtrlSetLimit(-1, 254, 0) $iBright = Number(IniRead("config.ini", "Lampadas", "02", 0)) GUICtrlSetData(-1, $iBright) $hSlider = GUICtrlGetHandle($iSlider) Local $hWhite = _Child($hMain, 200, 260, 10, 10) Local $hPicWhite = GUICtrlCreatePic("", 0, 0, 200, 260) _SetPNGIntoPicControl($hPicWhite, @ScriptDir & "1.png") Local $hYellow = _Child($hMain, 200, 260, 10, 10) Local $hPicYellow = GUICtrlCreatePic("", 0, 0, 200, 260) _SetPNGIntoPicControl($hPicYellow, @ScriptDir & "2.png") WinSetTrans($hYellow, "", GUICtrlRead($iSlider)) GUISetState(@SW_SHOW, $hMain) GUISetState(@SW_SHOWNOACTIVATE, $hWhite) GUISetState(@SW_SHOWNOACTIVATE, $hYellow) GUIRegisterMsg($WM_HSCROLL, "_GUIEvents") While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE IniWrite("config.ini", "Lampadas", "02", GUICtrlRead($iSlider)) Exit Case $iDumSlider WinSetTrans($hYellow, "", GUICtrlRead($iSlider)) EndSwitch WEnd EndFunc ;==>_Test Func _Child($hParent, $iW, $iH, $iX, $iY) Local $hChild = GUICreate("", $iW - $iX - 5, $iH - $iY - 10, $iX, $iY + 6, $WS_POPUP, $WS_EX_MDICHILD, $hParent) Return $hChild EndFunc ;==>_Child Func _SetPNGIntoPicControl($iPic, $sPNGFile) ;thanks to Monoscout _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sPNGFile) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x172, 0, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>_SetPNGIntoPicControl Func _GUIEvents($hWnd, $iMsgID, $WParam, $LParam) #forceref $hWnd, $iMsgID, $wParam, $lParam Switch $iMsgID Case $WM_HSCROLL Switch $LParam Case $hSlider GUICtrlSendToDummy($iDumSlider, GUICtrlRead($iSlider)) EndSwitch EndSwitch EndFunc ;==>_GUIEventsRegards, João Carlos. Edited December 27, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now