找回密码
 加入
搜索
查看: 2193|回复: 4

[AU3基础] 为什么 图标改不了 【已解决】

[复制链接]
发表于 2010-8-29 15:17:37 | 显示全部楼层 |阅读模式
本帖最后由 haodd 于 2010-11-12 23:22 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 300, 198, 192, 114)
$Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -144, 48, 40, 32, 32)
$Button1 = GUICtrlCreateButton("sd", 48, 136, 75, 25)
$Button2 = GUICtrlCreateButton("ds", 144, 136, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -144, 48, 40, 32, 32)                
        Case $Button2
                $Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -152, 48, 40, 32, 32)
        EndSwitch
WEnd
;"d:\我的文档\桌面\ico dll\icon_5.dll", -144 是个图标 为绿色√
;"d:\我的文档\桌面\ico dll\icon_5.dll", -152 是个图标 为红色的×
可是执行的时候 点击 Button2 “红叉”还是√
需要点击两次  Button2 “红叉” 才变 “×”
发表于 2010-8-29 16:43:36 | 显示全部楼层
对dll不是太理解
发表于 2010-8-29 21:31:07 | 显示全部楼层
本帖最后由 ivanpg 于 2010-8-29 21:37 编辑

用这个
GUICtrlSetImage
函数试下
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 300, 198, 192, 114)
$Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -1, 48, 40, 32, 32)
$Button1 = GUICtrlCreateButton("sd", 48, 136, 75, 25)
$Button2 = GUICtrlCreateButton("ds", 144, 136, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $Icon11 = GUICtrlSetImage($Icon1, "d:\我的文档\桌面\ico dll\icon_5.dll",-1)                
        Case $Button2
                $Icon11 = GUICtrlSetImage($Icon1, "d:\我的文档\桌面\ico dll\icon_5.dll",-2) 
        EndSwitch
WEnd
;"d:\我的文档\桌面\ico dll\icon_5.dll", -144 是个图标 为绿色√
;"d:\我的文档\桌面\ico dll\icon_5.dll", -152 是个图标 为红色的×
 楼主| 发表于 2010-9-2 00:11:01 | 显示全部楼层
多加一次负值操作就可以了
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 300, 198, 192, 114)
$Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -144, 48, 40, 32, 32)
$Button1 = GUICtrlCreateButton("sd", 48, 136, 75, 25)
$Button2 = GUICtrlCreateButton("ds", 144, 136, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -144, 48, 40, 32, 32)                
   $Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -144, 48, 40, 32, 32)              
        Case $Button2
                $Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -152, 48, 40, 32, 32)
$Icon1 = GUICtrlCreateIcon("d:\我的文档\桌面\ico dll\icon_5.dll", -152, 48, 40, 32, 32)

        EndSwitch
WEnd
;"d:\我的文档\桌面\ico dll\icon_5.dll", -144 是个图标 为绿色√
;"d:\我的文档\桌面\ico dll\icon_5.dll", -152 是个图标 为红色的×
发表于 2010-9-16 10:54:05 | 显示全部楼层
还是GUICtrlSetImage好,不推荐反复生成新组件
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-3 06:38 , Processed in 0.087147 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表