Jump to content

Is this a bug with tabs and updown spinners?


mrider
 Share

Recommended Posts

I suspect this is a "you're doing it wrong" rather than a bug, since I find it hard to believe that nobody has encountered this before. But I've searched the forum and can't find anything relevant. So if it's a "you're doing it wrong", then be so kind as to point me at a post or some place in the help file so I can see what I'm doing wrong.

My problem in a nutshell is that I have an updown spinner control on a tab. In my real program, it makes sense for the spinner to be disabled when tasks are running. If the spinner control is NOT visible because of the selected tab, then when the controls get disabled, it peeks through the tab. That is to say you can see a ghost of where the updown part is.

This is with AutoIt 3.3.8.1 on Windows XP SP3. I also spooled up a quick virtual machine that pretty much has nothing installed except AutoIt to see if it was some sort of software conflict on my computer (it apparently isn't).

Here's a simple sample that demonstrates:

#include <GUIConstantsEx.au3>
GUICreate("Demo", 290, 110)
GUICtrlCreateTab(3, 3, 200, 100)
GUICtrlCreateTabItem("One")
$inp = GUICtrlCreateInput("", 10, 50, 150, 20)
$spinner = GUICtrlCreateUpdown(-1)
GUICtrlCreateTabItem("Two")
GUICtrlCreateTabItem("")
$toggle = GUICtrlCreateButton("Disable", 210, 30)
GUISetState()
Dim $msg
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
If $msg = $toggle Then
     If GUICtrlRead($toggle) = "Disable" Then
         GUICtrlSetState($inp, $GUI_DISABLE)
         GUICtrlSetState($spinner, $GUI_DISABLE)
         GUICtrlSetData($toggle, "Enable")
     Else
         GUICtrlSetState($inp, $GUI_ENABLE)
         GUICtrlSetState($spinner, $GUI_ENABLE)
         GUICtrlSetData($toggle, "Disable")
     EndIf
EndIf
Sleep(1)
WEnd

post-4896-0-17427900-1364592423_thumb.jp Here you see the window with the spinner enabled while on tab 1

post-4896-0-69867500-1364592430_thumb.jp Here you see the window with the spinner disabled while on tab 1

post-4896-0-71248200-1364592440_thumb.jp Here you see the window with the spinner enabled while on tab 2

post-4896-0-23973700-1364592452_thumb.jp This shows what happens after you click the "Disable" button while on tab 2

post-4896-0-73387200-1364592459_thumb.jp Here you see what happens after you re-enable the spinner without moving back to tab 1

The only way to get the spinner to stop ghosting is to click back and forth between tab 1 and tab 2.

So what am I doing wrong?

Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

  • Developers

Looks like a repaint issue, but lets agree your button really should be part of TAB1 as well and not be visible when Tab2 is active.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Something like this.

#include <GUIConstantsEx.au3>
GUICreate("Demo", 290, 110)
GUICtrlCreateTab(3, 3, 200, 100)
GUICtrlCreateTabItem("One")
$inp = GUICtrlCreateInput("", 10, 50, 150, 20)
$spinner = GUICtrlCreateUpdown(-1)
$toggle = GUICtrlCreateButton("Disable", 210, 30)
GUICtrlCreateTabItem("Two")
GUICtrlCreateTabItem("")
GUISetState()
Global $msg, $lastmsg
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    If $msg = $toggle Then
        If GUICtrlRead($toggle) = "Disable" Then
            GUICtrlSetState($inp, $GUI_DISABLE)
            GUICtrlSetState($spinner, $GUI_DISABLE)
            GUICtrlSetData($toggle, "Enable")
        Else
            GUICtrlSetState($inp, $GUI_ENABLE)
            GUICtrlSetState($spinner, $GUI_ENABLE)
            GUICtrlSetData($toggle, "Disable")
        EndIf
    EndIf
    Sleep(1)
WEnd

Or, you could put the button inside the tab itself.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Can we all agree to stop with the "move the button to tab 1" nonsense? The point is not where the button is, the point is that if the spinner is not on the tab in front when it's disabled, then the spinner control peeks through. Think about it, you didn't fix the problem, all you did was make it impossible to demonstrate it. The only reason the button is there is so that you can toggle the activation/deactivation of the spinner.

How do I get the spinner control to not peek through when I disable the control while the tab is not in front? That is the question.

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

  • Developers

Can we all agree to stop with the "move the button to tab 1" nonsense? The point is not where the button is, the point is that if the spinner is not on the tab in front when it's disabled, then the spinner control peeks through. Think about it, you didn't fix the problem, all you did was make it impossible to demonstrate it. The only reason the button is there is so that you can toggle the activation/deactivation of the spinner.

How do I get the spinner control to not peek through when I disable the control while the tab is not in front? That is the question.

enjoy :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Can we all agree to stop with the "move the button to tab 1" nonsense? The point is not where the button is, the point is that if the spinner is not on the tab in front when it's disabled, then the spinner control peeks through.

As Jos posited, it's probably a repaint issue where you're enabling/disabling a control that isn't visible causing it bleed through the tab.

Think about it, you didn't fix the problem, all you did was make it impossible to demonstrate it. The only reason the button is there is so that you can toggle the activation/deactivation of the spinner.

Actually, I did fix the problem, because now you can't enable a control that's not visible, so you don't have the issue any longer.

How do I get the spinner control to not peek through when I disable the control while the tab is not in front? That is the question.

Let's agree that you shouldn't be, and that your implementation was in error because you're trying to enable a control that shouldn't need to be enabled until you switch back to the tab it's on. Try having your script detect the tab control that's visible, and enable/disable the spinner at that point, not when you can't see it or interact with it. If that's not sufficient, then you'll have to keep looking for a solution.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I guess what I find frustrating is that everyone is focusing on the fact that they can manually toggle the state, and so the "solution" is to make it so you can't manually toggle the state. The only reason you can manually toggle the state is so that you can see the problem.

Taking away the manual part makes the whole demo program pointless. In case you missed it - the demo program is a demo. My real code is nothing like that at all. But it exhibits the same behavior.

Try having your script detect the tab control that's visible, and enable/disable the spinner at that point, not when you can't see it or interact with it.

That makes sense. What I was doing was enabling/disabling all controls when I start up the program's task. I guess what I'll have to do is put in an event listener that calls the enable/disable code instead of doing it as part of task startup. Then I can toggle the enabledness(for want of a better word) of the controls that are currently visible. I can call that function when starting up the task, since the function will have no way of knowing whether it was called from an event listener or called manually.

Thanks.

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

Just enable/disable the togglebutton in case of the tabitem:

#include <GUIConstantsEx.au3>
GUICreate("Demo", 290, 110)
$Tab = GUICtrlCreateTab(3, 3, 200, 100)
GUICtrlCreateTabItem("One")
$inp = GUICtrlCreateInput("", 10, 50, 150, 20)
$spinner = GUICtrlCreateUpdown(-1)
GUICtrlCreateTabItem("Two")
GUICtrlCreateTabItem("")
$toggle = GUICtrlCreateButton("Disable", 210, 30)
GUISetState()

Dim $msg, $iActiveTI
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Switch $msg
        Case $Tab
            $iActiveTI = GUICtrlRead($Tab)
            If $iActiveTI = 0 Then
                GUICtrlSetState($toggle, $GUI_ENABLE)
            Else
                GUICtrlSetState($toggle, $GUI_DISABLE)
            EndIf
        Case $toggle
            If GUICtrlRead($toggle) = "Disable" Then
                GUICtrlSetState($inp, $GUI_DISABLE)
                GUICtrlSetState($spinner, $GUI_DISABLE)
                GUICtrlSetData($toggle, "Enable")
            Else
                GUICtrlSetState($inp, $GUI_ENABLE)
                GUICtrlSetState($spinner, $GUI_ENABLE)
                GUICtrlSetData($toggle, "Disable")
            EndIf
    EndSwitch
    ;Sleep(1)
WEnd

Link to comment
Share on other sites

Sigh...

I really wish everyone would stop obsessing over the darn button. Next time I want to ask a question about why something acts weird, I'll be sure to make it so the state change happens when the mouse is on one side of the screen or the other. Although I wouldn't be surprised if someone pops up with "well then, don't use the left side of the screen."

Let's repeat this again: the button is only there so that you can see the problem. The button is not the problem. It was the most expedient way for you to toggle the state of the widgets in my demo. It is not how the real code works. The real code doesn't have a button there at all. The demo does, because it required the fewest lines of code. That program is not real. It's a demo. An http://www.pscode.org/sscce.html . Changing how the button works so that you can't press it defeats the purpose of the demo.

For the record, I solved the problem with three changes: 1) I have a global value that holds the desired state between enabled and disabled. 2) I modified the task startup such that instead of toggling the widget state, it toggles the value of the global value. 3) I added an event listener to the tabs which enables or disables widgets based on the global value.

