Jump to content
Sign in to follow this  
Linda

menubar+statusbar only works after resizing

Recommended Posts

Linda

Hi! ^_^

I am new to AutoIT so go gently on this one ;) (and i have been searching for answers on the forum but no luck)

When i include a menubar + a statusbar the statusbar disappears at the default window size when starting the script.

It appears first if i include $WS_SIZEBOX and then manually resize the window one time. Also,it seems to work when i minimize and then maximaize the window.

However,if i replace the manubar with another component,like a button,the statusbar and the button appears when i run the script.So it seems to be the combination menu+statusbar that is the problem.

Here is the script (it also change the font on the statusbar)

#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>

Global $hFont

Dim $aParts[3] = [100, 250]
Dim $aPartsText[2] = ["System info", "Current directory"]

$hGUI = GUICreate("StatusBar Resize", 400, 300, -1, -1,BitOR($WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER))

$hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts, $aPartsText)

_GUICtrlStatusBar_SetFont($hStatus, 16, 800, 2 + 4, "Tahoma")
;$Button1 = GUICtrlCreateButton("Button1", 96, 136, 75, 25, 0)
;GUISetState(@SW_SHOW)

GUICtrlCreateMenu("menu")
GUISetState()

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_WinAPI_DeleteObject($hFont)

Func _GUICtrlStatusBar_SetFont($hWnd, $iHeight = 15, $iWeight = 400, $iFontAtrributes = 0, $sFontName = "Arial")
    $hFont = _WinAPI_CreateFont($iHeight, 0, 0, 0, $iWeight, BitAND($iFontAtrributes, 2), BitAND($iFontAtrributes, 4), _
                                BitAND($iFontAtrributes, 8), $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, _
                                $DEFAULT_QUALITY, 0, $sFontName)

    _SendMessage($hWnd, $WM_SETFONT, $hFont, 1)
EndFunc  ;==>_GUICtrlStatusBar_SetFont


; Resize the status bar when GUI size changes
Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
    _GUICtrlStatusBar_Resize ($hStatus)
    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_SIZE

Anyone seen this before ?

Thanks in advance!

/

Linda

Share this post


Link to post
Share on other sites
Authenticity

Well, moving these two lines after the GUICtrlCreateMenu() call seems to work as expected:

GUICtrlCreateMenu("menu")
$hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts, $aPartsText)

_GUICtrlStatusBar_SetFont($hStatus, 16, 800, 2 + 4, "Tahoma")
Edited by Authenticity

Share this post


Link to post
Share on other sites
Linda

Hi Authenticity ^_^

Thanks a million for writing that and you are right it did work as expected!

Have a nice day !

/Linda

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  

×