Jump to content

overlapping label


gcue
 Share

Recommended Posts

I have two labels that move based on how many items are selected..

"Currently selected: "

and

"0" which updates with the # of items checkboxed

sometimes these overlap...im thinking its a math issue

here i create a label:

$currently_selected = GUICtrlCreateLabel("Currently Selected:", 399, 380, 90, 15)
GUICtrlSetColor(-1, $font_color)
GUICtrlSetFont(-1, 7.5, 500)
$currently_selected_checkboxes = GUICtrlCreateLabel("0", 494, 380, 6, 15)
GUICtrlSetColor(-1, $font_color)
GUICtrlSetFont(-1, 7.5, 500)

and here is the function that runs when an item is checked and it updates the number and moves the labels accordingly to line up with the gui

Func CurrentlySelected()

    CheckBoxStatus() ;checks how many items are selected and returns that number to $asset_total_count

    $number_of_digits = StringLen($asset_total_count)
    $x = $number_of_digits * 6

    GUICtrlSetPos($currently_selected, 405 - $x, 380)
    GUICtrlSetPos($currently_selected_checkboxes, 500 - $x, 380, $x, 15)

    GUICtrlSetData($currently_selected_checkboxes, $asset_total_count)

EndFunc   ;==>CurrentlySelected

any help is greatly appreciated!

Link to comment
Share on other sites

Tried to reproduce with the following little test but seems all fine to me...

GUICreate("test",600,100)
$currently_selected = GUICtrlCreateLabel("Currently Selected:", 399, 1, 90, 15)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFF88)
GUICtrlSetFont(-1, 7.5, 500)
$currently_selected_checkboxes = GUICtrlCreateLabel("0", 494, 1, 6, 15)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x0088FF)
GUICtrlSetFont(-1, 7.5, 500)

GUISetState()

For $i = 1 To 99999 Step 13
    CurrentlySelected($i)
    Sleep(10)
Next

Sleep(3000)
Exit

Func CurrentlySelected($x)
    $asset_total_count = $x

    $number_of_digits = StringLen($asset_total_count)
    $x = $number_of_digits * 6

    GUICtrlSetPos($currently_selected, 405 - $x, 1)
    GUICtrlSetPos($currently_selected_checkboxes, 500 - $x, 1, $x, 15)

    GUICtrlSetData($currently_selected_checkboxes, $asset_total_count)
EndFunc   ;==>CurrentlySelected

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

thanks for your help sadbunny.. that was a nice lil way of checking it! =)

whew.. thought i had to go back and take 8th grade math..

hmm so it must be something with the way it updates (refreshes) that it messes up..

any ideas?

Edited by gcue
Link to comment
Share on other sites

sorry i wish i knew when.. its random

been trying to duplicate it for days - no luck

so thats why i think it has to do something on the way the data update happens with guictrlsetdata

These kinds of weird glitches always intrigue me... :graduated: I have made a number of scripts that write text to labels often and move those labels around... Never seen this before.

But, still one part of my previous question remains: how? I mean, in what way do they overlap, what does it look like? Which label "moves" (i mean, more than it should to), to which direction? (And what Windows version/architecture are you using?)

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Ok so it shifts about a character... Sounds like a bleedthrough effect then? Are you absolutely 100% sure that your code doesn't create a label there more than once in the same place, and later only manipulates the last one it created?

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

yep absolutely positive.. i dont create another label.. just using guictrlsetdata

I did some tests but I can't find any occurence of this. (And by the way, setting the background color is useful to see how far the label actually extends.) Even if your math were off and/or you would do anything wrong with coordinates, it doesn't seem to me like this should happen when updating windows gui controls in a normal way (like, not "as fast as possible" 1000x per second but just after something is clicked manually) ... So it doesn't sound to me like an XP glitch or an error in the way that AutoIt handles things...

To be 101% sure, you could add something like

$guiRemoveCounter += 1
If $guiRemoveCounter == 5 Then
    GUICtrlDelete($currently_selected_checkboxes)
EndIf
Sleep(3000)

... at the bottom of your func CurrentlySelected and then trigger 5 refreshes... The label should be completely gone, if not then there's a quirk in your script :graduated:

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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