So as BrewManNH alluded, the answer was to pay attention to which tab is in front, and only alter those widgets. Where before I was altering all widgets.

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

  • Moderators

mrider,

Why bother to change the state of the updown at all? ;)

#include <GUIConstantsEx.au3>
GUICreate("Demo", 290, 110)
GUICtrlCreateTab(3, 3, 200, 100)
GUICtrlCreateTabItem("One")
$inp = GUICtrlCreateInput("", 10, 50, 150, 20)
$spinner = GUICtrlCreateUpdown(-1)
GUICtrlCreateTabItem("Two")
GUICtrlCreateTabItem("")
$toggle = GUICtrlCreateButton("Disable", 210, 30)
GUISetState()
Dim $msg
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    If $msg = $toggle Then
        If GUICtrlRead($toggle) = "Disable" Then
            GUICtrlSetState($inp, $GUI_DISABLE)
            ;GUICtrlSetState($spinner, $GUI_DISABLE)
            GUICtrlSetData($toggle, "Enable")
        Else
            GUICtrlSetState($inp, $GUI_ENABLE)
            ;GUICtrlSetState($spinner, $GUI_ENABLE)
            GUICtrlSetData($toggle, "Disable")
        EndIf
    EndIf
    Sleep(1)
WEnd

As you can see, disabling the input also disables the updown - there is now no "show-through" problem nor any requirement for a toggled flag. :)

M23

P.S. And you might like to reread your later posts in this thread and reflect as to whether the attitude you adopted is one which is likely to serve you well here. You can probably guess what my response to that question would be. ;)

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

Sigh...

I really wish everyone would stop obsessing over the darn button. Next time I want to ask a question about why something acts weird, I'll be sure to make it so the state change happens when the mouse is on one side of the screen or the other. Although I wouldn't be surprised if someone pops up with "well then, don't use the left side of the screen."

Let's repeat this again: the button is only there so that you can see the problem. The button is not the problem. It was the most expedient way for you to toggle the state of the widgets in my demo. It is not how the real code works. The real code doesn't have a button there at all. The demo does, because it required the fewest lines of code. That program is not real. It's a demo. An http://www.pscode.org/sscce.html . Changing how the button works so that you can't press it defeats the purpose of the demo.

Yes, and the code in your actual gui is replaced by the button you use for demonstration.

how can you expect answers on how to correctly structure code you are not showing professor?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...