找回密码
 加入
搜索
楼主: qsy666888

[AU3基础] ControlMove问题,怪事,怎么出现两个

 火.. [复制链接]
 楼主| 发表于 2014-6-17 12:34:45 | 显示全部楼层
回复 15# chzj589


是不是不该用这个ControlMove函数
发表于 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
发表于 2014-6-17 14:15:44 | 显示全部楼层
路过,收藏,看看学学学学
 楼主| 发表于 2014-6-17 15:40:30 | 显示全部楼层
回复 17# chzj589
现在可以了,不错
 楼主| 发表于 2014-6-17 15:53:22 | 显示全部楼层
回复 17# chzj589

是字体改黑掩盖掉,问题还是存在,虽然不是完美的但已经不错了,就是怕影响其它功能
发表于 2014-6-17 16:09:45 | 显示全部楼层
回复 20# qsy666888

字体改为:GUICtrlSetFont($Label1, 11, 400, 0, "")也不会
字体改为:GUICtrlSetFont($Label1, 10, 400, 0, "")就又出现。
 楼主| 发表于 2014-6-17 16:15:58 | 显示全部楼层
回复 21# chzj589

嗯,是的
 楼主| 发表于 2014-6-17 16:16:28 | 显示全部楼层
回复 21# chzj589

不知道还有没有好的办法
发表于 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[0] + 24, $pos[1] + 32, 99, 25)
                                $Label1 = GUICtrlCreateLabel("Label1", $pos[0] + 48, $pos[1] + 80, 52, 24)
                        EndIf

        EndSwitch
WEnd


Func GroupDelete($_ID)
        For $i = $_ID To $_ID + 2
                GUICtrlDelete($i)
        Next
EndFunc   ;==>GroupDelete
发表于 2014-6-17 22:27:28 | 显示全部楼层
ControlMove 可以移动,但是移动后最小化窗口再还原,控件就回到原来的地方了.
发表于 2014-6-17 23:31:37 | 显示全部楼层
回复 24# lixiaolong
学习了,学习再学习
 楼主| 发表于 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[2]
$aGroup[0] = GUICtrlCreateButton("Button2", 80, 176, 99, 25)
$aGroup[1] = 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[0] - $left, $y = $gArray[1] - $top
        GUICtrlSetPos($Group1, $left, $top)
        For $i = 0 To UBound($aGroup) - 1
                Local $array = ControlGetPos($Form1, "", $aGroup[$i])
                GUICtrlSetPos($aGroup[$i], $array[0] - $x, $array[1] - $y)
        Next
EndFunc   ;==>_GroupMove

评分

参与人数 1贡献 +2 收起 理由
lixiaolong + 2 学习了!

查看全部评分

 楼主| 发表于 2014-6-18 12:20:43 | 显示全部楼层
回复 28# 风行者
不错,大拇指
发表于 2014-6-19 13:19:25 | 显示全部楼层
学习来啦。。。。。。。。。。。。。。。。。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 16:49 , Processed in 0.077116 second(s), 16 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表