|
|
Comments and Discussions
|
|
 |

|
Is there anybody else encountering this error?
possible pointer to a menu popup error?
I have narrowed the problem to the ff:
in DynamicItems.cpp Line 315:
pSubMenu->InsertMenu(.. MF_POPUP.. )
SystemTray.cpp line 865, 869:
TrackPopupMenu();
Thanks in advance.
|
|
|
|

|
See this subject
MDI Bug/Assert Fix Sully 14:10 27 Feb '03
|
|
|
|

|
Hai,
Thanks for the article.....
I have small doubt, Can we change the MaxNo of items dynamically???
Hope got my doubt.waiting for solution..
And how can we get the selected menu item string.
I think you have stored some array type and doing it..
Can we get the selected menu item string..CMenu has many member functions like GetMenustring, GetMenuInfo soon..Can we use this functions here..If so how to use this to get it..
Regards
vijay
|
|
|
|

|
Hey!
First if all, thx for this great class!
Unfortunately, there seem to be some issues under Win98: Neither the Modal-Dialog example nor my own dialog-based app shows the dynamic menu items there.
In your modal-based example, the LoadMenu command doesn't show the file dialog. In my own app, the dynMenu items are just "shrinked", they show no text at all and have a very small line height. Futhermore, the ON_UPDATE_COMMAND_UI_RANGE macro seems to not call the associated handler method at all.
Both apps work great under XP. The Systray example works on Win 98 and XP.
I found several potential reasons for these issues on the WWW: Resource IDs over 3267 can cause problems on Win98, Modal-Dialog-Apps have problems to update menus without an ON_WM_INITMENUPOPUP handler (which your dialog-based example doesn't have neither?!) the update-ui-range macro fails if it's menu IDs have no subsequent values (no problem here), and there could be unicode problems.
As your example seems to be compiled under VC6 with no unicode support and the resources are in the same range as in your systray example - why does the first example fail, while the other one works?
Does anybody have any ideas?
ibthas
|
|
|
|

|
Is it possible to upgrade this project to support unicode .Dat file so that resouce can be in forign lang.
Currently it is not
zcsfds
|
|
|
|

|
Under XP, can I pain the menu bar myself, ignoring the Windows theme on the PC
Hope someone can help
Thanks
Alex
|
|
|
|

|
How can I change the MENU BAR colour (assuming XP only) from whatever te Windows theme is
Hope someone can help
Thanks
Alex
|
|
|
|

|
I was compling it with VS2003,then the error occurs,can
you help me?
|
|
|
|

|
Use the new STL header filenames:
#include
Instead of the older way
#include
IMHO, "fstream.h" refers to "local project files", but most compilers will
lookup in files when "local" are not found.
|
|
|
|

|
I cannot fight this error too
After changing --#include [fstream.h]-- to --#include [fstream]-- 13 error(s) and 3 warning(s) appear. Buildlog is saved to http://rapidshare.de/files/7474319/buildlog.html
VS2003EA.
-- modified at 6:11 Friday 11th November, 2005
|
|
|
|

|
It's easy - just add
using namespace std;
and create ifstream object this way:
i_file = new ifstream (pFileName);
Although the question is 1 year old, maybe this answer would be useful to someone trying to use this code
|
|
|
|
|

|
After closing the notify program, the developer studio displays memory leaks.
Memory is allocated during the pushback in: void addItem(CMenuItem* item) { m_items.push_back(item); } but
is never been deleted.
Can somebody help me with this?
I really like this class and would like to use it, but without the memory leak
|
|
|
|

|
Found the problem:
delete in function CPopMenuItem::clear() always calls the
CMenuItem destructor. This is wrong if the pointer which was passed
in addItem was pointing to a CPopMenuItem object.
Make the following changes in CPopMenuItem::clear():
void clear()
{
std::vector< CMenuItem* >::iterator iter = m_items.begin();
for ( ; iter != m_items.end(); ++iter )
{
(*iter)->clear();
if ((*iter)->getType() == POPUP)
{
CPopMenuItem* pPopupCurrentItem = (CPopMenuItem*)(*iter);
delete pPopupCurrentItem;
}
else
delete (*iter);
}
m_items.clear();
}
|
|
|
|

|
Hi
Is it possible to rename "Dyn Menu" dynamicly in my running app?
greetz, Michael
|
|
|
|

|
Does anyone know where I can find these files: "TestFile.txt" and "TestFile2.txt". They were supposed to be included in the sample code.
|
|
|
|
|

|
The dynamic popup menu items need to detach, that is, they need to surrender ownership of the menu.
===[DynamicItems.cpp]======
void CDynamicItems::addDynamicPopupMenu(CMenu* pSubMenu, CPopMenuItem* menu_item)
{
//...
switch ( PopupCurrentItem->getType() )
{
case CMenuItem::POPUP:
{
CMenu* menu = new CMenu();
menu->CreatePopupMenu();
addDynamicPopupMenu(menu, (CPopMenuItem*)(PopupCurrentItem));
pSubMenu->InsertMenu( 0, MF_BYPOSITION | MF_POPUP,
(UINT)menu->GetSafeHmenu(),
PopupCurrentItem->getName().c_str() );
menu->Detach(); // <<----- ADD THIS!
delete menu;
}
break;
|
|
|
|
|
|

|
Your code is great..I was looking for some ideas like this for a long time...And here is your code... But..(sorry)...As it is not 100% dynamic since you fixed in advance the size of your "dynamic" menu I won't consider it as dynamic...But...I work around it to have it working 100% dynamic without changing a resource.h file.. Right now it is crappy code coding but i think people here can start with that.. The idea is to have " ON_COMMAND_RANGE( ID_POPUP_DynCmd01, ID_POPUP_DynCmd20, OnExecuteDynamicMenu )" fully dynamic without any conflict with resource id. So I define a variable in the Main frame #define ID_DYN_MENU_FIRST_CMD 99000 (high unsual number to be sure it won't conflict to some id). Then we have to know how many items we have in our menu. So I create a public static variable in CDynamicItems (m_nb_items) that count the number of elemt in the menu. And so now you can have : ON_COMMAND_RANGE( ID_DYN_MENU_FIRST_CMD, ID_POPUP_DynCmd01+CDynamicItems::m_nb_items, OnExecuteDynamicMenu ) Also don't forget to create a function in CDynamicItems to set the first ID (ie: m_DynamicItems.setFirstItem(ID_DYN_MENU_FIRST_CMD); )that is called in the mainframe constructor... And now you can remove the line in the resource.h file that contains the "dynamic" items. It works fine for me...I can have any number of plugin with menu item... And i don't care about the resource !! Is that clear for everybody ? I can make a zip file with the previous project with my added code... But thanks at dexcoffier@yahoo.fr for his great first idea ... Lionel Grenier Virtual Environment Programmer
|
|
|
|

|
Nice improvement! One comment through. When I tried 99000 in VC6.0 it wouldn't work normally. My guess is that UINT doesn't go that high. Visual Studio re-assigns new values (something around 34360+-). But otherwise this is very helpful because it saved me a lot of code.
10q
EPHERE
|
|
|
|

|
The article will be updated soon with new sample codes (systray & modal app) including update v1.1 ...
Keep an eye on it !
|
|
|
|

|
When running this program under Win 98, I get the following error: "This program has performed an illegal operation and will be shut down." This error occurs then I try to highlight (fly-over) one of the file's menu choice.
Thanks,
King
|
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A class and an easy way to dynamically add items stored in a file to a menu
| Type | Article |
| Licence | |
| First Posted | 28 May 2001 |
| Views | 146,563 |
| Bookmarked | 81 times |
|
|