Just starting out? Need help? Post your questions and find answers here.
ssg_mick
User
Posts: 10 Joined: Thu Oct 26, 2017 12:13 pm
Post
by ssg_mick » Thu Jan 04, 2018 3:59 pm
Hi,
i have a popupmenu containing 2 seperators.
Code: Select all
Procedure createContactPopupMenu()
ContactPopupMenu = CreatePopupMenu(#PB_Any)
MenuItem(101, LANG_ShowCustomer.s)
MenuItem(103, LANG_ShowNotes.s)
MenuItem(104, LANG_ShowEmails.s)
MenuItem(105, LANG_ShowTasks.s)
MenuItem(106, LANG_ShowBranches.s)
MenuItem(107, LANG_ShowOrders.s)
MenuBar()
MenuItem(109, LANG_CreateNote.s)
MenuItem(110, LANG_CreateEmail.s)
MenuItem(111, LANG_CreateTask.s)
MenuItem(112, LANG_CreateBranch.s)
MenuItem(113, LANG_CreateOrder.s)
MenuBar()
MenuItem(114, LANG_PhoneCall.s)
EndProcedure
But when i run my code, i get 3 seperators instead of one for every MenuBar().
Michael
Windows 10, PureBasic 5.70 LTS
skywalk
Addict
Posts: 3972 Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA
Post
by skywalk » Thu Jan 04, 2018 4:15 pm
Gap in your MenuItem() numbers? 102,108?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
wombats
Enthusiast
Posts: 663 Joined: Thu Dec 29, 2011 5:03 pm
Post
by wombats » Thu Jan 04, 2018 5:29 pm
The menu creation code you posted seems to work fine for me.
How are you using the createContactPopupMenu() function in your project? Are you recreating the menu each time it needs to be shown? Maybe you need to free it before recreating it.
Marc56us
Addict
Posts: 1477 Joined: Sat Feb 08, 2014 3:26 pm
Post
by Marc56us » Thu Jan 04, 2018 6:11 pm
This can happen if one of the character strings (menu text) is empty.
ie: if LANG_PhoneCall.s = ""
PS. Avoid using direct numbers as gadget ID, always use name or constant
ssg_mick
User
Posts: 10 Joined: Thu Oct 26, 2017 12:13 pm
Post
by ssg_mick » Thu Jan 04, 2018 8:26 pm
wombats wrote: The menu creation code you posted seems to work fine for me.
How are you using the createContactPopupMenu() function in your project? Are you recreating the menu each time it needs to be shown? Maybe you need to free it before recreating it.
Yes, i create the PopupMenu every time when it should be shown. I wanted to try FreeGadget(ContactPopupMenu), but this only works, when it exists. How can i check, if a Gadget exists?
Michael
Windows 10, PureBasic 5.70 LTS
davido
Addict
Posts: 1890 Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK
Post
by davido » Thu Jan 04, 2018 8:29 pm
@ssg_mick ,
May I suggest you look at: IsGadget() .
Or, perhaps: IsMenu() .
DE AA EB
ssg_mick
User
Posts: 10 Joined: Thu Oct 26, 2017 12:13 pm
Post
by ssg_mick » Thu Jan 04, 2018 8:33 pm
I tried this:
Code: Select all
If IsGadget(#CustomerPopupMenu)
FreeGadget(#CustomerPopupMenu)
EndIf
but this did not solve the Problem.
Michael
Windows 10, PureBasic 5.70 LTS
RASHAD
PureBasic Expert
Posts: 4637 Joined: Sun Apr 12, 2009 6:27 am
Post
by RASHAD » Thu Jan 04, 2018 8:34 pm
Code: Select all
Global ContactPopupMenu
Procedure createContactPopupMenu()
If IsMenu(ContactPopupMenu)
FreeMenu(ContactPopupMenu)
EndIf
ContactPopupMenu = CreatePopupMenu(#PB_Any)
MenuItem(101, LANG_ShowCustomer.s)
MenuItem(103, LANG_ShowNotes.s)
MenuItem(104, LANG_ShowEmails.s)
MenuItem(105, LANG_ShowTasks.s)
MenuItem(106, LANG_ShowBranches.s)
MenuItem(107, LANG_ShowOrders.s)
MenuBar()
MenuItem(109, LANG_CreateNote.s)
MenuItem(110, LANG_CreateEmail.s)
MenuItem(111, LANG_CreateTask.s)
MenuItem(112, LANG_CreateBranch.s)
MenuItem(113, LANG_CreateOrder.s)
MenuBar()
MenuItem(114, LANG_PhoneCall.s)
EndProcedure
Egypt my love
ssg_mick
User
Posts: 10 Joined: Thu Oct 26, 2017 12:13 pm
Post
by ssg_mick » Tue Jan 16, 2018 4:46 pm
Marc56us wrote: This can happen if one of the character strings (menu text) is empty.
ie: if LANG_PhoneCall.s = ""
PS. Avoid using direct numbers as gadget ID, always use name or constant
This was my fault...
I had 2 MenuItems with empty Text$:
Code: Select all
Procedure createCustomerPopupMenu()
If CreatePopupMenu(#CustomerPopupMenu)
MenuItem(#PopupMenuItemShowContacts, LANG_ShowContacts.s)
MenuItem(#PopupMenuItemShowNotes, LANG_ShowNotes.s)
MenuItem(#PopupMenuItemShowEmails, LANG_ShowEmails.s)
MenuItem(#PopupMenuItemShowTasks, LANG_ShowTasks.s)
;MenuItem(#PopupMenuItemShowBranches, LANG_ShowBranches.s)
;MenuItem(#PopupMenuItemShowOrders, LANG_ShowOrders.s)
MenuBar()
MenuItem(#PopupMenuItemCreateContact, LANG_CreateContact.s)
MenuItem(#PopupMenuItemCreateNote, LANG_CreateNote.s)
MenuItem(#PopupMenuItemCreateEmail, LANG_CreateEmail.s)
MenuItem(#PopupMenuItemCreateTask, LANG_CreateTask.s)
;MenuItem(#PopupMenuItemCreateBranch, LANG_CreateBranch.s)
;MenuItem(#PopupMenuItemCreateOrder, LANG_CreateOrder.s)
MenuBar()
MenuItem(#PopupMenuItemPhoneCall, LANG_PhoneCall.s)
EndIf
EndProcedure
Thanks all for your help and ideas.
Michael
Windows 10, PureBasic 5.70 LTS