zhwu530 发表于 2012-7-31 18:29:35

如何调整状态栏大小


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
Global $aParts =
$GUIMain = GUICreate("test", 800, 600, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, _
                $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, _
                $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
$hStatus = _GUICtrlStatusBar_Create($GUIMain,"","",$WS_SIZEBOX)
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Exit


运行以上代码鼠标移动到GUI右下角拖动GUI如何让状态栏大小随GUI 一起变化

xiehuahere 发表于 2012-7-31 20:10:48

本帖最后由 xiehuahere 于 2012-7-31 21:59 编辑

回复 1# zhwu530


看看 _GUICtrlStatusBar_Resize 这个函数帮助里面的例子吧。
我帮你修改一下:#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
Global $aParts =
$GUIMain = GUICreate("test", 800, 600, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, _
                $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, _
                $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
$hStatus = _GUICtrlStatusBar_Create($GUIMain)
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Exit

; Resize the status bar when GUI size changes
Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
    _GUICtrlStatusBar_Resize($hStatus)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE不过,我也有一点不是十分清楚。即关于$WM_SIZE 和 $WM_SIZING 的区别:
$WM_SIZE 应该是大小改变完成了发送的,而 $WM_SIZING 是在改变过程中实时发送的吧,根据SPY++捕获的消息看来是这样,为啥处理 $WM_SIZING 不行呢?是不是 $WM_SIZING 发个不停来不及处理?

鸟人 发表于 2012-7-31 21:09:42

顶起,这个问题我也遇到过。一直没能解决,期待

鸟人 发表于 2012-7-31 22:43:36

看了2楼的提示改了下看达到要求没。。

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
Global $aParts =
$GUIMain = GUICreate("test", 800, 600, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, _
                $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, _
                $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
$hStatus = _GUICtrlStatusBar_Create($GUIMain)
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Exit

Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
        Local $size = WinGetPos($GUIMain)
   Local $aParts = [$size-50, -1]
          _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_Resize($hStatus)
    Return $GUI_RUNDEFMSG
EndFunc

xiehuahere 发表于 2012-7-31 22:57:32

回复 4# 鸟人


    对的,还需要用一下 _GUICtrlStatusBar_SetParts,我漏掉了。

{:face (197):}
页: [1]
查看完整版本: 如何调整状态栏大小