Sign in to follow this  
Followers 0
Aceguy

Guictrlsetonevent not working,

7 posts in this topic

#1 ·  Posted (edited)

#include<Array.au3>
#include<DateTimeConstants.au3>
#include<GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include<GUIConstants.au3>
#include<Array.au3>
#include<Misc.au3>
#include <Sound.au3>
#include <GuiComboBox.au3>
#include <Date.au3>
#include <String.au3>
#include<guicomboboxex.au3>
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=..\Test.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


Opt("GUIOnEventMode", 1)

Global $label,$Progress


$Form1 = GUICreate("Countdown", 361, 445, 384, 252)
$Combo1 = GUICtrlCreateCombo("", 240, 8, 113, 25, BitOR($CBS_DROPDOWNLIST, $CBS_SORT))
GUICtrlSetOnEvent(-1, "combo_change")
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$Date = GUICtrlCreateDate("", 5, 5, 70, 20, $DTS_TIMEFORMAT)




Dim $label[11]
Dim $Progress[11]

$g = 0
For $x = 1 To UBound($label) - 1

    $Progress[$x] = GUICtrlCreateProgress(8, 40 + $g, 169, 17)

    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlSetBkColor(-1, 0x00ff00)
    
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")
    GUICtrlSetStyle(-1, 1)
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
    
    $label[$x] = GUICtrlCreateLabel("this is a test label", 8, 40 + $g, 120, 17)
    GUICtrlSetOnEvent(-1, "label_test")
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
    GUICtrlSetBkColor($label[$x], $GUI_BKCOLOR_TRANSPARENT)
    $g += 20


Next

GUISetState(@SW_SHOW)
_GUICtrlComboBoxEx_SetCurSel(GUICtrlGetHandle($Combo1), 0)

While 1
    Sleep(50)
WEnd


Func label_test()
    ConsoleWrite("Label" & @LF)
    Local $iD = @GUI_CtrlId
    
    $sea = _ArraySearch($label, $iD)
    If Not @error Then MsgBox(0, "label", $iD & " " & $sea, 0)
    
EndFunc   ;==>label

Func combo_change()
EndFunc   ;==>combo_change

any ideas why when i click on the label it doesnt work.

Edited by Aceguy

Share this post


Link to post
Share on other sites



Doesnt work :) when the labe extends beyond the progress bar, its ok.... but when they are both the same size i cannot click it

.

The click event will be registered by the topmost Control, so when the progress bar is overlapping the label control, the click event will go to the progress bar.

Did you try changing the creation sequence?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

yes, tried swapping the labe with the progress bar and it works, well the click does, but the label doesnt show.

You need to disable the progress bars

#include<Array.au3>
#include<DateTimeConstants.au3>
#include<GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include<GUIConstants.au3>
#include<Array.au3>
#include<Misc.au3>
#include <Sound.au3>
#include <GuiComboBox.au3>
#include <Date.au3>
#include <String.au3>
#include<guicomboboxex.au3>
#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=..\Test.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****


Opt("GUIOnEventMode", 1)

Global $label,$Progress


$Form1 = GUICreate("Countdown", 361, 445, 384, 252)
$Combo1 = GUICtrlCreateCombo("", 240, 8, 113, 25, BitOR($CBS_DROPDOWNLIST, $CBS_SORT))
GUICtrlSetOnEvent(-1, "combo_change")
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$Date = GUICtrlCreateDate("", 5, 5, 70, 20, $DTS_TIMEFORMAT)




Dim $label[11]
Dim $Progress[11]

$g = 0
For $x = 1 To UBound($label) - 1
  
    $Progress[$x] = GUICtrlCreateProgress(8, 40 + $g, 169, 17)
    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlSetBkColor(-1, 0x00ff00)
   
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")
    GUICtrlSetStyle(-1, 1)
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
    GUICtrlSetState(-1,$GUI_DISABLE)
    
    $label[$x] = GUICtrlCreateLabel("this is a test label", 8, 40 + $g, 120, 17,$SS_NOTIFY)
    GUICtrlSetOnEvent(-1, "label_test")
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1,0)
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
    GUICtrlSetBkColor($label[$x], $GUI_BKCOLOR_TRANSPARENT)
    
    $g += 20

GUISetOnEvent($GUI_EVENT_CLOSE,"closeall")
Next

GUISetState(@SW_SHOW)
_GUICtrlComboBoxEx_SetCurSel(GUICtrlGetHandle($Combo1), 0)

While 1
    Sleep(50)
WEnd

Func closeall()
    
    Exit
EndFunc


Func label_test()
    ConsoleWrite("Label" & @LF)
    Local $iD = @GUI_CtrlId
   
    $sea = _ArraySearch($label, $iD)
    If Not @error Then MsgBox(0, "label", $iD & " " & $sea, 0)
   
EndFunc ;==>label

Func combo_change()
EndFunc ;==>combo_change

EDIT:I don't think $SS_NOTIFY is needed then.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  
Followers 0