Jump to content
Sign in to follow this  
killaz219

Label renaming problem

Recommended Posts

killaz219

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

Share this post


Link to post
Share on other sites
Jos

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)

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

Share this post


Link to post
Share on other sites
themax90

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

Share this post


Link to post
Share on other sites
Jos

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.


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

Share this post


Link to post
Share on other sites
killaz219

@killaz219 why did you add $SS_SIMPLE?

<{POST_SNAPBACK}>

Oops, guess I wasn't thinking straight when I did it.

Share this post


Link to post
Share on other sites
sykes

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?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.