Jump to content

Autoit $gui_disable Problem (Help)


Recommended Posts

Hello, good forums to everyone.In Autoit, there is a color change when doing $gui_disable. I dont want this. when I press the "lock button", I want to lock "Listview" along with the "lock button". In doing so, I would like to get green after pressing the "button" and "listview" lock button, which were the previous color blue. 

note : i use google translation, sorry for my bad english :)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 470, 500)
$hLV = GUICtrlCreateListView("test 1", 10, 10, 450, 400)
GUICtrlSetBkColor(-1, 0x00FFFF)
$hButton = GUICtrlCreateButton("lock", 10, 450, 80, 30)
GUICtrlSetBkColor(-1, 0x00FFFF)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUICtrlSetState($hButton, $GUI_DISABLE)
            Sleep(1000)
            GUICtrlSetBkColor($hButton, 0x00FF00)  ; working
            GUICtrlSetColor($hButton, 0x00FFFF)    ; not working
            GUICtrlSetData($hButton, "locked")

            GUICtrlSetState($hLV, $GUI_DISABLE)
            Sleep(1000)
            GUICtrlSetBkColor($hLV, 0x00FF00)  ; working
            GUICtrlSetColor($hLV, 0x00FFFF)    ; not working
    EndSwitch
WEnd

 

Adsız.png

Adsız2.png

Link to comment
Share on other sites

Just little playing with you example:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 470, 500)
$hLV = GUICtrlCreateListView("test 1", 10, 10, 450, 400)
GUICtrlCreateListViewItem("item1", $hLV)
GUICtrlSetBkColor(-1, 0x00FFFF)
$hButton = GUICtrlCreateButton("lock", 10, 450, 80, 30)
GUICtrlSetBkColor(-1, 0x00FFFF)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUICtrlSetState($hButton, $GUI_DISABLE)
;~             Sleep(1000)
            GUICtrlSetBkColor($hButton, 0x00FF00)  ; working
            GUICtrlSetColor($hButton, 0x00FFFF)    ; not working
            GUICtrlSetData($hButton, "locked")

;~             GUICtrlSetState($hLV, $GUI_DISABLE)
;~             Sleep(1000)
            GUICtrlSetBkColor($hLV, 0x00FF00)  ; working
;~             GUICtrlSetColor($hLV, 0x00FFFF)    ; not working

            GUICtrlCreateListViewItem("item2", $hLV)
;~             GUICtrlSetColor($hLV, 0x00FFFF)    ; not working
            GUICtrlSetColor($hLV, 0xFF0000)    ; working
            GUICtrlCreateListViewItem("item3", $hLV)
    EndSwitch
WEnd

As you can see when not doing disable ListView all works OK because disabling override background color to gray.

So if you want to change colors of ListView DON'T disable ListView.

Edited by Zedna
Link to comment
Share on other sites

2 hours ago, Zedna said:

Just little playing with you example:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 470, 500)
$hLV = GUICtrlCreateListView("test 1", 10, 10, 450, 400)
GUICtrlCreateListViewItem("item1", $hLV)
GUICtrlSetBkColor(-1, 0x00FFFF)
$hButton = GUICtrlCreateButton("lock", 10, 450, 80, 30)
GUICtrlSetBkColor(-1, 0x00FFFF)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUICtrlSetState($hButton, $GUI_DISABLE)
;~             Sleep(1000)
            GUICtrlSetBkColor($hButton, 0x00FF00)  ; working
            GUICtrlSetColor($hButton, 0x00FFFF)    ; not working
            GUICtrlSetData($hButton, "locked")

;~             GUICtrlSetState($hLV, $GUI_DISABLE)
;~             Sleep(1000)
            GUICtrlSetBkColor($hLV, 0x00FF00)  ; working
;~             GUICtrlSetColor($hLV, 0x00FFFF)    ; not working

            GUICtrlCreateListViewItem("item2", $hLV)
;~             GUICtrlSetColor($hLV, 0x00FFFF)    ; not working
            GUICtrlSetColor($hLV, 0xFF0000)    ; working
            GUICtrlCreateListViewItem("item3", $hLV)
    EndSwitch
WEnd

