ioripalm 发表于 2015-7-21 16:54:22

在GUI上面显示透明的位图例子:数组有没有快捷的转换UDF!

本帖最后由 ioripalm 于 2015-7-22 11:21 编辑

看到一个比较好的位图显示透明的例子!
试着修改了一下里面的数组,可以在GUI上面得到一个透明的镂空图案。
这个数组是我一个字一个字敲的,请问谁知道如何根据一个BMP位图来自动生成这样的数组,有没有这样的UDF。
代码如下:#include <GUIConstants.au3>
#include <Array.au3>

Global $SQLResultWindow
$SQLResultWindow = GUICreate("位图透明效果", 270, 50, -1, -1, -1, $WS_EX_ACCEPTFILES)
Local $_Left_pos, $_Top_pos, $_GUI_NAME
$_Left_pos = 10 ; Replace with correct position
$_Top_pos = 40 ; Replace with correct position
$_GUI_NAME = $SQLResultWindow
_GuiImageHole($_GUI_NAME, $_Left_pos, $_Top_pos, 220, 32)

GUISetState()
        While 1
                $mainmsg = GUIGetMsg()
                        Select
                Case $mainmsg = $GUI_EVENT_CLOSE
                        Exit
                EndSelect
WEnd
               


Func _GuiImageHole($window_handle, $pos_x, $pos_y,$Image_Width ,$Image_Height)
    Local $aClassList, $aM_Mask, $aMask
#Region picture array
Local $PictArray
$PictArray = '1,1,8,1'
$PictArray = '50,1,70,1'
$PictArray = '1,2,8,2'
$PictArray = '50,2,70,2'
$PictArray = '1,3,8,3'
$PictArray = '50,3,70,3'
$PictArray = '1,4,8,4'
$PictArray = '50,4,70,4'
$PictArray = '1,5,8,5'
$PictArray = '50,5,70,5'
$PictArray = '1,6,8,6'
$PictArray = '50,6,70,6'
$PictArray = '1,7,8,7'
$PictArray = '50,7,70,7'
$PictArray = '1,8,8,8'
$PictArray = '20,8,70,8'
$PictArray = '1,9,8,9'
$PictArray = '20,9,70,9'
$PictArray = '1,10,8,10'
$PictArray = '20,10,70,10'
$PictArray = '1,11,8,11'
$PictArray = '20,11,70,11'
$PictArray = '1,12,8,12'
$PictArray = '20,12,70,12'
$PictArray = '1,13,8,13'
$PictArray = '50,13,70,13'
$PictArray = '1,14,8,14'
$PictArray = '50,14,70,14'
$PictArray = '1,15,8,15'
$PictArray = '50,15,70,15'
$PictArray = '1,16,8,16'
$PictArray = '50,16,70,16'
$PictArray = '1,17,8,17'
$PictArray = '50,17,70,17'
$PictArray = '1,18,8,18'
$PictArray = '50,18,70,18'
$PictArray = '1,19,8,19'
$PictArray = '50,19,70,19'
$PictArray = '1,20,8,20'
$PictArray = '20,20,70,20'
$PictArray = '1,21,8,21'
$PictArray = '20,21,70,21'
$PictArray = '1,22,8,22'
$PictArray = '20,22,70,22'
$PictArray = '1,23,8,23'
$PictArray = '20,23,70,23'
$PictArray = '1,24,8,24'
$PictArray = '20,24,70,24'
$PictArray = '1,25,8,25'
$PictArray = '50,25,70,25'
$PictArray = '1,26,8,26'
$PictArray = '50,26,70,26'
$PictArray = '1,27,8,27'
$PictArray = '50,27,70,27'
$PictArray = '1,28,8,28'
$PictArray = '50,28,70,28'
$PictArray = '1,29,8,29'
$PictArray = '50,29,70,29'
$PictArray = '1,30,8,30'
$PictArray = '50,30,70,30'
$PictArray = '1,31,8,31'
$PictArray = '50,31,70,31'
$PictArray = '1,32,220,32'
#Region picture array

        ; get the size of the active window
        $size = WinGetClientSize($window_handle)
        $Window_width = $size
        $Window_height = $size + 40 ; include height of title bar up to 30 dots
        ; First hide the window
        $aClassList = StringSplit(_WinGetClassListEx($window_handle), @LF)
        $aM_Mask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0, 'long', 0, 'long', 0, 'long', 0)
        ; rectangle A - left side
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0, 'long', 0, 'long', $pos_x, 'long', $Window_height)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask, 'long', $aMask, 'long', $aM_Mask, 'int', 2)
        ; rectangle B - Top
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0, 'long', 0, 'long', $Window_width, 'long', $pos_y)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask, 'long', $aMask, 'long', $aM_Mask, 'int', 2)
        ; rectangle C - Right side
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', $pos_x+ $Image_Width , 'long', 0 , 'long', $Window_width + 30, 'long', $Window_height)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask, 'long', $aMask, 'long', $aM_Mask, 'int', 2)
        ; rectangle D - Bottom
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0 , 'long', $pos_y + $Image_Height, 'long', $Window_width, 'long', $Window_height)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask, 'long', $aMask, 'long', $aM_Mask, 'int', 2)
        ; now unhide all regions as definedin array $PictArray
        For $i = 0 To (UBound($PictArray) - 1)
                $Block_value = StringSplit($PictArray[$i],',')
                $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', $pos_x + $Block_value - 1 , 'long', $pos_y + $Block_value, 'long', $pos_x + $Block_value, 'long', $pos_y + $Block_value -1)
                DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask, 'long', $aMask, 'long', $aM_Mask, 'int', 2)
        Next
        DllCall('user32.dll', 'long', 'SetWindowRgn', 'hwnd', $window_handle, 'long', $aM_Mask, 'int', 1)
        $PictArray='' ; empty array
