Sign in to follow this  
Followers 0
gottygolly

Button showing up behind another button.

5 posts in this topic

#1 ·  Posted (edited)

Not sure how to explain this but when I click on the square button it shows up in the button (Square) that it makes.

Anyone know how to avoid this problem?

(You pretty much have to run the code to understand my problem)

#include<misc.au3>
Global $obj
$gui = GUICreate("Box Fun",@DesktopWidth/3,@DesktopHeight/3,-1,-1)
Opt("GUIOnEventMode",1)
$buy = GUICtrlCreateButton("Square",5,5,100,20)
GUISetOnEvent(-3,"_Exit")
GUICtrlSetOnEvent($buy,"Buy_Square")
$bought_s = False
$total = 1
GUISetState()
While 1
   Sleep(10)
   If $bought_s = True Then
      Buy_Square()
      EndIf
WEnd

Func _Exit()
   Exit
EndFunc

Func Buy_Square()
   $mp = GUIGetCursorInfo($gui)
   If $bought_s = False Then
   $obj = GUICtrlCreateButton("",$mp[0]-25,$mp[1]-25,50,50)
   GUICtrlSetBkColor($obj,Random(1,0xFFFFFF))
   GUICtrlSetState($obj,128)
   $bought_s = True
EndIf
If $bought_S = True Then
   $cp = ControlGetPos($gui,"",$obj)
   ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25)
EndIf
If _IsPressed("01") Then
   $bought_s = False
   ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25)
   EndIf
EndFunc

Sorry if i'm not explaining it enough or right I just don't know how to explain it properly.

Edited by gottygolly

Share this post


Link to post
Share on other sites



I ran it, I saw what it's doing, I just have no clue what it is you want it to do. That is some messed up code.


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It's something for a different script that i'm working on but I don't know why it's doing that, do you happen to know how to fix that? 

I just want it to make a button and stuff but when it makes a button it basically takes a snapshot of the background behind it.

What do you mean by some messed up code?

Edited by gottygolly

Share this post


Link to post
Share on other sites

1.  Figure out how to use While _IsPressed("01"), that backwards loop is only asking for disaster

2.  WM_PAINT for that new control button

3.  Or disable the $buy button anytime the $obj button is within the $buy buttons rect boundary


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

1.  Figure out how to use While _IsPressed("01"), that backwards loop is only asking for disaster

2.  WM_PAINT for that new control button

3.  Or disable the $buy button anytime the $obj button is within the $buy buttons rect boundary

 

disabling the button seems to work good if OP is ok with the temporary flicker of the buy button.

#include<misc.au3>
Global $obj
$gui = GUICreate("Box Fun",@DesktopWidth/3,@DesktopHeight/3,-1,-1)
Opt("GUIOnEventMode",1)
$buy = GUICtrlCreateButton("Square",5,5,100,20)
GUISetOnEvent(-3,"_Exit")
GUICtrlSetOnEvent($buy,"Buy_Square")
$bought_s = False
$total = 1
GUISetState()
While 1
   Sleep(10)
   If $bought_s = True Then
      Buy_Square()
GUICtrlSetState($buy,64)
   EndIf
WEnd

Func _Exit()
   Exit
EndFunc

Func Buy_Square()
    GUICtrlSetState($buy,128)
   $mp = GUIGetCursorInfo($gui)
   If $bought_s = False Then
   $obj = GUICtrlCreateButton("",$mp[0]-25,$mp[1]-25,50,50)
   GUICtrlSetBkColor($obj,Random(1,0xFFFFFF))
   GUICtrlSetState($obj,128);128
   $bought_s = True
   EndIf

If $bought_S = True Then
   $cp = ControlGetPos($gui,"",$obj)
   ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25)
EndIf
If _IsPressed("01") Then
   $bought_s = False
   ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25)
   EndIf
EndFunc

if @error Then
	MsgBox(262192,"",@ComputerName&" slaps "&@UserName&" around a bit with a large trout!")
	EndIf

>Exit code: 0

REAL search results

"Yeah yeah yeah, patience. How long will that take?"  -Ed Gruberman

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  
Followers 0