Jump to content
Sign in to follow this  
chuehbueb

Labels on images as buttons

Recommended Posts

Hi, i want to use a script, that works like this:

#include <guiconstants.au3>
#include "LabelClick.au3"

$MainWindow = GUICreate("my gui", 295, 89, 455, 340, BitOR($WS_POPUPWINDOW, $WS_BORDER))
$Status = GUICtrlCreatePic("images\default\bg.gif", 0, 0, 295, 89, BitOR($SS_NOTIFY,$WS_GROUP))

$Play = GUICtrlCreatePic("images\default\play.gif", 242, 4, 51, 15)
GUICtrlSetState(-1, $GUI_DISABLE)

$Pause = GUICtrlCreatePic("images\default\pause.gif", 242, 20, 51, 15)
GUICtrlSetState(-1, $GUI_DISABLE)

$PlayLabel = GUICtrlCreateLabel('', 242, 4, 51, 15, $GUI_BKCOLOR_TRANSPARENT)
$PauseLabel = GUICtrlCreateLabel('', 242, 20, 51, 15, $GUI_BKCOLOR_TRANSPARENT)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = - 3 Then Exit
    If _LabelClicked($MainWindow, $PlayLabel) Then MsgBox(0, 'Pic', 'Play')
    If _LabelClicked($MainWindow, $PauseLabel) Then MsgBox(0, 'Pic', 'Pause')
WEnd

is that possible?

Share this post


Link to post
Share on other sites

Any reason why you could not use buttons instead?

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 192, 51, -1, -1)
$Pic1 = GUICtrlCreateIcon("shell32.dll", 137, 12, 20, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$Button1 = GUICtrlCreateButton("Play", 8, 16, 75, 25, $WS_CLIPSIBLINGS)
$Pic2 = GUICtrlCreateIcon("shell32.dll", 27, 108, 21, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$Button2 = GUICtrlCreateButton("Stop", 104, 16, 75, 25, $WS_CLIPSIBLINGS)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $Button1, $Pic1
        MsgBox(0, 'Testing', 'You press play.')
    Case $Button2, $Pic2
        MsgBox(0, 'Testing', 'You press stop.')
    Case Else
        ;;;;;;;
    EndSwitch
WEnd
Exit

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Try this it should work for you...

#include <guiconstants.au3>

$MainWindow = GUICreate("my gui", 295, 89, 455, 340, BitOR($WS_POPUPWINDOW, $WS_BORDER))
$Status = GUICtrlCreatePic("images\default\bg.gif", 0, 0, 295, 89, BitOR($SS_NOTIFY,$WS_GROUP))

$Play = GUICtrlCreatePic("images\default\play.gif", 242, 4, 51, 15)
GUICtrlSetCursor($Play, 0)

$Pause = GUICtrlCreatePic("images\default\pause.gif", 242, 20, 51, 15)
GUICtrlSetCursor($Pause, 0)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = - 3 Then Exit
    
    $m_info = GUIGetCursorInfo($MainWindow)
    If IsArray($m_info) Then
        If $m_info[2] And $m_info[4] = $Play Then MsgBox(0, 'Pic', 'Play')
        If $m_info[2] And $m_info[4] = $Pause Then MsgBox(0, 'Pic', 'Pause')
    EndIf   
WEnd

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...