|
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.
|
|
|
|
|
Means you're probably forgetting to do something. I do this by hand all the time, and unlike the wizards, it works every time. Like I said, nothing wrong with using the wizards, but they're not the most reliable thing ever implemented.
|
|
|
|
|
Hi,
In my application for one child window,im having more than 100 pages.When page up and page down im moving coresponding next pages.BEfore getting next page, im destroying the previous page by using DestroyWindow.
But when i see in the Task Manager,Perormance Tab,The PF usage shows for every page it increasing 0.01GB and in Physical Memory(K)-Available the number(ex:1571826)is getting reduced and soon one error is coming like
"Out of memory,edit".
Im pasting here my PageUp and Pagedown code:
void CGraphView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(nChar == 33 || nChar == 34)
{
short iTempPgNo = ((CMainFrame*)AfxGetMainWnd())->m_ngiSchPNo;
if(nChar == 33)
{
iTempPgNo--;
}
else
{
iTempPgNo++;
}
if(iTempPgNo != m_ngiSchPNo)
{
CString sNo;
if( gpGView[nCurrGrpView]->glg_animation[giSchPNo].m_hWnd )
{
gpGView[nCurrGrpView]->glg_animation[giSchPNo].DestroyWindow();
giSchPNo = iTempPgNo;
if(giSchPNo > giGraphicCnt)
giSchPNo = giGraphicCnt;
((CMainFrame*)AfxGetMainWnd())->m_ngiSchPNo = giSchPNo;
}
}
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
Eventhough im using DestroyWindow(),why the memory is getting increased for each page down.
Anu
|
|
|
|
|
Only frame windows destroy their associated C++ object when DestroyWindow is called. With CWnd-derived windows only the Windows UI HWND is destroyed when DestroyWindow is called. Do you need to delete a CWnd object too or are you reusing them? Or are they frame windows?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
CGraphView is one of the childframe, this class is using to show Graphics window.We are using one third party DLL to show the gaphcis page(glg_animation).
Anu
|
|
|
|