|
-
Sep 28th, 2007, 08:58 PM
#1
Thread Starter
Hyperactive Member
[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.
-
Sep 28th, 2007, 10:30 PM
#2
Thread Starter
Hyperactive Member
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.
-
Sep 29th, 2007, 01:17 AM
#3
Thread Starter
Hyperactive Member
Re: vbAccelerator CommandBar Control Problem
FORM1
VB Code:
Option Explicit
Private DeleteIndex As Integer
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub cmdBar_RequestNewInstance(Index As Integer, ctl As Object)
Dim lNewIndex As Long
lNewIndex = cmdBar.UBound + 1
Load cmdBar(lNewIndex)
cmdBar(lNewIndex).Align = 0
Set ctl = cmdBar(lNewIndex)
End Sub
Private Sub createCommandBars()
Dim Bar As cCommandBar
Dim btn As cButton
Dim btns As cCommandBarButtons
' --------------------------------------------------------
'
' create the items we're going to use.
' Buttons and CommandBars are global: it doesn't matter
' which control instance you use to create them,
' the other toolbars will reflect the same set of items.
' Remember the command bars are global to your *project*
' not just the form that holds the controls
'
' --------------------------------------------------------
With cmdBar(0)
With .Buttons
Set btn = .Add("frmMachineDistributionPopUP", , "Popup")
btn.ShowCaptionInToolbar = True
Set btn = .Add("PopUP", , "Popup")
btn.ShowCaptionInToolbar = True
.Add "ANM", 0, " Add New Machine", eNormal, "Add New Machine Drawing"
.Add "ExitfrmMachineDistribution", 1, " Exit Form", eNormal, "Exit Form"
.Add "WRRF", 0, " Register / Re-allocation", eNormal, "Registratration / Reallocation of Machine"
End With
' Top level menu:
Set Bar = .CommandBars.Add("MENU", "Menu")
Set btns = Bar.Buttons
btns.Add .Buttons("PopUP")
'frmMachineDesc
Set Bar = .CommandBars.Add("EDITMENU")
Set btns = Bar.Buttons
btns.Add .Buttons("WRRF")
.Buttons("PopUP").Bar = Bar
' Top level menu: frmMachinedistribution
Set Bar = .CommandBars.Add("frmMachineDistributionMENU", "Menu")
Set btns = Bar.Buttons
btns.Add .Buttons("frmMachineDistributionPopUP")
'frmMachinedistribution
Set Bar = .CommandBars.Add("frmMachineDistributionEDITMENU")
Set btns = Bar.Buttons
btns.Add .Buttons("ANM")
btns.Add .Buttons("ExitfrmMachineDistribution")
.Buttons("frmMachineDistributionPopUP").Bar = Bar
End With
End Sub
Private Sub Form_Load()
createCommandBars
cmdBar(0).ToolbarImageList = ImageList2
cmdBar(0).MenuImageList = ImageList2
cmdBar(0).MainMenu = True
cmdBar(0).Toolbar = cmdBar(0).CommandBars("EDITMENU")
End Sub
Private Sub lvwMachineList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Pt As POINTAPI
GetCursorPos Pt
If Button = 2 Then
Dim xPixels As Long
Dim yPixels As Long
xPixels = Pt.X
yPixels = Pt.Y
cmdBar(0).ShowPopupMenu xPixels, yPixels, cmdBar(0).CommandBars("EDITMENU")
End If
End Sub
FORM2
VB Code:
Private Sub Form_Load()
cmdBar(1).ToolbarImageList = ImageList2
cmdBar(1).MenuImageList = ImageList2
cmdBar(1).Toolbar = cmdBar(1).CommandBars("frmMachineDistributionMENU")
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.
-
Sep 30th, 2007, 09:05 AM
#4
Thread Starter
Hyperactive Member
Re: vbAccelerator CommandBar Control Problem
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.
-
Sep 30th, 2007, 10:20 AM
#5
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
-
Sep 30th, 2007, 08:39 PM
#6
Thread Starter
Hyperactive Member
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.
-
Oct 1st, 2007, 04:38 AM
#7
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!
-
Oct 1st, 2007, 05:06 AM
#8
Thread Starter
Hyperactive Member
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.
-
Oct 1st, 2007, 05:23 AM
#9
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?
-
Oct 1st, 2007, 05:28 AM
#10
Thread Starter
Hyperactive Member
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.
-
Oct 1st, 2007, 05:33 AM
#11
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.
-
Oct 1st, 2007, 05:42 AM
#12
Thread Starter
Hyperactive Member
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.
-
Oct 1st, 2007, 06:09 AM
#13
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.
-
Oct 1st, 2007, 07:11 PM
#14
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|