Results 1 to 14 of 14

Thread: [RESOLVED]vbAccelerator CommandBar Control Problem

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Resolved [RESOLVED]vbAccelerator CommandBar Control Problem

    I tried to use vbAccelerator CommandBar Control.

    2 of my project forms contains commandbar.
    This is the flow when i opening the form

    Form1 : Cmdbar(0)
    Remark : This form is using Popup Menu Style for commandbarClick one of the button of Form1 will able to open Form2
    Form2 : Do not have commandbar
    Click one of the button of Form2 will able to open Form3
    Form3 : Cmdbar(1)

    Everything is fine when i open form1 to form2 and form3. The Commandbar work Cool.
    After i unload the form3 and form2. My popup command bar of form1 prompt me an error : Run-Time error '457':
    This key is already associated with an element of this collection.
    I knew the commandbars are global.
    I also do not have duplicate Skey for commandbar.
    I create the commandbars separately in form with no same Skey

    I debug the project by using break point. I found that after i unload form2 and form3 when i click again for popup menu form1. the break point wil back to form3 form_load

    How can i solve the problem.

    Best regard
    nuFLaVors
    I will sing a song heaven if someone help me ^^
    Last edited by nUflAvOrS; Oct 1st, 2007 at 07:13 PM.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    The Error Has been solved ,
    However, the popup Menu will still show in form3 although form3 was unloaded
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  3. #3

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    FORM1

    VB Code:
    1. Option Explicit
    2.  
    3. Private DeleteIndex As Integer
    4. Private Type POINTAPI
    5.     X As Long
    6.     Y As Long
    7. End Type
    8. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    9.  
    10. Private Sub cmdBar_RequestNewInstance(Index As Integer, ctl As Object)
    11.    Dim lNewIndex As Long
    12.    lNewIndex = cmdBar.UBound + 1
    13.    Load cmdBar(lNewIndex)
    14.    
    15.    cmdBar(lNewIndex).Align = 0
    16.    Set ctl = cmdBar(lNewIndex)
    17. End Sub
    18.  
    19. Private Sub createCommandBars()
    20.  
    21.  
    22.    Dim Bar As cCommandBar
    23.    Dim btn As cButton
    24.    Dim btns As cCommandBarButtons
    25.  
    26.    ' --------------------------------------------------------
    27.    '
    28.    ' create the items we're going to use.
    29.    ' Buttons and CommandBars are global: it doesn't matter
    30.    ' which control instance you use to create them,
    31.    ' the other toolbars will reflect the same set of items.
    32.    
    33.    ' Remember the command bars are global to your *project*
    34.    ' not just the form that holds the controls
    35.    '
    36.    ' --------------------------------------------------------
    37.    With cmdBar(0)
    38.         With .Buttons
    39.            Set btn = .Add("frmMachineDistributionPopUP", , "Popup")
    40.            btn.ShowCaptionInToolbar = True
    41.            Set btn = .Add("PopUP", , "Popup")
    42.            btn.ShowCaptionInToolbar = True
    43.            
    44.            
    45.            
    46.            .Add "ANM", 0, "   Add New Machine", eNormal, "Add New Machine Drawing"
    47.            .Add "ExitfrmMachineDistribution", 1, "   Exit Form", eNormal, "Exit Form"
    48.            .Add "WRRF", 0, "   Register / Re-allocation", eNormal, "Registratration / Reallocation of Machine"
    49.         End With
    50.        
    51.         ' Top level menu:
    52.         Set Bar = .CommandBars.Add("MENU", "Menu")
    53.         Set btns = Bar.Buttons
    54.         btns.Add .Buttons("PopUP")
    55.        
    56.        
    57.         'frmMachineDesc
    58.         Set Bar = .CommandBars.Add("EDITMENU")
    59.         Set btns = Bar.Buttons
    60.         btns.Add .Buttons("WRRF")
    61.    
    62.         .Buttons("PopUP").Bar = Bar
    63.        
    64.          ' Top level menu: frmMachinedistribution
    65.         Set Bar = .CommandBars.Add("frmMachineDistributionMENU", "Menu")
    66.         Set btns = Bar.Buttons
    67.         btns.Add .Buttons("frmMachineDistributionPopUP")
    68.        
    69.        
    70.         'frmMachinedistribution
    71.         Set Bar = .CommandBars.Add("frmMachineDistributionEDITMENU")
    72.         Set btns = Bar.Buttons
    73.         btns.Add .Buttons("ANM")
    74.         btns.Add .Buttons("ExitfrmMachineDistribution")
    75.         .Buttons("frmMachineDistributionPopUP").Bar = Bar
    76.  
    77.        
    78.    End With
    79.  
    80.        
    81.    
    82. End Sub
    83.  
    84. Private Sub Form_Load()
    85.  
    86. createCommandBars
    87.  
    88. cmdBar(0).ToolbarImageList = ImageList2
    89. cmdBar(0).MenuImageList = ImageList2
    90. cmdBar(0).MainMenu = True
    91. cmdBar(0).Toolbar = cmdBar(0).CommandBars("EDITMENU")
    92.  
    93. End Sub
    94.  
    95. Private Sub lvwMachineList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    96. Dim Pt As POINTAPI
    97.  
    98.    GetCursorPos Pt
    99.     If Button = 2 Then
    100.        Dim xPixels As Long
    101.        Dim yPixels As Long
    102.        xPixels = Pt.X
    103.        yPixels = Pt.Y
    104.        cmdBar(0).ShowPopupMenu xPixels, yPixels, cmdBar(0).CommandBars("EDITMENU")
    105.        
    106.        
    107.    End If
    108. End Sub

    FORM2

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. cmdBar(1).ToolbarImageList = ImageList2
    4. cmdBar(1).MenuImageList = ImageList2
    5.  
    6. cmdBar(1).Toolbar = cmdBar(1).CommandBars("frmMachineDistributionMENU")
    7. End Sub


    I MAKE IT SIMPLE AND CLEAR THIS TIME

    I describe my situation now.

    I open form1 then click a button from form1 to show form2. Since form1 commandbar is show in popupMenu.
    form1 will become unabled after form2 clicked
    form1 and form2 are fine to show the commandbar.

    I unload form2,form1 became enable = true.
    When i right click the listview from form1 then form2 will show in order and then the menu popup at form2.
    I don't want form2 popup i want it stay unshow.

    I found that the problem maybe in requestnewinstance event.
    But i can't find the solution. Someone please help me..!!

    I thanks in advance or someone can post me how to use vbaccelerator commandbar in multiple form.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  4. #4

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    No one gotta help me ?
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  5. #5
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: vbAccelerator CommandBar Control Problem

    I have used the VBAcc CommandBar in lots of my apps, but, like you, I always find it a problem if I want the CommandBar in more than one form. This is due to the subclassing and the nature of the control being Global.

    What I have done is to use the Commandbar on my main form and then use other methods on lesser forms. After all, you shouldn't actually need the Command Bar on anything other than the Main form and if you are after the Menu properties for other forms there are many controls available which are as good. For example;

    http://www.planet-source-code.com/vb...49985&lngWId=1

  6. #6

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    Thanks Steve Grant,

    Furthermore, vbaccelerator commandbar couldn't used in MDI Form ?
    and i can't register the library file of the example you were provided. Can you tell me how to register it ?

    Thanks in Advance :-)
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  7. #7
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: vbAccelerator CommandBar Control Problem

    Although you could create the OCX from ...Samples\HookMenu, here is the slightly earlier version already compiled and IMHO easier to use! You can find a tlb registration tool on the VBAcc site.


    If this has helped you please mark the thread resolved and rate it!

  8. #8

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    I rated you but the problem haven't resolved.
    Some of the members of hookmenu doesn't function.
    For instance, autocolumn and righttoleft .
    How to solve the problem ?

    Thanks again Steve Grant
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  9. #9
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: vbAccelerator CommandBar Control Problem

    I cannot see in the posts above where you complain of RighttoLeft and AutoColumn. Also, these are not properties of the control I attached to my last post.

    To use the HookMenu control, just create a menu in the normal way using the Menu Editor and then use the HookMenu control to set the style of the Menu you want i.e. Office 2003. Then use the HookMenu control to add icons to the menu items.

    Have I misunderstood you?

  10. #10

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    Yes, I had tried the method follow your last post.
    The tlb has been registered, the hookmenu.ocx has been registered .
    all are running well.
    The image is embeded inside the menu in normal menu editior method.
    Just some of the function provided by planet source example ( the link you gave me ). I executed the sample but some of the members is not function.

    Thanks Sir :-)
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  11. #11
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: vbAccelerator CommandBar Control Problem

    You are more than welcome.

    Just give the version I attached a try, it has a different filename so you can have both registered at the same time. I think you will find the attached version easier to use.

    Let me know.

  12. #12

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    Thanks Sir,

    I ignored the problem i listed down above because i didn't use that method.
    Now i faced a problem again.
    The picture i filled in imagelist with 16 x 16 doesn't fixed the menu.

    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  13. #13
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: vbAccelerator CommandBar Control Problem

    A lot of icons have more than one picture within, make sure you are really using plain 16 x 16 icons.

  14. #14

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: vbAccelerator CommandBar Control Problem

    Ok Thanks Sir,

    Your help is appreciated..
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width