Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Menubar width
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Menubar width

 Post Reply Post Reply
Author
Message
ddebono View Drop Down
Groupie
Groupie


Joined: 02 August 2005
Location: Norway
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddebono Quote  Post ReplyReply Direct Link To This Post Topic: Menubar width
    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?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 03 August 2005 at 4:54am

1. Try GetWindowRect method.

2. EnableDocking method + xtpFlagHideWrap

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
ddebono View Drop Down
Groupie
Groupie


Joined: 02 August 2005
Location: Norway
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddebono Quote  Post ReplyReply Direct Link To This Post 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 ?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ddebono View Drop Down
Groupie
Groupie


Joined: 02 August 2005
Location: Norway
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddebono Quote  Post ReplyReply Direct Link To This Post 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



Edited by ddebono
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ddebono View Drop Down
Groupie
Groupie


Joined: 02 August 2005
Location: Norway
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddebono Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.189 seconds.