Jump to content
Sign in to follow this  

menubar+statusbar only works after resizing

Recommended Posts


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"]


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

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


    GUIRegisterMsg($WM_SIZE, "WM_SIZE")



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)
EndFunc  ;==>WM_SIZE

Anyone seen this before ?

Thanks in advance!



Share this post

Link to post
Share on other sites

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

$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

Hi Authenticity ^_^

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

Have a nice day !


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