EndFunc;==>_GuiImageHole
Func _WinGetClassListEx($sTitle)
    Local $sClassList = WinGetClassList($sTitle)
    Local $aClassList = StringSplit($sClassList, @LF)
    Local $sRetClassList = '', $sHold_List = '|'
    Local $aiInHold, $iInHold
    For $i = 1 To UBound($aClassList) - 1
      If $aClassList[$i] = '' Then ContinueLoop
      If StringRegExp($sHold_List, '\|' & $aClassList[$i] & '~(\d+)\|') Then
            $aiInHold = StringRegExp($sHold_List, '.*\|' & $aClassList[$i] & '~(\d+)\|.*', 1)
            $iInHold = Number($aiInHold)
            If $iInHold = 0 Then $iInHold += 1
            $aClassList[$i] &= '~' & $iInHold + 1
            $sHold_List &= $aClassList[$i] & '|'
            $sRetClassList &= $aClassList[$i] & @LF
      Else
            $aClassList[$i] &= '~1'
            $sHold_List &= $aClassList[$i] & '|'
            $sRetClassList &= $aClassList[$i] & @LF
      EndIf
    Next
    Return StringReplace(StringStripWS($sRetClassList, 3), '~', '')
EndFunc ;==>_WinGetClassListEx效果如下:
http://www.mftp.info/20150601/1437468926x988971902.jpg

论坛有人发过这样的代码!
请问数组都要自己一个字一个字的敲吗?
http://www.autoitx.com/forum.php?mod=viewthread&tid=4644&highlight=%EF%CE%BF%D5
http://www.autoitx.com/forum.php?mod=viewthread&tid=20916&highlight=%EF%CE%BF%D5

ioripalm 发表于 2015-7-22 11:06:52

有没有人知道的呀!帮忙找一下好不!
页: [1]
查看完整版本: 在GUI上面显示透明的位图例子:数组有没有快捷的转换UDF!