Jump to content

close event in label doenst work


Recommended Posts

hi guys, fine?

i'm trying to set an event to a label and it doesns work IF the line bellow is uncomented:

GUICtrlCreatePic($hImageLocal, $w, $h, 0, 0)

 

the event that doenst work bellow:

$x_inicial = GUICtrlCreateLabel("X", 470, 10, 20, 20, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
GUICtrlSetOnEvent(-1, "close")

but if i coment this line, the event works, bellow the full code

 

#NoTrayIcon
#include <GUIConstantsEx.au3>
#Include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <GuiTreeView.au3>


HotKeySet("{ESC}", "close")

Opt("GUIOnEventMode", 1)
Opt('WINTITLEMATCHMODE', 4)
$hImageLocal2 = "http://wallpaper.zone/img/3784228.jpg"
_GDIPlus_Startup ()
$hImageLocal = _GetURLImage($hImageLocal2)


Local $hImage = _GDIPlus_ImageLoadFromFile($hImageLocal);_GDIPlus_ImageLoadFromFile($hImageLocal)
If @error Then
    MsgBox(16, "Error", "Does the file exist?")
    Exit 1
EndIf

$x = _GDIPlus_ImageGetWidth($hImage)
$y = _GDIPlus_ImageGetHeight($hImage)
$w =(@DesktopWidth/2)-($x/2)
$h =(@DesktopHeight/2)-($y/2)

_GDIPlus_ImageDispose ($hImage)


_GDIPlus_ShutDown ()
Global $Form1 = GUICreate("inicial", @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $DS_SETFOREGROUND));, $WS_EX_TOPMOST)

GUICtrlCreatePic($hImageLocal, $w, $h, 0, 0)

$x_inicial = GUICtrlCreateLabel("X", 470, 10, 20, 20, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
GUICtrlSetOnEvent(-1, "close")

GUISetState(@SW_SHOW,$Form1)

While 1
    Switch GUIGetMsg($Form1)
        Case $GUI_EVENT_CLOSE
            exit
    EndSwitch

WEnd

func x_press()
    MsgBox(0,"","OK")
EndFunc

func close()
            exit
EndFunc



Func _GetURLImage($sURL, $sDirectory = @ScriptDir)
    Local $hDownload, $sFile
    $sFile = StringRegExpReplace($sURL, "^.*/", "")
    If @error Then
        Return SetError(1, 0, $sFile)
    EndIf
    If StringRight($sDirectory, 1) <> "\" Then
        $sDirectory = $sDirectory & "\"
    EndIf
    $sDirectory = $sDirectory & $sFile
    If FileExists($sDirectory) Then
        Return $sDirectory
    EndIf
    $hDownload = InetGet($sURL, $sDirectory, 17, 1)
    While InetGetInfo($hDownload, 2) = 0
        If InetGetInfo($hDownload, 4) <> 0 Then
            InetClose($hDownload)
            Return SetError(1, 0, $sDirectory)
        EndIf
        Sleep(105)
    WEnd
    InetClose($hDownload)
    Return $sDirectory
EndFunc   ;==>_GetURLImage

 

Link to comment
Share on other sites

  • Moderators

Melque_Lima,

Disable the pic control - AutoIt does not like overlapping active controls as it cannot read your mind and decide which you want to action.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Melque_Lima,

Read the Help file for GUICtrlCreatePic - the "Remarks" section explains all.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...