Print Page | Close Window

Menubar width

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=2675
Printed Date: 20 April 2024 at 8:03am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Menubar width
Posted By: ddebono
Subject: Menubar width
Date Posted: 02 August 2005 at 5:37pm

How to find the width that the windows has to be to fit the menubar/commandbar ?

And is it possible to turn off the menubar wrapping when the windows gets to narrow?




Replies:
Posted By: Oleg
Date Posted: 03 August 2005 at 4:54am

1. Try GetWindowRect method.

2. EnableDocking method + xtpFlagHideWrap



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: ddebono
Date Posted: 04 August 2005 at 3:51pm

Thanks,

 

The EnableDocking worked, but not the GetWindowRect.

The reason is that if the form is narrower than a toolbar, the GetWindowRect will report the actual left and right, and not the ones needed for non-clipping of the toolbar.

Maybe a GetWindowNonClipping function or something ?



Posted By: Oleg
Date Posted: 05 August 2005 at 11:42pm

You must disable stretch flag first.

 

    CommandBars.ActiveMenuBar.EnableDocking xtpFlagHideWrap
    CommandBars.RecalcLayout
    Dim L As Long, T As Long, R As Long, B As Long
    CommandBars.ActiveMenuBar.GetWindowRect L, T, R, B
    Const FrameBorder = 120
    Me.Width = R - L + FrameBorder



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: ddebono
Date Posted: 06 August 2005 at 6:36am

Hi,

Stretch flag is this the xtpFlagHideWrap ?

You example does not work. It still reports a much narrower width than needed. It seems that it reports no wider than the actual form width.

What I use it for is when the fontsize and icon size goes from normal to large. And then find the width necessary.

Private Sub FixMenuMode()

Dim fntTmp As StdFont

    On Error GoTo Hell

    Set fntTmp = Me.Font
    fntTmp.name = "Tahoma"
   
    If objOptions.BigMenusIcons Then
        CommandBars.Options.LargeIcons = True
        CommandBars.Options.SetIconSize True, 48, 48
        CommandBars.Options.SetIconSize False, 24, 24
        CommandBars.Options.SetPopupIconSize 48, 48
        fntTmp.Size = 14
        Set CommandBars.Options.Font = fntTmp
    Else
        CommandBars.Options.LargeIcons = False
        CommandBars.Options.SetIconSize False, 24, 24
        CommandBars.Options.SetIconSize True, 48, 48
        CommandBars.Options.SetPopupIconSize 24, 24
        fntTmp.Size = 8.25
        Set CommandBars.Options.Font = fntTmp
    End If
   
    If Me.width < FindMenuWidth Then
        Me.width = FindMenuWidth
    End If
    
    Form_Resize
   
    Exit Sub

Hell:
    ShowError "frmShow Sub FixMenuMode"
End Sub

Private Function FindMenuWidth() As Long

Dim lLeft As Long
Dim lRight As Long
Dim lTop As Long
Dim lBottom As Long
Dim lLeft1 As Long
Dim lRight1 As Long
Dim lBottom1 As Long
Dim lTop1 As Long
Dim lWidth As Long

    On Error GoTo Hell

    CommandBars.ActiveMenuBar.EnableDocking xtpFlagHideWrap
    ' Toolbar is the tolbar control of the commandbars
    Toolbar.EnableDocking xtpFlagHideWrap

    CommandBars.RecalcLayout
    CommandBars.ActiveMenuBar.GetWindowRect lLeft, lTop, lRight, lBottom
    Toolbar.GetWindowRect lLeft1, lTop1, lRight1, lBottom1
   
    If lRight1 > lRight Then
        lWidth = lRight1 - lLeft1
    Else
        lWidth = lRight - lLeft
    End If
   
    FindMenuWidth = lWidth + (15 * lTwipsPerPixelX)

    Exit Function

Hell:
    ShowError "frmShow Function FindMenuWidth"
End Function



Posted By: Oleg
Date Posted: 07 August 2005 at 1:29am

GetWindowRect retruns current Width... I think Toolbar already wrapped so it returns wrapped Width of toolbar.

 



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: ddebono
Date Posted: 08 August 2005 at 1:41pm

Oleg,

Yes it seems like the toolbar is already wrapped, and there no way to turn it off.

But the same thing also happens with the menu bar even though wrapping is turned off.

You should look more into this.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net