沉默的斗鱼
发表于 2018-4-25 01:24:43
回复 13# kk_lee69
经过反复测试,发现鼠标动作是执行在按钮上方的文字上的,如果鼠标点击不到上方文字而点击到图片按钮其他位置,鼠标动作不会执行,如何把鼠标动作更改到图片按钮上而不是文字区域呢?
kk_lee69
发表于 2018-4-25 01:30:07
回复 14# 沉默的斗鱼
比如给按钮2添加动作,执行一次后第二次就会鼠标按上和按下按钮图片不会更改,按下其他按钮后再按下按钮2方能执行动作和变换按钮背景图片,不知道这是为何,
這句話不懂
每按一个按钮执行动作而不是用变量定义整体动作。
當然可以 可是 你這樣用這個技術含量高的用意在哪因為就等同把這個 結構都破掉了...........
kk_lee69
发表于 2018-4-25 01:42:59
回复 16# 沉默的斗鱼
改這樣 你就可以知道 按鈕到底是誰在控制的也可以達到你要的目錄 分別 做動作
#include <WinAPI.au3>
#include <GDIPlus.au3>
Opt("TrayAutoPause", 0)
OnAutoItExitRegister("DisposeAll")
_GDIPlus_Startup()
Global $GT = "GUI Title", $ImgA, $PosA, $BBT, $BBTA, $But, $ButA, $BBTNum = 4
; loading images
$ImgA = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\anniu1a.png")
$ImgA = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\anniu1b.png")
$ImgA = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\anniu4a.png")
Local $Img1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\bg.png")
Local $Img2 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\title_button.png")
; main GUI with title
Global $USWin = GUICreate($GT, 528, 440, -1, -1, 0x80000000, BitOR(0x00080000, 0x00000008));, 0x80)
Local $hGraphic1a = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Local $hBitmapa = _GDIPlus_BitmapCreateFromGraphics(528, 440, $hGraphic1a)
Local $hGraphic2a = _GDIPlus_ImageGetGraphicsContext($hBitmapa)
_GDIPlus_GraphicsDrawImageRect($hGraphic2a, $Img1, 88, 0, 440, 440)
_GDIPlus_GraphicsDrawImageRect($hGraphic2a, $Img2, 138, 5, 198, 45)
_GDIPlus_GraphicsDrawString_($hGraphic2a, $GT, 148, 11, "Comic Sans MS", 12)
_GDIPlus_GraphicsDispose($hGraphic2a)
_GDIPlus_GraphicsDispose($hGraphic1a)
SetBitmap($USWin, $hBitmapa, 255)
_GDIPlus_GraphicsDispose($hBitmapa)
_GDIPlus_ImageDispose($Img1)
_GDIPlus_ImageDispose($Img2)
; position labels for all buttons
$PosA = GUICtrlCreateLabel("",450, 99, 157, 30); tab buttons
$LAB1=$PosA
$PosA = GUICtrlCreateLabel("",350 , 150, 157, 30)
$LAB2=$PosA
$PosA = GUICtrlCreateLabel("",200, 165, 157, 30)
$LAB3=$PosA
$PosA = GUICtrlCreateLabel("",100, 198, 157, 30)
$LAB4=$PosA
$PosA[$BBTNum + 1] = GUICtrlCreateLabel("", 137, 402, 160, 35); save button
$PosA[$BBTNum + 2] = GUICtrlCreateLabel("", 317, 402, 160, 35); close button
For $i = 1 To $BBTNum + 2
$PosA[$i] = 0
Next
; tab button 1
$BBT = GUICreate($GT, 165, 227, 450, 100, 0x80000000, BitOR(0x00080000, 0x00000008, 0x00000040, 0x08000000), $USWin)
DrawImg2($BBTA, 1, $ImgA, "", 10, 4, "Comic Sans MS", 11)
SetBitmap($BBT, $BBTA, 255); set the first tab button as pressed
; tab button 2
$BBT = GUICreate($GT, 165, 227, 350, 133, 0x80000000, BitOR(0x00080000, 0x00000008, 0x00000040, 0x08000000), $USWin)
DrawImg3($BBTA, 2, $ImgA, "", 10, 4, "Comic Sans MS", 11)
SetBitmap($BBT, $BBTA, 255)
; tab button 3
$BBT = GUICreate($GT, 165, 227, 200, 166, 0x80000000, BitOR(0x00080000, 0x00000008, 0x00000040, 0x08000000), $USWin)
DrawImg($BBTA, 3, $ImgA, "", 10, 4, "Comic Sans MS", 11)
SetBitmap($BBT, $BBTA, 255)
; tab button 4
$BBT = GUICreate($GT, 165, 227, 100, 199, 0x80000000, BitOR(0x00080000, 0x00000008, 0x00000040, 0x08000000), $USWin)
DrawImg($BBTA, 4, $ImgA, "", 10, 4, "Comic Sans MS", 11)
SetBitmap($BBT, $BBTA, 255)
; save button
$But = GUICreate($GT, 345, 38, 138, 405, 0x80000000, BitOR(0x00080000, 0x00000008, 0x00000040, 0x08000000), $USWin)
DrawImg($ButA, 1, $ImgA, "Save", 10, 4, "Comic Sans MS", 11)
SetBitmap($But, $ButA, 255)
; close button
$But = GUICreate($GT, 345, 38, 318, 405, 0x80000000, BitOR(0x00080000, 0x00000008, 0x00000040, 0x08000000), $USWin)
DrawImg($ButA, 2, $ImgA, "Close", 10, 4, "Comic Sans MS", 11)
SetBitmap($But, $ButA, 255)
; release loaded images
_GDIPlus_ImageDispose($ImgA)
_GDIPlus_ImageDispose($ImgA)
_GDIPlus_ImageDispose($ImgA)
; show all GUIs - kind of like an animation effect
GUISetState(@SW_SHOW, $USWin)
For $i = 1 To $BBTNum
GUISetState(@SW_SHOW, $BBT[$i])
Next
GUISetState(@SW_SHOW, $But)
GUISetState(@SW_SHOW, $But)
; set the first tab button as pressed
$curr = 1
;$prev = 0
While 1
For $i = 1 To $BBTNum + 2; 4 tabs + 2 buttons
Switch $i
Case 1 To $BBTNum; tab buttons - 2-state
If $curr = $i Then ContinueLoop; don't check the state of the current tab
$pos = GUIGetCursorInfo($USWin)
If $pos = $PosA[$i] Then
If $pos = 1 Then ExitLoop
If $pos = 1 Then ExitLoop
While $pos = $PosA[$i]
If GUIGetMsg() = -3 Then Exit
$pos = GUIGetCursorInfo($USWin)
Switch $pos
Case 0; not pressed
If $PosA[$i] <> 1 Then
SetBitmap($BBT[$i], $BBTA[$i], 255)
$PosA[$i] = 1
EndIf
Case 1; pressed - change tab
If $PosA[$i] <> 2 Then
SetBitmap($BBT[$curr], $BBTA[$curr], 255)
SetBitmap($BBT[$i], $BBTA[$i], 255)
$PosA[$i] = 2
;$prev = $curr
$curr = $i
IF $PosA[$i]=$LAB1 Then
_WinAPI_ShowMsg("這是第1個按鈕")
EndIf
IF $PosA[$i]=$LAB2 Then
_WinAPI_ShowMsg("這是第2個按鈕")
EndIf
IF $PosA[$i]=$LAB3 Then
_WinAPI_ShowMsg("這是第3個按鈕")
EndIf
IF $PosA[$i]=$LAB4 Then
_WinAPI_ShowMsg("這是第4個按鈕")
EndIf
ExitLoop
EndIf
EndSwitch
Sleep(10)
WEnd
If $curr <> $i Then SetBitmap($BBT[$i], $BBTA[$i], 255)
$PosA[$i] = 0
EndIf
Case Else; save and close buttons - 3-state
$pos = GUIGetCursorInfo($USWin)
If $pos = $PosA[$i] Then
If $pos = 1 Then ExitLoop
If $pos = 1 Then ExitLoop
While $pos = $PosA[$i]
$pos = GUIGetCursorInfo($USWin)
Switch $pos
Case 0; not pressed
If $PosA[$i] <> 1 Then
SetBitmap($But[$i - $BBTNum], $ButA[$i - $BBTNum], 255)
$PosA[$i] = 1
EndIf
Case 1
While $pos = 1; holding pressed
$pos = GUIGetCursorInfo($USWin)
Switch $pos
Case $PosA[$i]; on button, pressed
If $PosA[$i] <> 2 Then
SetBitmap($But[$i - $BBTNum], $ButA[$i - $BBTNum], 255)
$PosA[$i] = 2
EndIf
Case Else; not on button, pressed
If $PosA[$i] <> 3 Then
SetBitmap($But[$i - $BBTNum], $ButA[$i - $BBTNum], 255)
$PosA[$i] = 3
EndIf
EndSwitch
Sleep(10)
WEnd
If $pos = $PosA[$i] Then
Switch $i - $BBTNum
Case 1; save button pressed
MsgBox(0 + 262144, $GT, "Saved")
Case 2; close button pressed
Exit
EndSwitch
EndIf
EndSwitch
Sleep(10)
WEnd
SetBitmap($But[$i - $BBTNum], $ButA[$i - $BBTNum], 255)
$PosA[$i] = 0
EndIf
EndSwitch
Next
Switch GUIGetMsg(); this is for tab controls
Case -3
Exit
EndSwitch
Sleep(10)
WEnd
Func DisposeAll()
For $i = 1 To $BBTNum
_GDIPlus_BitmapDispose($BBTA[$i])
_GDIPlus_BitmapDispose($BBTA[$i])
_GDIPlus_BitmapDispose($BBTA[$i])
Next
For $i = 1 To 2
_GDIPlus_BitmapDispose($ButA[$i])
_GDIPlus_BitmapDispose($ButA[$i])
_GDIPlus_BitmapDispose($ButA[$i])
Next
EndFunc ;==>DisposeAll
Func DrawImg(ByRef $RetA, $indx, $Imgs, $text, $xx, $yy, $sFont = "Comic Sans MS", $nSize = 10, $ncol = "000000", $iFormat = 0)
For $i = 0 To 2
Local $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(165, 38, $hGraphic1)
Local $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Imgs[$i], 0, 0, 165, 38)
_GDIPlus_GraphicsDrawString_($hGraphic2, $text, $xx, $yy, $sFont, $nSize, $ncol, $iFormat)
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_GraphicsDispose($hGraphic1)
$RetA[$indx][$i] = $hBitmap
Next
EndFunc ;==>DrawImg
Func DrawImg2(ByRef $RetA, $indx, $Imgs, $text, $xx, $yy, $sFont = "Comic Sans MS", $nSize = 10, $ncol = "000000", $iFormat = 0)
For $i = 0 To 2
Local $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(165, 38, $hGraphic1)
Local $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Imgs[$i], 0, 0, 46, 46)
_GDIPlus_GraphicsDrawString_($hGraphic2, $text, $xx, $yy, $sFont, $nSize, $ncol, $iFormat)
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_GraphicsDispose($hGraphic1)
$RetA[$indx][$i] = $hBitmap
Next
EndFunc ;==>DrawImg
Func DrawImg3(ByRef $RetA, $indx, $Imgs, $text, $xx, $yy, $sFont = "Comic Sans MS", $nSize = 10, $ncol = "000000", $iFormat = 0)
For $i = 0 To 2
Local $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(165, 128, $hGraphic1)
Local $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Imgs[$i], 0, 0, 128, 128)
_GDIPlus_GraphicsDrawString_($hGraphic2, $text, $xx, $yy, $sFont, $nSize, $ncol, $iFormat)
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_GraphicsDispose($hGraphic1)
$RetA[$indx][$i] = $hBitmap
Next
EndFunc ;==>DrawImg
Func _GDIPlus_GraphicsDrawString_($hGraphics, $sString, $nX, $nY, $sFont = "Comic Sans MS", $nSize = 10, $ncol = "000000", $iFormat = 0)
If StringLeft($ncol, 2) = "0x" Then $ncol = StringTrimLeft($ncol, 2)
Local $hBrush = _GDIPlus_BrushCreateSolid("0xFF" & $ncol)
Local $hFormat = _GDIPlus_StringFormatCreate($iFormat)
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $nSize)
Local $tLayout = _GDIPlus_RectFCreate($nX, $nY, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
Local $aResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo, $hFormat, $hBrush)
Local $iError = @error
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
Return SetError($iError, 0, $aResult)
EndFunc ;==>_GDIPlus_GraphicsDrawString_
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC = _WinAPI_GetDC(0)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
Local $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate("long X;long Y")
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate("long X;long Y")
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate("byte Op;byte Flags;byte Alpha;byte Format")
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", 1)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 0x02)
_WinAPI_ReleaseDC(0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap
水木子
发表于 2018-4-25 11:00:12
本帖最后由 水木子 于 2018-4-25 11:21 编辑
感觉没必要搞这么复杂吧!
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include 'GUICtrlOnHover.au3'
Global $aPic
Global $iNumber = 3
Global $iSpacingX = 100, $iSpacingY = 100
Global $iLeft = 60, $iTop = 50
Global $iButtonWidth = 80, $iButtonHeight = 80
_GDIPlus_Startup()
$hImage1 = _GDIPlus_ImageLoadFromFile('1.png')
$hImage2 = _GDIPlus_ImageLoadFromFile('2.png')
$hImage3 = _GDIPlus_ImageLoadFromFile('3.png')
GUIRegisterMsg($WM_PAINT, 'MY_WM_PAINT')
$hGui1 = GUICreate('', 400, 400)
For $i = 0 To UBound($aPic) - 1
$aPic[$i] = GUICtrlCreatePic('', $iSpacingX * Mod($i, $iNumber) + $iLeft, $iSpacingY * Floor($i / $iNumber) + $iTop, $iButtonWidth, $iButtonHeight)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
_GUICtrl_SetOnHover(-1, '_Hover_Proc', '_Leave_Hover_Proc', 'PrimaryDown_Proc', 'PrimaryUp_Proc')
Next
Global $hPic1 = _GDIPlus_GraphicsCreateFromHWND($hGui1)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $aPic To $aPic
$iIndex = $nMsg - $aPic
_GDIPlus_GraphicsDrawImageRect($hPic1, $hImage3, $iSpacingX * Mod($iIndex, $iNumber) + $iLeft, $iSpacingY * Floor($iIndex / $iNumber) + $iTop, $iButtonWidth, $iButtonHeight)
;~ MsgBox(0, 0, '按钮 - ' & $iIndex + 1)
EndSwitch
WEnd
_GDIPlus_GraphicsDispose($hPic1)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_ImageDispose($hImage3)
_GDIPlus_Shutdown()
Func PrimaryUp_Proc($iCtrlID)
Switch $iCtrlID
Case $aPic To $aPic
$iZ = $iCtrlID - $aPic
_GDIPlus_GraphicsDrawImageRect($hPic1, $hImage1, $iSpacingX * Mod($iZ, $iNumber) + $iLeft, $iSpacingY * Floor($iZ / $iNumber) + $iTop, $iButtonWidth, $iButtonHeight)
EndSwitch
EndFunc ;==>_Hover_Proc
Func _Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $aPic To $aPic
$iZ = $iCtrlID - $aPic
_GDIPlus_GraphicsDrawImageRect($hPic1, $hImage2, $iSpacingX * Mod($iZ, $iNumber) + $iLeft, $iSpacingY * Floor($iZ / $iNumber) + $iTop, $iButtonWidth, $iButtonHeight)
EndSwitch
EndFunc ;==>_Hover_Proc
Func _Leave_Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $aPic To $aPic
$iZ = $iCtrlID - $aPic
_GDIPlus_GraphicsDrawImageRect($hPic1, $hImage1, $iSpacingX * Mod($iZ, $iNumber) + $iLeft, $iSpacingY * Floor($iZ / $iNumber) + $iTop, $iButtonWidth, $iButtonHeight)
EndSwitch
EndFunc ;==>_Leave_Hover_Proc
Func MY_WM_PAINT($hWnd, $msg, $wParam, $lParam)
_WinAPI_RedrawWindow($hGui1, 0, 0, $RDW_UPDATENOW)
For $i = 0 To UBound($aPic) - 1
_GDIPlus_GraphicsDrawImageRect($hPic1, $hImage1, $iSpacingX * Mod($i, $iNumber) + $iLeft, $iSpacingY * Floor($i / $iNumber) + $iTop, $iButtonWidth, $iButtonHeight)
Next
_WinAPI_RedrawWindow($hGui1, 0, 0, $RDW_VALIDATE)
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_PAINT
zpmc123
发表于 2018-4-25 13:05:30
回复 1# 沉默的斗鱼
给你个例子!#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include 'GUICtrlOnHover.au3'
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 800, 570,-1, -1,BitOR($WS_POPUP, $WS_CLIPSIBLINGS))
$Pic = GUICtrlCreatePic("1.jpg", 0, 0, 800, 570)
GUICtrlSetState(-1, $GUI_DISABLE)
$Pic1 = GUICtrlCreatePic("1-1.bmp", 720, 5, 32, 18)
_GUICtrl_SetOnHover(-1, '_Hover_Proc', '_Leave_Hover_Proc', 'PrimaryDown_Proc', 'PrimaryUp_Proc')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Pic2 = GUICtrlCreatePic("0-1.bmp", 760, 5, 32, 18)
_GUICtrl_SetOnHover(-1, '_Hover_Proc', '_Leave_Hover_Proc', 'PrimaryDown_Proc', 'PrimaryUp_Proc')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Pic3 = GUICtrlCreatePic("2-1.bmp", 50, 250, 170, 156)
_GUICtrl_SetOnHover(-1, '_Hover_Proc', '_Leave_Hover_Proc', 'PrimaryDown_Proc', 'PrimaryUp_Proc')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Pic4 = GUICtrlCreatePic("3-1.bmp", 300,250, 170, 156)
_GUICtrl_SetOnHover(-1, '_Hover_Proc', '_Leave_Hover_Proc', 'PrimaryDown_Proc', 'PrimaryUp_Proc')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Pic5 = GUICtrlCreatePic("4-1.bmp", 550, 250, 170, 156)
_GUICtrl_SetOnHover(-1, '_Hover_Proc', '_Leave_Hover_Proc', 'PrimaryDown_Proc', 'PrimaryUp_Proc')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label1 = GUICtrlCreateLabel("", 650, 500, 120, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label2 = GUICtrlCreateLabel(@OSVersion &" "&@OSArch, 650, 547, 100, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
;WinSetOnTop($Form1,"",1);设置窗口置顶.
;WinSetTrans($Form1, "", 200);透明窗口
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Pic1 ;最小化
WinSetState($Form1, "", @SW_MINIMIZE)
Case $Pic2
Exit
Case $Pic3
MsgBox(0, " ","目前没有定义 !")
Case $Pic4
MsgBox(0, " ","目前没有定义 !")
Case $Pic5
MsgBox(0, " ","目前没有定义 !")
Case $GUI_EVENT_MOUSEMOVE
Local $A = GUIGetCursorInfo($Form1)
If Not @error Then
If $A > -1 And $A < 800 And $A > -1 And $A < 570 Then
GUICtrlSetData($Label1, "(鼠标位置: " & Int( $A) & "," & Int($A) & ")")
EndIf
EndIf
EndSwitch
WEnd
Func _Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $Pic1
GUICtrlSetImage($Pic1,"1-2.bmp")
Case $Pic2
GUICtrlSetImage($Pic2,"0-2.bmp")
Case $Pic3
GUICtrlSetImage($Pic3,"2-2.bmp")
Case $Pic4
GUICtrlSetImage($Pic4,"3-2.bmp")
Case $Pic5
GUICtrlSetImage($Pic5,"4-2.bmp")
EndSwitch
EndFunc ;==>_Hover_Proc
Func _Leave_Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $Pic1
GUICtrlSetImage($Pic1,"1-1.bmp")
Case $Pic2
GUICtrlSetImage($Pic2, '0-1.bmp')
Case $Pic3
GUICtrlSetImage($Pic3, '2-1.bmp')
Case $Pic4
GUICtrlSetImage($Pic4, '3-1.bmp')
Case $Pic5
GUICtrlSetImage($Pic5, '4-1.bmp')
EndSwitch
EndFunc ;==>_Leave_Hover_Proc
zpmc123
发表于 2018-4-25 13:10:45
如果不明白,请看附件!
zpmc123
发表于 2018-4-25 13:13:09
回复 21# zpmc123
因为图片只是示例,所以没有加命令,这个年老的,要是不会加命令,请留言!
沉默的斗鱼
发表于 2018-4-25 13:37:26
回复 20# zpmc123
谢谢zpmc123大佬的热心,bmp做按钮我一直使用呢,做全图片gui我就一直用bmp呢,就是类似你的这种办法,论坛上你这种bmp按钮做法年老痴呆有样例,但是bmp不能支持透明,或者说透明的话就会把设置透明色的所有颜色都过滤掉了,所以我就一直想用png实现按钮图标呢,你真热心,谢谢谢!但我还是想要png做的按钮。
沉默的斗鱼
发表于 2018-4-25 13:39:47
回复 19# 水木子
水木子大神出手就是厉害,用短短的变量就定义全了,可惜小弟对变量循环理解不透,不能改变某一个按钮的背景色和添加单一动作,大神就是大神呀!让人敬佩万分。
沉默的斗鱼
发表于 2018-4-25 13:46:34
回复 18# kk_lee69
老大吗,你对手绘和变量理解挺厉害的,太佩服了啦!
我的意思是说你的4个TAB按钮,如果你压下按钮1,执行完动作它不会自动弹起变色,你压按钮2或者3时,他就会变色弹起,我说的就是这个意思。
你的代码基本可以使用了,我是想把4个TAB按钮全部去掉,6个全部变成单独的图片按钮就可以了!水木子的很简洁,和你的结合起来估计就实现我的效果了,但是你们两写的代码各有千秋,小弟琢磨不透!
沉默的斗鱼
发表于 2018-4-25 13:49:27
回复 22# zpmc123
不好意思,这会才刷出来图片,是年老的例子,我一直用类似的做bmp全GUI呢,年老这个代码简介,我一直用类似的办法做bmp全GUI呢。如果水木子大神的png按钮实例能做成年老这种就完美啦!
水木子
发表于 2018-4-25 14:04:50
回复zpmc123
不好意思,这会才刷出来图片,是年老的例子,我一直用类似的做bmp全GUI呢,年老这 ...
沉默的斗鱼 发表于 2018-4-25 13:49 http://www.autoit3.cn/images/common/back.gif
完全可以的。
kk_lee69
发表于 2018-4-25 15:07:54
回复 24# 沉默的斗鱼
水木子的 範例就是你要的 不是??
kk_lee69
发表于 2018-4-25 15:10:56
本帖最后由 kk_lee69 于 2018-4-25 15:40 编辑
回复 26# 沉默的斗鱼
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $aPic To $aPic
$iIndex = $nMsg - $aPic
_GDIPlus_GraphicsDrawImageRect($hPic1, $hImage3, $iSpacingX * Mod($iIndex, $iNumber) + $iLeft, $iSpacingY * Floor($iIndex / $iNumber) + $iTop, $iButtonWidth, $iButtonHeight)
;MsgBox(0, 0, '按? - ' & $iIndex + 1)
IF $iIndex + 1=1 THENMsgBox(0,"","按下第一個按鈕做A事件")
IF $iIndex + 1=2 THENMsgBox(0,"","按下第二個按鈕做B事件")
EndSwitch
WEnd
kk_lee69
发表于 2018-4-25 15:20:21
回复 25# 沉默的斗鱼
我的意思是说你的4个TAB按钮,如果你压下按钮1,执行完动作它不会自动弹起变色,你压按钮2或者3时,他就会变色弹起,我说的就是这个意思。
你的代码基本可以使用了,我是想把4个TAB按钮全部去掉
1. 按下按鈕一這句話有問題範例裡面按鈕一 本來就是按下的 你認為按下一個 早就已經變色按下的按鈕 會有甚麼變化
2. 你压按钮2或者3时,他就会变色弹起 按鈕二或三 本來就沒按下所以你按下就會變色
3.我是想把4个TAB按钮全部去掉 你的想法 還是被限制住 從頭到尾 都沒有TAB按鈕只有 PNG 按鈕 不然你告訴我 誰是TAB 按鈕