Sign in to follow this  
Followers 0
Madza91

ControlMove bug or what?

8 posts in this topic

Is this Bug or i don't know use this command (ControlMove) ^^

When move some control and minimize window, moved control get back on 1st position...

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$Label0 = GUICtrlCreateLabel("| 1st Position |          | 2nd Position |", 50, 50, 500, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("|   Label   |", 50, 70, 100, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
Sleep(500)
ControlMove($Form1, "", $Label1, 310,70,100,20)
Sleep(100)
WinSetState($Form1, "", @SW_MINIMIZE)
Sleep(100)
WinSetState($Form1, "", @SW_RESTORE)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites

That is weird... i tried different ways, but same result :S

Share this post


Link to post
Share on other sites

The window is repainting itself as it was written, not what you decided to do to it outside the code source.


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

And how to fix that?

Something like this or exist better way?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$Label0 = GUICtrlCreateLabel("| 1st Position |            | 2nd Position |", 50, 50, 500, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("|      Label      |", 50, 70, 100, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
Sleep(500)
ControlMove($Form1, "", $Label1, 310,70,100,20)
$Label2 = GUICtrlCreateLabel("|      Label      |", 310,70,100,20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlDelete($Label1)
Sleep(100)
WinSetState($Form1, "", @SW_MINIMIZE)
Sleep(100)
WinSetState($Form1, "", @SW_RESTORE)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites

And how to fix that?

Something like this or exist better way?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$Label0 = GUICtrlCreateLabel("| 1st Position |            | 2nd Position |", 50, 50, 500, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("|      Label      |", 50, 70, 100, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
Sleep(500)
ControlMove($Form1, "", $Label1, 310,70,100,20)
$Label2 = GUICtrlCreateLabel("|      Label      |", 310,70,100,20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlDelete($Label1)
Sleep(100)
WinSetState($Form1, "", @SW_MINIMIZE)
Sleep(100)
WinSetState($Form1, "", @SW_RESTORE)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
The "fix" would be to memory edit after the controlmove for the starting position of the control to its current location.

To do something like that in your own GUI, the easiest way would be to set a function that does it on restore and or minimize. Make the function change the control location before it is restored, it is repainted with the new control location (making the variables dynamic rather than statically coding them like you are above).


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

n3nE

And how to fix that?

If for your GUI, try to use a GuiCtrlSetPos() function.

Share this post


Link to post
Share on other sites

Oh, i forgot that command :D

Thanks ;)


[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites

To do something like that in your own GUI, the easiest way would be to set a function that does it on restore and or minimize. Make the function change the control location before it is restored, it is repainted with the new control location (making the variables dynamic rather than statically coding them like you are above).

One problem with the above, which I have used myself occasionally, is that WinSetState($Form1, "", @SW_RESTORE) does not seem to generate a $GUI_EVENT_RESTORE message. Manually clicking on the app in the TaskBar to restore it does generate the $GUI_EVENT_RESTORE message enabling you to move the control back to the desired position.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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