#include #include #include #include ;~ #include #include #include <_GDIButton.au3> #include <_GDIBStyle.au3> #Problemi conosciuti: #1) La parte esterna di un'icona pił grande del pulsante non viene aggiornata in caso di Flash con altra icona #2) Alcune icone sono renderizzate male Global $hBMPBuff, $hGraphicGUI, $hGraphic _Main() Func _Main() Local $hGUI, $hEndCap;, $hGraphic $hGUI = GUICreate("GDI+", 400, 500, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX)) $CheckBox = GUICtrlCreateButton('Example', 165, 220, 70, 40) GUISetState() _GDIPlus_Startup() $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(400, 500, $hGraphicGUI) ; Create bitmap the same size as the graphics of the GUI. $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ; Create graphics for bitmap, $hBMPBuff. (where the graphics is like the canvas of the bitmap) ;exclude controls from GDI+ grapphic region Local $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, 400, 300) Local $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD) Local $aRect Do $aRect = ControlGetPos($hChild, "", 0) _GDIPlus_RegionCombineRect($hRegion, $aRect[0], $aRect[1], $aRect[2], $aRect[3], 3) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) Until Not $hChild #Region New Button $XCtr = stringsplit('||25|10|70|50', '|') $XApp = stringsplit('OFF|0x00BB77|0xFFCC00', '|') $XTxt = stringsplit('|0|000000|12|0|Arial|||||', '|') $XIco = stringsplit('|||', '|') assign('BUTT01', _GDICreate_Button($hGUI, $XCtr, '_Mio1', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||120|10|70|50', '|') $XApp = stringsplit('OFF|0xAAAAAA|0xFFCC00', '|') $XTxt = stringsplit('Good|0|000000|12|0|Arial|Bad|FFFFFF||2|', '|') $XIco = stringsplit('|||', '|') assign('BUTT02', _GDICreate_Button($hGUI, $XCtr, '_Mio1', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||215|10|70|50', '|') $XApp = stringsplit('OFF|0xA4CCA4|0xFFCC00', '|') $XTxt = stringsplit('|0|000099|12|0|Arial|HELLO!|000000|14|1|Consolas', '|') $XIco = stringsplit('31|32| |', '|') assign('BUTT03', _GDICreate_Button($hGUI, $XCtr, '_Mio1', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||310|10|70|50', '|') $XApp = stringsplit('OFF|0x6666FF|0xFFCC00', '|') $XTxt = stringsplit('|0|0000FF|12|0|Arial||||1|', '|') $XIco = stringsplit('130|24|130|32', '|') assign('BUTT04', _GDICreate_Button($hGUI, $XCtr, '_Mio1', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||25|80|70|50', '|') $XApp = stringsplit('OFF|0x00BB77|0xFF0000', '|') $XTxt = stringsplit('|0|000000|12|0|Arial||||1|', '|') $XIco = stringsplit('130|32|244|40', '|') assign('BUTT05', _GDICreate_Button($hGUI, $XCtr, '_Mio2', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||120|80|70|50', '|') $XApp = stringsplit('OFF|0x999999|0x0000FF', '|') $XTxt = stringsplit('|0|000000|12|0|Arial||||1|', '|') $XIco = stringsplit('80|32||', '|') assign('BUTT06', _GDICreate_Button($hGUI, $XCtr, '_Mio2', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||215|80|70|50', '|') $XApp = stringsplit('OFF|0xAAAA00|0x00FF00', '|') $XTxt = stringsplit('GO|0|000000|12|0|Arial|STOP|000000||1|Consolas', '|') $XIco = stringsplit('135|32|130|', '|') assign('BUTT07', _GDICreate_Button($hGUI, $XCtr, '_Mio2', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||310|80|70|50', '|') $XApp = stringsplit('OFF|0xAA0000|0x00FF00', '|') $XTxt = stringsplit('AAAA|0|000000|12|0|Arial|VVVV|000000||1|Consolas', '|') $XIco = stringsplit('130|32|130|', '|') assign('BUTT08', _GDICreate_Button($hGUI, $XCtr, '_Mio2', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||25|150|70|50', '|') $XApp = stringsplit('OFF|0x00BB77|0xFFCC00', '|') $XTxt = stringsplit('|0|000000|12|0|Arial||||1|', '|') $XIco = stringsplit('130|32|244|40', '|') assign('BUTT09', _GDICreate_Button($hGUI, $XCtr, '_Mio3', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||120|150|70|50', '|') $XApp = stringsplit('OFF|0x999999|0xFFCC00', '|') $XTxt = stringsplit('|0|000000|12|0|Arial||||1|', '|') $XIco = stringsplit('80|32||', '|') assign('BUTT10', _GDICreate_Button($hGUI, $XCtr, '_Mio3', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||215|150|70|50', '|') $XApp = stringsplit('OFF|0x00AA00|0x00FF00', '|') $XTxt = stringsplit('YES|0|000000|12|0|Arial|NO|000000||1|Consolas', '|') $XIco = stringsplit('135|32|130|', '|') assign('BUTT11', _GDICreate_Button($hGUI, $XCtr, '_Mio3', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 $XCtr = stringsplit('||310|150|70|50', '|') $XApp = stringsplit('OFF|0x00AAAA|0x00FF00', '|') $XTxt = stringsplit('DO|0|000000|12|0|Arial|LOOP|000000||1|Consolas', '|') $XIco = stringsplit('130|32|130|', '|') assign('BUTT12', _GDICreate_Button($hGUI, $XCtr, '_Mio3', $hGraphic, $XApp, $XTxt, $XIco), 2);, 100, 100 #EndRegion New Button ;~ _ArrayDisplay($BUTT03) #Region Arrows $hPen = _GDIPlus_PenCreate(0xFFFF0000, 2) ; Hex colour format 0xAARRGGBB - Alpha (transparency), Red, Green, Blue. $hEndCap = _GDIPlus_ArrowCapCreate(3, 6) _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap) _GDIPlus_GraphicsDrawLine($hGraphic, 10, 320, 390, 320, $hPen) _GDIPlus_PenSetWidth($hPen, 4) _GDIPlus_GraphicsDrawLine($hGraphic, 10, 350, 390, 350, $hPen) _GDIPlus_PenSetWidth($hPen, 6) _GDIPlus_GraphicsDrawLine($hGraphic, 10, 380, 390, 380, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_ArrowCapDispose($hEndCap) #EndRegion Arrows _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ; Draw bitmap to GUI (graphics). GUIRegisterMsg(0x000F, "WM_PAINT") ;~ GUIRegisterMsg($WM_MOUSEHOVER, "WM_HOVER") Global $pos = StringSplit("0|0|0|0|0", "|") Global $PosOld = $pos Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Close() Case $BUTT01[0][0] ;~ Close() $BUTT01=_GDIPush_Button($BUTT01);, $hGraphic) Case $BUTT02[0][0] $BUTT02=_GDIPush_Button($BUTT02);, $hGraphic) Case $BUTT03[0][0] $BUTT03=_GDIPush_Button($BUTT03);, $hGraphic) Case $BUTT04[0][0] $BUTT04=_GDIPush_Button($BUTT04);, $hGraphic) Case $BUTT05[0][0] $BUTT05=_GDIPush_Button($BUTT05);, $hGraphic) Case $BUTT06[0][0] $BUTT06=_GDIPush_Button($BUTT06);, $hGraphic) Case $BUTT07[0][0] $BUTT07=_GDIPush_Button($BUTT07);, $hGraphic) Case $BUTT08[0][0] $BUTT08=_GDIPush_Button($BUTT08);, $hGraphic) Case $BUTT09[0][0] $BUTT09=_GDIPush_Button($BUTT09);, $hGraphic) Case $BUTT10[0][0] $BUTT10=_GDIPush_Button($BUTT10);, $hGraphic) Case $BUTT11[0][0] $BUTT11=_GDIPush_Button($BUTT11);, $hGraphic) Case $BUTT12[0][0] $BUTT12=_GDIPush_Button($BUTT12);, $hGraphic) Case $GUI_EVENT_RESTORE RepaintGDIp() EndSwitch If WinActive('GDI+') Then $PosOld = $pos $pos = GUIGetCursorInfo($hGUI) If $PosOld[4] <> $pos[4] Then if $PosOld[4]=0 Then For $N=1 To 12 IF eval('BUTT' & StringRight ('0' & $N, 2))[0][0] = $pos[4] and eval('BUTT' & StringRight ('0' & $N, 2))[2][0]='OFF' Then _GDIFlash_ON(eval('BUTT' & StringRight ('0' & $N, 2)));, $hGraphic) EndIf Next EndIf if $Pos[4]=0 Then For $N=1 To 12 IF eval('BUTT' & StringRight ('0' & $N, 2))[0][0] = $PosOld[4] and eval('BUTT' & StringRight ('0' & $N, 2))[2][0]='OFF' Then _GDIFlash_OFF(eval('BUTT' & StringRight ('0' & $N, 2)));, $hGraphic) EndIf Next EndIf EndIf EndIf Until False EndFunc ;==>_Main Func WM_PAINTx($hGUI, $iMsg, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_PAINT Func WM_PAINT($hGUI, $iMsg, $wParam, $lParam) RepaintGDIp() ;~ _WinAPI_RedrawWindow($hGUI, 0, 0, BitOR($RDW_INVALIDATE, $RDW_ALLCHILDREN)) Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_PAINT Func RepaintGDIp() _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) EndFunc func Close() ;~ _GDIPlus_ArrowCapDispose($hEndCap) ;~ _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hGraphicGUI) _WinAPI_DeleteObject($hBMPBuff) ;~ _GDIPlus_FontFamilyDispose($hFamily) ;~ _GDIPlus_FontDispose($hFont) ;~ _GDIPlus_StringFormatDispose($hStringFormat) ;~ _GDIPlus_ImageDispose($hImage) ;release image ;~ _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete() Exit EndFunc