Jump to content

store dynamically controls


Recommended Posts

Ciao

Is it possible to store handle gui and function into array?

I'd like to dinamically store all the informations in a matrix

if I write

$TransparentButtonTest2 = GUICreate("", 400, 400, 2, 2,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle)
$hImageButton2 = _GDIPlus_ImageLoadFromFile(@ScriptDir & $pathImage & "regione1_down.png")
SetBitMap($TransparentButtonTest2, $hImageButton2, 255)

the function works, but if I do

$aDecoderStatus[$row][2] = GUICreate("", 400, 400, 2, 2,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle)
$aDecoderStatus[$row][3] = _GDIPlus_ImageLoadFromFile(@ScriptDir & $pathImage & $aDecoder[$row][0]& "_down.png")
$aDecoderStatus[$row][4] = _GDIPlus_ImageLoadFromFile(@ScriptDir & $pathImage & $aDecoder[$row][0]& "_warning.png")

and after 

SetBitMap(GUICtrlRead($aDecoderStatus[5][2]), GUICtrlRead($aDecoderStatus[5][4]), 255)

but doesn't works

This is the full script

The allarmi_ita.ini is like this:

[settings]
regione1= A25112
regione2= F20C01
regione3= 789213
regione4= 152201
regione5= 156879
regiane6= F8AEW8

and in the "images" folder, the name of the files have this structure:

regione1_down.png
regione1_warning.png
regione2_down.png
regione2_warning.png
and so on...

thankyou and sorry for my bad english

Marco

Edited by marcoauto
Link to comment
Share on other sites

 ArrayDisplay($aDecoderStatus) is

Row|Col 0|Col 1|Col 2|Col 3|Col 4
[0]||0|||
[1]|A25112|0|0x002D01C6|0x08A06FE8|0x08A07618
[2]|F20C01|0|0x00D10604|0x08A07CE8|0x08A083A8
[3]|789213|0|0x003E0FF0|0x08A08A78|0x08A09138
[4]|152201|0|0x00BC1104|0x08A09808|0x08A09EC8
[5]|156879|0|0x002C0FDC|0x08A0A598|0x08A0AC58
[6]|F8AEW8|0|0x00201032|0x08A0B328|0x08A0B9E8

 

Link to comment
Share on other sites

What about something like this:

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

Global $aImageList[3]

_GDIPlus_Startup()
$aImageList[0] = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif")
$aImageList[1] = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg")
$aImageList[2] = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg")
$hGUI1 = GUICreate("GUI", 640, 480, 200, 150)
$hGUI2 = GUICreate("", 640, 480, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD,$WS_EX_LAYERED, $WS_EX_TOPMOST),$hGUI1)
GUISetState(@SW_SHOW, $hGUI1)
GUISetState(@SW_SHOW, $hGUI2)

_SetBitmap($hGUI2, $aImageList[0])
_SetBitmap($hGUI2, $aImageList[1])
_SetBitmap($hGUI2, $aImageList[2])

_GDIPlus_Shutdown()

Func _SetBitmap($hGUI, $hGUI_Image)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hGUI_Image)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hGUI_Image))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hGUI_Image))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Format", 1)

    Sleep(1000)
    For $i = 5 to 255 step 5
        DllStructSetData($tBlend, "Alpha", $i)
        _WinAPI_UpdateLayeredWindow($hGUI2, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
        Sleep(40)
    Next
    Sleep(1000)
    For $i = 250 to 0 step -5
        DllStructSetData($tBlend, "Alpha", $i)
        _WinAPI_UpdateLayeredWindow($hGUI2, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
        Sleep(40)
    Next
    Sleep(500)

    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)

    _GDIPlus_ImageDispose($hGUI_Image)
EndFunc

This is a modified version of UEZ code here:

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...