Advertisement
name22

AutoIt - Button with Icon/Image and Text

Jan 11th, 2013
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.63 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <SendMessage.au3>
  3.  
  4. $hWnd = GUICreate("Test", 200, 150)
  5. $cButton = GUICtrlCreateButton("Button", 50, 50, 100, 50)
  6. GUISetState()
  7.  
  8. _SetImage($cButton, @ScriptDir & "\Test.bmp")
  9.  
  10. While GUIGetMsg() <> -3
  11. WEnd
  12.  
  13. Func _SetImage($hWnd_Button, $sPath_BMP)
  14.     ; -Author: name22 (www.autoit.de)
  15.     ; -Requires: WinAPI.au3, SendMessage.au3
  16.     If Not IsHWnd($hWnd_Button) Then $hWnd_Button = GUICtrlGetHandle($hWnd_Button)
  17.     Local $hBMP_Button = _WinAPI_LoadImage(0, $sPath_BMP, 0, 0, 0, 0x0010)
  18.     Local $aRet = _SendMessage($hWnd_Button, 0xF7, 0, $hBMP_Button)
  19.     _WinAPI_DeleteObject($hBMP_Button)
  20.     Return $aRet
  21. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement