by POS 05/03/12, 08:59 am
ใส่รูปและเสียงบนปุ่ม
-ถ้าเป็นไอคอนใช้คำสั่ง _GUIImageList_AddIcon ส่วนรูปภาพใช้คำสั่ง _GUIImageList_AddBitmap
-เสียงเมื่อเลื่อนลูกศรเม้าส์ไปบนปุ่มใช้ beep หรือ SoundPlay (สำหรับไฟล์เสียง)
*ควรอ่านวิธีใช้ _GUIImageList_Create, _GUICtrlButton_SetImageList และ GUIGetCursorInfo ใน help เพิ่มเติมด้วย
ตัวอย่างโค้ด
- Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
Global $PSsix=0
$hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
_GUIImageList_AddIcon($hImage, "shell32.dll",3, True)
_GUIImageList_AddIcon($hImage, "shell32.dll",62, True)
_GUIImageList_AddIcon($hImage, "shell32.dll",27, True)
_GUIImageList_AddIcon($hImage, "shell32.dll",3, True)
_GUIImageList_AddIcon($hImage, "shell32.dll",3, True)
;~ _GUIImageList_AddBitmap($hImage, "xxxx.bmp" )
;~ _GUIImageList_AddBitmap($hImage, "xxxx.bmp" )
$Form1 = GUICreate("Form1", 171, 108, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 62, 24, 90, 49)
_GUICtrlButton_SetImageList($Button1, $hImage)
GUISetState(@SW_SHOW)
While 1
$geth = GUIGetCursorInfo($Form1)
If $geth[4] = $Button1 Then
If $PSsix = 0 Then
Beep(600,200)
;~ SoundPlay
$PSsix = 1
EndIf
Else
$PSsix=0
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd