qsy666888 发表于 2014-6-17 12:34:45

回复 15# chzj589


是不是不该用这个ControlMove函数

chzj589 发表于 2014-6-17 13:47:40

回复 16# qsy666888
你再试试

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $width = 400, $height = 300
#region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 428, 399)
GUISetBkColor(0xECE9D8)
Global $Button1 = GUICtrlCreateButton(" > ", $width - 96, $height - 284, 75, 22)
GUICtrlSetFont($Button1, 12, 400, 0, "微软雅黑")
Global $Button3 = GUICtrlCreateButton(" ↓ ", 304, 46, 75, 22)
GUICtrlSetFont($Button3, 12, 400, 0, "微软雅黑")
Global $Group1 = GUICtrlCreateGroup("", $width - 374, $height - 226, 185, 177)
GUICtrlSetBkColor(-1, 0xECE9D8); 背景色
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Button2 = GUICtrlCreateButton("返回", $width - 350, $height - 194, 99, 22)
Global $Label1 = GUICtrlCreateLabel("Label1", $width - 326, $height - 146, 52, 24)
GUICtrlSetFont($Label1, 12, 400, 0, "微软雅黑")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        ControlMove($Form1, "", $Group1, $width - 194, $height - 226)
                        ControlMove($Form1, "", $Button2, $width - 170, $height - 194)
                        ControlMove($Form1, "", $Label1, $width - 146, $height - 147)
                Case $Button2
                        ControlMove($Form1, "", $Group1, $width - 374, $height - 226)
                        ControlMove($Form1, "", $Button2, $width - 350, $height - 194)
                        ControlMove($Form1, "", $Label1, $width - 326, $height - 147)
                        GUICtrlSetFont($Label1, 12, 400, 0, "微软雅黑")
                Case $Button3
                        ControlMove($Form1, "", $Group1, $width-374, $height-116)
                        ControlMove($Form1, "", $Button2, $width-350, $height-84)
                        ControlMove($Form1, "", $Label1, $width - 326, $height - 40)
        EndSwitch
WEnd

ak47gglllk 发表于 2014-6-17 14:15:44

路过,收藏,看看学学学学

qsy666888 发表于 2014-6-17 15:40:30

回复 17# chzj589
现在可以了,不错

qsy666888 发表于 2014-6-17 15:53:22

回复 17# chzj589

是字体改黑掩盖掉,问题还是存在,虽然不是完美的但已经不错了,就是怕影响其它功能

chzj589 发表于 2014-6-17 16:09:45

回复 20# qsy666888

字体改为:GUICtrlSetFont($Label1, 11, 400, 0, "")也不会
字体改为:GUICtrlSetFont($Label1, 10, 400, 0, "")就又出现。

qsy666888 发表于 2014-6-17 16:15:58

回复 21# chzj589

嗯,是的

qsy666888 发表于 2014-6-17 16:16:28

回复 21# chzj589

不知道还有没有好的办法

lixiaolong 发表于 2014-6-17 22:23:39

本帖最后由 lixiaolong 于 2014-6-17 22:24 编辑

回复 1# qsy666888 #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $Form1 = GUICreate("Form1", 428, 399)
Global $Button1 = GUICtrlCreateButton("Button1", 304, 96, 75, 25)

; Group ====================================================
Global $Group1 = GUICtrlCreateGroup("", 56, 144, 185, 177)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Button2 = GUICtrlCreateButton("Button2", 80, 176, 99, 25)
Global $Label1 = GUICtrlCreateLabel("Label1", 104, 224, 52, 24)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;==========================================================

GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                       
                        GroupDelete($Group1); Deletes a control.
                        $Group1 = GUICtrlCreateGroup("", 56, 50, 185, 177)
                        Local $pos = ControlGetPos($Form1, "", $Group1)
                       
                        If Not @error Then
                                $Button2 = GUICtrlCreateButton("Button2", $pos + 24, $pos + 32, 99, 25)
                                $Label1 = GUICtrlCreateLabel("Label1", $pos + 48, $pos + 80, 52, 24)
                        EndIf

        EndSwitch
WEnd


Func GroupDelete($_ID)
        For $i = $_ID To $_ID + 2
                GUICtrlDelete($i)
        Next
EndFunc   ;==>GroupDelete

lixiaolong 发表于 2014-6-17 22:27:28

ControlMove 可以移动,但是移动后最小化窗口再还原,控件就回到原来的地方了.

chzj589 发表于 2014-6-17 23:31:37

回复 24# lixiaolong
学习了,学习再学习

qsy666888 发表于 2014-6-18 00:10:28

回复 25# lixiaolong
这种方法是实现了,如果加条件的话使Group1里的控件发生变化,就不行了,
比如我设置条件点击Group1里面的Button2,删除控件label,再点击Button1按钮移动Group1控件组,那么Group1控件组移动后里面的就会出现label文本。

风行者 发表于 2014-6-18 11:07:44

使用数组进行计算,写个函数就可以

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

#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 428, 399)
Global $Button1 = GUICtrlCreateButton("Button1", 304, 96, 75, 25)
Global $Group1 = GUICtrlCreateGroup("", 56, 144, 185, 177)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $aGroup
$aGroup = GUICtrlCreateButton("Button2", 80, 176, 99, 25)
$aGroup = GUICtrlCreateLabel("Label1", 104, 224, 52, 24)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        _GroupMove(56, 50)
        EndSwitch
WEnd

Func _GroupMove($left, $top)
        ;计算一下偏移值
        Local $gArray = ControlGetPos($Form1, "", $Group1)
        Local $x = $gArray - $left, $y = $gArray - $top
        GUICtrlSetPos($Group1, $left, $top)
        For $i = 0 To UBound($aGroup) - 1
                Local $array = ControlGetPos($Form1, "", $aGroup[$i])
                GUICtrlSetPos($aGroup[$i], $array - $x, $array - $y)
        Next
EndFunc   ;==>_GroupMove

qsy666888 发表于 2014-6-18 12:20:43

回复 28# 风行者
不错,大拇指

wangms 发表于 2014-6-19 13:19:25

学习来啦。。。。。。。。。。。。。。。。。。。
页: 1 [2]
查看完整版本: ControlMove问题,怪事,怎么出现两个