Jump to content

Label renaming problem


 Share

Recommended Posts

I've had problems recently with stuff like this. It seems in the code I posted below that it just repaints the text over the old text. Is there anyway I can make it just replace the text in the label? Something I overlooked?

#include "GUIConstants.au3"
$style = $WS_POPUP + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX
$window = GUICreate("Aaron's Encrypter", 200, 110, (@DesktopWidth - 757) / 2, (@DesktopHeight - 262) / 2, $style)
$Button_1 = GuiCtrlCreateButton("Add item to list", 30, 50, 100, 30)
$Label = GUICtrlCreateLabel("100", 135, 55, 30, 20, BitOR($SS_SIMPLE, $SS_SUNKEN))
GuiSetState()

Do
   $msg = GUIGetMsg()
   if $msg = $button_1 Then
      GUICtrlSetData( $label, Int(Random(0, 99)))
   EndIf
Until $msg = -3
Link to comment
Share on other sites

  • Developers

I've had problems recently with stuff like this. It seems in the code I posted below that it just repaints the text over the old text. Is there anyway I can make it just replace the text in the label? Something I overlooked?

#include "GUIConstants.au3"
$style = $WS_POPUP + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX
$window = GUICreate("Aaron's Encrypter", 200, 110, (@DesktopWidth - 757) / 2, (@DesktopHeight - 262) / 2, $style)
$Button_1 = GuiCtrlCreateButton("Add item to list", 30, 50, 100, 30)
$Label = GUICtrlCreateLabel("100", 135, 55, 30, 20, BitOR($SS_SIMPLE, $SS_SUNKEN))
GuiSetState()

Do
   $msg = GUIGetMsg()
   if $msg = $button_1 Then
      GUICtrlSetData( $label, Int(Random(0, 99)))
   EndIf
Until $msg = -3

<{POST_SNAPBACK}>

:idiot: it has something to do with $SS_SIMPLE because this works fine:

$Label = GUICtrlCreateLabel("100", 135, 55, 30, 20, $SS_SUNKEN)

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

If you times the original value by 0 then add the Integer, it will come out even. The only defect is that is always has a 0 behind the two digit number unless it's a 3 digit, then it.s fine.

#include "GUIConstants.au3"
$style = $WS_POPUP + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX
$window = GUICreate("Aaron's Encrypter", 200, 110, (@DesktopWidth - 757) / 2, (@DesktopHeight - 262) / 2, $style)
$Button_1 = GuiCtrlCreateButton("Add item to list", 30, 50, 100, 30)
$Label = GUICtrlCreateLabel("100", 135, 55, 30, 20, BitOR($SS_SIMPLE, $SS_SUNKEN))
GuiSetState()

Do
  $msg = GUIGetMsg()
  if $msg = $button_1 Then
     GUICtrlSetData( $label, 0 * 0 & Int(Random(0, 99)))
  EndIf
Until $msg = -3

Since it's simple it thinks it's always addition. You got to take off that original number though.

And if you just want a random adding thing..

#include "GUIConstants.au3"
$style = $WS_POPUP + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX
$window = GUICreate("Aaron's Encrypter", 200, 110, (@DesktopWidth - 757) / 2, (@DesktopHeight - 262) / 2, $style)
$Button_1 = GuiCtrlCreateButton("Add item to list", 30, 50, 100, 30)
$Label = GUICtrlCreateLabel("100", 135, 55, 30, 20, BitOR($SS_SIMPLE, $SS_SUNKEN))
GuiSetState()

Do
  $msg = GUIGetMsg()
  if $msg = $button_1 Then
      $current = GUIRead($label)
     GUICtrlSetData( $label, $current + Int(Random(0, 99)))
  EndIf
Until $msg = -3

And for subtraction..

#include "GUIConstants.au3"
$style = $WS_POPUP + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX
$window = GUICreate("Aaron's Encrypter", 200, 110, (@DesktopWidth - 757) / 2, (@DesktopHeight - 262) / 2, $style)
$Button_1 = GuiCtrlCreateButton("Add item to list", 30, 50, 100, 30)
$Label = GUICtrlCreateLabel("100", 135, 55, 30, 20, BitOR($SS_SIMPLE, $SS_SUNKEN))
GuiSetState()

Do
  $msg = GUIGetMsg()
  if $msg = $button_1 Then
      $current = GUIRead($label)
     GUICtrlSetData( $label, $current - Int(Random(0, 99)))
  EndIf
Until $msg = -3

Just trying to exhaust all possibilities... Hehe :idiot:

Edited by Agent Smith
Link to comment
Share on other sites

  • Developers

If you times the original value by 0 then add the Integer, it will come out even. The only defect is that is always has a 0 behind the two digit number unless it's a 3 digit, then it.s fine.

<{POST_SNAPBACK}>

He has a refresh problem of the Label Control. in other words when the current value is 100 and the new value 5, then the label will display 500.

@killaz219 why did you add $SS_SIMPLE?

SS_SIMPLE:

Specifies a simple rectangle and displays a single line of left-aligned text in the rectangle. The text line cannot be shortened or altered in any way. The controls parent window or dialog box must not process the WM_CTLCOLORSTATIC message.

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

Is it because SS_SIMPLE States:

The text line cannot be shortened or altered in any way

?

This would mean the text line you originally set would remain and the new value would simply be placed on top of it?

We have enough youth. How about a fountain of SMART?

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