找回密码
 加入
搜索
查看: 4356|回复: 6

[GUI管理] 嵌入状态栏中的按钮最小化后,位置变了如何解决【已解决】

  [复制链接]
发表于 2011-11-28 23:17:06 | 显示全部楼层 |阅读模式
本帖最后由 xwt620 于 2011-12-3 22:14 编辑


#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Local $aParts[4] = [80, 160, 300, -1]

$Form1 = GUICreate("Form1", 623, 448, 192, 124)
$Button1 = GUICtrlCreateButton("按钮",0,0,50,20)
$hButton1 = GUICtrlGetHandle(-1)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetParts($StatusBar1, $aParts)
_GUICtrlStatusBar_SetText($StatusBar1, "")
_GUICtrlStatusBar_SetText($StatusBar1, "部件 2", 1)

_GUICtrlStatusBar_SetMinHeight($StatusBar1, 21)
_GUICtrlStatusBar_EmbedControl($StatusBar1,0,$hButton1,3)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

运行代码,此时按钮1在part1的中间,最小化窗口再恢复窗口,看看 按钮1还是不是居中显示?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-11-30 20:52:42 | 显示全部楼层
参见帖子 状态栏内嵌滚动条在GUI restore后显示位置不正确
同样的问题。

对于内嵌于状态栏的控件,都需要处理一下WM_ACTIVATE,重新嵌入并调整对应的显示属性。
要问为什么就不知道了。
发表于 2011-11-30 20:55:22 | 显示全部楼层
参考一下:
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Local $aParts[4] = [80, 160, 300, -1]
 
$Form1 = GUICreate("Form1", 623, 448, 192, 124)
$Button1 = GUICtrlCreateButton("按钮",0,0,50,20)
$hButton1 = GUICtrlGetHandle(-1)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetParts($StatusBar1, $aParts)
_GUICtrlStatusBar_SetText($StatusBar1, "")
_GUICtrlStatusBar_SetText($StatusBar1, "部件 2", 1)
 
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 21)
_GUICtrlStatusBar_EmbedControl($StatusBar1,0,$hButton1,3)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg($WM_ACTIVATE, 'WM_ACTIVATE')

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd

Func WM_ACTIVATE($hWnd, $msg, $wParam)
        If $wParam = 1 Then _GUICtrlStatusBar_EmbedControl($StatusBar1,0,$hButton1,3)
Endfunc
 楼主| 发表于 2011-12-1 00:57:42 | 显示全部楼层
谢谢,估计为什么就得到官方网站问问老外了。
发表于 2011-12-1 05:16:43 | 显示全部楼层
回复 4# xwt620
这样试试看,对所在的区段取绑定矩形,根据矩形框建立场景,然后把按钮做到场景里,可能就对了
 楼主| 发表于 2011-12-3 22:14:31 | 显示全部楼层
回复 5# netegg


    这个好高深啊~不太懂。。
发表于 2012-5-17 14:38:09 | 显示全部楼层
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-25 14:14 , Processed in 0.083180 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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