|
Hi Experts,
I need your help to solve a problem. Problem is to create a dynamic tree in memory.
I have a node with 2 field 1. Self Record Number and 2. Parent Record Number
I need to create a hierarchy (Tree) based on above information. Any node can come in any sequence. There is no rule defined for hirerchy.
How to set the node at run time so that I can create a correct child-parent hierarchy?
|
|
|
|
|
The "parent" should point to the parent and the "self" should point to the sibling.
But it is a very poor implementation, difficult to walk and maintain (who are the children of a given parent? you should keep a list of the "world" to scan!).
Hierarchies normally requires more pointers:
- to the parent
- to the first child (and eventually to the last)
- to the next sibling (and eventually the previous)
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
john5632 wrote: I have a node with 2 field 1. Self Record Number and 2. Parent Record Number
You can add your nodes to a vector, a linked list or a map. Then by definition you already have a tree, as long as you keep the constraint of not adding any loops, and keeping a single root node.
It all depends on what you want to do with it in the end. If you need fast look-up, then look at Emilios suggestion above. Otherwise, go simple.
|
|
|
|
|
Hi all, I need to retrieve image information from an CMenu item, below is my code, but exception occurs at last line when I call GetHBITMAP().
I suspect the dwItemData I retrieved is NOT a Bitmap*.
I suspect the menu I am working on is build with MFT_OWNERDRAW option.
// get the menu item icon
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_FTYPE;
mii.fType = MFT_OWNERDRAW;
pMenu->GetMenuItemInfo(i, &mii, TRUE/*1st param = item position*/);
HBITMAP hbm = NULL;
Gdiplus::Bitmap* pMI = (Gdiplus::Bitmap*)mii.dwItemData;
Gdiplus::Status status = pMI->GetHBITMAP(Gdiplus::Color(0, 255, 255, 255), &hbm);
Thanks in advance!
modified on Wednesday, July 6, 2011 9:50 PM
|
|
|
|
|
I don't see a call to GetMenuItemInfo() [^], so the contents of dwItemData will not be valid.
The best things in life are not things.
|
|
|
|
|
Sorry I removed that line with some other comments after pasting here. Added already. In the actual code I did call GetMenuItemInfo(), thanks!
|
|
|
|
|
nate31 wrote: Gdiplus::Bitmap* pMI = (Gdiplus::Bitmap*)mii.dwItemData;
Since dwItemData has not been initialized, what value do you suppose pMI has?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Can you point out what I should do here? Thanks!
|
|
|
|
|
Start with something like:
MENUITEMINFO mii = {0};
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_FTYPE;
mii.fType = MFT_OWNERDRAW;
if (pMenu->GetMenuItemInfo(i, &mii, TRUE ))
{
Gdiplus::Bitmap *pMI = (Gdiplus::Bitmap *) mii.dwItemData;
if (pMI != NULL)
{
HBITMAP hbm = NULL;
Gdiplus::Status status = pMI->GetHBITMAP(Gdiplus::Color(0, 255, 255, 255), &hbm);
if (status == Status::Ok)
;
}
else
ASSERT(FALSE);
}
else
dwError = GetLastError();
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi developers,
I am using a wrapper class (Taken from Codeproject), in which ADO connectivity has been used,
CADORecordset rsAccessMedia(&theApp.m_pDbHompath);
CString strQuery;
strQuery.Format( _T("select * from %s where ID = %d"), m_strTable, lngcurrItemID );
rsAccessMedia.Open( strQuery, CADORecordset::openQuery );
bool bIsOK = true;
if(rsAccessMedia.IsEOF()) //If Record not found for the selected( draaged ) media
bIsOK = false;
rsAccessMedia.Close();
At the last line application getting crashed. Connection is proper, but I don't know why it is being crashed.
Pls help me out.
Thanks.
|
|
|
|
|
I would not do this
strQuery.Format( _T("select * from %s where ID = %d"), m_strTable, lngcurrItemID );
unless m_strTable is a char* or const char* (or wide version thereof)
use
strQuery.Format( _T("select * from %s where ID = %d"), (LPCTSTR)m_strTable, lngcurrItemID );
to ensure proper interpretation of the argument.
Otherwise, it doesn't look too bad. The piece of code you supplied, is that all you have to run to get the error?
Edit: I'm assuming m_strTable is a CString.
|
|
|
|
|
Yes, m_strTable is a CString variable.
Then what's wrong with the query.
Is might be becoz of improper connection
|
|
|
|
|
The CString does not only contain a pointer to a character array, but also more information such as allocation size and length of current data. If you use a CString as an argument you will push all that to the stack, when in fact you only want the pointer to the character array on the stack, as described by the format specifiers to CString::Format(). You will simply mess up the arguments/stack. Do the conversion I suggested in the answer above to avoid this.
This is one reason to avoid variable arguments whenever possible. The compiler cannot perform type checks.
Does your code still fail?
|
|
|
|
|
Hi all,
this error comes when i am using win32 dll in c# application.
An unhandled exception of type 'System.BadImageFormatException' occurred in Test.exe
Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
please help me for this.
thanks in advance.
|
|
|
|
|
Please ask in the C# forum.
|
|
|
|
|
Are you building both the binaries on the same platform? 32 bit or 64 bit ?
|
|
|
|
|
|
Try this one, make your application run inside WoW64. For that go to the project properties, select the "build" tab and set the "platform target" to x86.
FYI : Read this.[^]
|
|
|
|
|
thanks,its working fine
but its safe and secure for further use.
is C# application work for all platform x86 and x64.
|
|
|
|
|
It depends for which platform you are building.
|
|
|
|
|
Hi all,
I am using visual studio 2010 and sometimes when i try to create a variable using add member variable wizard, it is not created. Try again and again and it is not created make a new dialog box and a new control then it is created.
can anybody please help me with this.
|
|
|
|
|
You should be posting this in the microsoft connect website as a bug.
On a different note, you could manually do what the wizard does and add a member variable by adding code.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
I've noticed the same thing. It usually works again the next time you have reopened the project/solution. If you really need this wizard to work, try reloading your project.
If you know what to add, you can do it more quickly manually than using the wizard anyway.
|
|
|
|
|
The wizards are generally unreliable, they're buggy, specially if you mess with any of the code they've generated (and the text comments/tags it inserts for itself). My recommendation, learn to do everything without wizards. It'll make you an overall better developer and will keep you from relying on something that works part of the time.
|
|
|
|
|
I have tried adding those variable manually but when i try to use those variable it gives error undeclared identifiers.
|
|
|
|