As you can see when not doing disable ListView all works OK because disabling override background color to gray.

So if you want to change colors of ListView DON'T disable ListView.

Is there no way to lock Listview without making $gui_disable? Because I have to lock Listview . The code you write doesn't lock in Listview, it just changes color.

Link to comment
Share on other sites

I believe (really not sure) it could be doable by creating a second $WS_POPUP, $WS_EX_MDICHILD GUI that overlapped the first containing only the listview and when you press Lock button, it would disable the whole second GUI.  Untested, and don't have time to do it right now.  Maybe tomorrow...

Link to comment
Share on other sites

17 hours ago, Nine said:

I believe (really not sure) it could be doable by creating a second $WS_POPUP, $WS_EX_MDICHILD GUI that overlapped the first containing only the listview and when you press Lock button, it would disable the whole second GUI.  Untested, and don't have time to do it right now.  Maybe tomorrow...

ı wait you :)

Link to comment
Share on other sites

@ufukkreis853, Not sure if this is what you want.😊 Try.

#Include <GUIEdit.au3>
#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 470, 500)
$hLV = GUICtrlCreateListView("test 1", 10, 10, 450, 400, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
    _GUICtrlEdit_SetLimitText($hLV, 64000)
    _GUICtrlEdit_LineScroll($hLV, 0, _GUICtrlEdit_GetLineCount($hLV))
GUICtrlSetBkColor(-1, 0x00FFFF)
$hButton = GUICtrlCreateButton("lock", 10, 450, 80, 30)
GUICtrlSetBkColor(-1, 0x00FFFF)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUICtrlSetState($hButton, $GUI_DISABLE)
            Sleep(1000)
            GUICtrlSetBkColor($hButton, 0x00FF00)  ; working
            GUICtrlSetColor($hButton, 0x00FFFF)    ; not working
            GUICtrlSetData($hButton, "locked")


            Sleep(1000)
            GUICtrlSetBkColor($hLV, 0x00FF00)  ; working
            GUICtrlSetColor($hLV, 0x00FFFF)    ; not working
    EndSwitch
WEnd

 

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

23 hours ago, KickStarter15 said:

@ufukkreis853, Not sure if this is what you want.😊 Try.

#Include <GUIEdit.au3>
#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 470, 500)
$hLV = GUICtrlCreateListView("test 1", 10, 10, 450, 400, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
    _GUICtrlEdit_SetLimitText($hLV, 64000)
    _GUICtrlEdit_LineScroll($hLV, 0, _GUICtrlEdit_GetLineCount($hLV))
GUICtrlSetBkColor(-1, 0x00FFFF)
$hButton = GUICtrlCreateButton("lock", 10, 450, 80, 30)
GUICtrlSetBkColor(-1, 0x00FFFF)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUICtrlSetState($hButton, $GUI_DISABLE)
            Sleep(1000)
            GUICtrlSetBkColor($hButton, 0x00FF00)  ; working
            GUICtrlSetColor($hButton, 0x00FFFF)    ; not working
            GUICtrlSetData($hButton, "locked")


            Sleep(1000)
            GUICtrlSetBkColor($hLV, 0x00FF00)  ; working
            GUICtrlSetColor($hLV, 0x00FFFF)    ; not working
    EndSwitch
WEnd

 

not this, because ı want lock listview :)

Link to comment
Share on other sites

22 hours ago, ufukkreis853 said:

not this, because ı want lock listview :)

What do you mean by locking listview? Can you explain the locking that you want? kind of floating ideas here.😊

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

_GUICtrlListView_BeginUpdate()

_GUICtrlListView_EndUpdate()

?

EDIT: I see my answer doesn't fit the question properly.

@ufukkreis853 Wouldn't it be more logical to leave the listview grey when disabled; so that the message is conveyed to the user that the listview is locked rather than the program being frozen? 

Personally, I have a few flavours depending on the application:

1. Empty the listview of data and headers so it's just a blank rectangle.

2. As with 1, but with a loading symbol if the operation takes longer than half a second or so.

3. Lock every control.

4. Hide the original control, and show an empty one in its place while necessary. I only do this if removal of data is unnecessary.

Edited by Inpho
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...