I've read the following statement and I cannot understand something within it "In all binary trees, there are at most 2^i nodes at level i + 1" what I cannot understand is that tree's levels start at level 0, however, if we apply what is written in this statement there will be no level 0 at all as it says level i + 1 which mean 0 + 1 = level 1, 1 + 1 = level 2, etc. So is this statement wrong?!!! or I am missing something?!!!
I read it in 2 books "Data Structures Through C in Depth" and "Data Structures and Algorithms in C++, 4th Edition" and even the link you gave to me saying "The root of the tree, therefore, is at level 0" which means that tree's level starts at 0. So I am confused because those books also saying that tree's level starts at 0?!!!
I know it is correct to say 2^N, however, to say for level N+1 is what makes me confused because tree's level starts at level 0 which mean that N = 0 so if we apply the above statement it will be 2^0 for level 0 + 1 which means 1 node for level number 1 I hope you get what I meant
I know it is correct to say 2^N, however, to say for level N+1 is what makes me confused because tree's level starts at level 0 which mean that N = 0 so if we apply the above statement it will be 2^0 for level 0 + 1 which means 1 node for level number 1 I hope you get what I meant.
I have a service I wrote that uses a filewatcher. On create it takes the excel file and truncates table and import it.
It works on my Windows 7 box. When I drag a new file into the folder it imports it. If i drag a newer file it deletes the old data and imports the new data.
On Windows 2012 Server the service works on the first import. on the second drop of a excel file I get
Error durring import of file 20151106.xls
Exception occured in Microsoft JET Database Engine
Exception: The Microsoft Jet database engine cannot open the file. It is already opened exclusively by another user, or you need permission to view its data.
I have a large legacy application being updated to use newer CMFCRibbonBar. This application is large and the creation of the CMFCRibbonBar involves converting a lot of legacy icons and menu structures so is a bit complicated to extract and post here. I will add further details as people request them.
But the general gist is:
The application works fine and has a valid and working CMFCRibbonBar.
That ribbon bar has 11 categories across the top. With hundreds of panel buttons and menu buttons.
I have also recreated the same structure using CMFCRibbonButton to create a quick old style menu system which has been added to the m_wndRibbonBar via the AddToTabs. This give me a working drop down menu in the top right had corner. I believe there is a general web example which people may be familiar with which create a “window style” dropdown where you to change the MFC window manager style from windows 2000 through to windows7.
My menu is created from scratch at application startup and is not taken from a menu resource as this application predates this structure.
I use commands like the following to construct this menu:
pQuickMenu = new CMFCRibbonButton(ID_MENU++,TEXT("Quick Menu"),-1,-1,0);
pQuickButton = new CMFCRibbonButton(ID_MENU++,wMenuCommand,-1,-1,0);
The problem I am having is dynamically adding new buttons to this quick menu at a later date.
When I originally created this quick menu I kept the pointer to this structure that was used to add to the ribbon. Therefore I am able to add to the quickmenu.
pQuickBut = new CMFCRibbonButton(ID_MENU,wMenuCommand,NULL,0,hSmall,0,0);
If I add a new button to the existing stored top level quick menu using the stored pQuickMenu pointer, the button does appear. The text is correct and the button is selectable.
Except that the button is not operated upon when clicked.
If I add the button to the m_wndRibbonBar instead then it works so I know there is a valid command handler.
Down within the MFC code, clicking on my new quick access menu enters a routine called:
This extracts the command id correctly.
UINT uiID = GetNotifyID();
But it then checks for a valid ribbonbar.
CMFCRibbonBar* pRibbonBar = GetTopLevelRibbonBar();
This fails and returns a null pointer. Thus the command processing structure is exited.
As a test, if I call m_wndRibbonBar.AddToTabs(pQuickMenu) again for a second time adding the same menu to the RibbonBar a second time, then the origial becomes corrupt but the new command does work.
I am therefore assuming (guessing) that when the AddToTabs is called there is a ribbon handle stored with the commands. When I add directly to the existing structure after the original call to AddToTabs, a valid ribbon handle is not happening.
In the old style of things I would detach my quick menu, update it and then reattach. But I do not know how to do this (or even if it is nessesary) in the new CMFC classes.
The command: m_wndRibbonBar.removeallfromtabs(); deletes the whole of my pQuickMenu structure so I can not then add to it.
Is there anyone who can help explain how to dynamicaly add new buttons to an exising menu that has been added to a ribbonbar tab.
Any help appreciated.
Can anyone help me?
I am still unable to add to a ribbonbar “tab”.
Here is an example bit of code, which when added to a new MFC MDI basing ribbon example generated from the wizard works correctly until I add the bit at the bottom.
pQuickMenu = new CMFCRibbonButton(1000,TEXT("QuickMenu"),NULL,0,0,0,0);
pQuickMenu->AddSubItem(new CMFCRibbonButton(1001,TEXT("Do I work?"),NULL,0,0,0,0),-1);
void CMainFrame::DoIWork(UINT ID)
MessageBox(TEXT ("Yes I Do!"),TEXT("Do I Work?"), MB_ICONWARNING) ;
If I add the above strucutre to a ribbon based MDI MFC application, a new “QuicMenu” tab appears on the menu system. It works. If I click the “Do I work?” menu entry then it pops up a panel saying “yes I do!”
If I now add a button to the ribbonbar at time of initialisation, which when clicked will adds a new button to the “QuickMenu” menu then all is good. The additional button turns up and is selectable.
But when I select this new menu entry from the “quickmenu”, the click is registered but in the lower MFC code it fails to recognise a valid ribbonbar handle and exists without processing the message (see my first post for more info).
Can anyone help?
I am realy stuck and may have to scrap the ribbon and revert to basic menus only if I can not dynamicaly add to my quickmenu as rquired.
What am I missing or overlooking when I'm adding to my QuickMenu structure?
Here is a link to a visual studio project which demonstrates my issue. If anyone can explain why the clicking of the button on the ribbon generates a new menu entry which does not get acted upon I would be very grateful.
In my project I created object for class using new operator. After use I deleted that object and set that to NULL. But even after deletion, I could able to access and able to run other functions using that (deleted)object.
Please go through example:
CTemp *objTemp = new CTemp;
objTemp = NULL;
objTemp->Fun2(); // It is illegal still works, why?
It will only work when your CTemp::Fun2() function does not access non-static member variables or call other member functions that would do so. Then the implicit this pointer will be used which is NULL generating an access violation.
I am in the process of trying to code the transmission of floating point data over an ethernet cable. I decided to send two bytes, the first with the "whole" part and the second with the "fractional" part (but as an unsigned char). The first byte works fine, but the second (trivial) part is giving me a strange (to me) problem which is driving me nuts - I can't see WHAT I'm getting wrong. Here is the test code:-