|
This seems like a common response, and I keep trying to find exactly where the assertion occurs but apparently not very successfully. Here is what keeps happening...I run the program in the debugger and execute the commands that lead to the error. I have put breakpoints all around the code where I think the problem has been occurring and I continue to walk through and try to identify the exact problem, however, I keep walking through different code sources that aren't program written (like the WndProc()). When I hit the error, I get a the Debug Assertion Failed and it gives me the path of some file on an f: drive I don't have (I think f: is just the c++ notation)...then it asks me to abort, retry, or ignore...retry, i get the message that my program has triggered a breakpoint and it goes right to the last section of code.
I have been tracking m_bitmap because it seems to hold the information from the CreateDIBSection() which I think is where all the bitmap information is stored.
I wish I knew what I could post to be more informative, but this is a large program with lots of classes....I have happily worked with all the suggestions on the site (which are awesome!) and will continue to try to get more information and hopefully get the program to work correctly.
modified on Tuesday, August 9, 2011 1:26 PM
|
|
|
|
|
AndrewG1231 wrote: and it gives me the path of some file on an f: drive I don't have (I think f: is just the c++ notation)
No, it's not C++ notation, it is the path to some object or source module built into your application. If you do not know where your source and object modules come from then it's unlikely that anyone here will be able to make any useful guesses. It seems to me that you are trying to run/debug some code that has been developed elsewhere but you are not fully familiar with.
|
|
|
|
|
I understand, the thoughts on here have been very helpful with figuring out where to look. Here is the exact message (I think I just posted this in another thread..sorry)
Program: C:\Users\Jeffrey\Desktop\WinSTM\.\Debug\WinSTM.exe
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\filelist.cpp Line:225
This refers to the following code
ENSURE(SUCCEEDED(hr));
Add(psi, strAppID);
#endif
You are right, it is inherited code...and I am doing my best to figure out what is going wrong with it. I also apologize if some of the questions seem naive/amateurish.
|
|
|
|
|
If the ENSURE(SUCCEEDED(hr)) failed at filelist.cpp line 225, then it means that the call to ShellCreateItemFromParsingName() failed.
This is part of the CRecentFileList::Add method.
Whenever debugging assertions, use the callstack. What was calling whom? Walk up the stack to see what's going on.
What's the value of hr ? I bet that will offer a huge clue.
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
The value of hr is E_INVALIDARG of type HRESULT...this does seem to be telling me something, but I am not sure which argument it is referring to in my stack. After the the assertion when I press retry to continue to debug the program breaks and here is my call stack:
mfc100d.dll!CRecentFileList::Add(const char * lpszPathName, const char * lpszAppID) Line 225 + 0x25 bytes C++
mfc100d.dll!CWinApp::AddToRecentFileList(const char * lpszPathName) Line 84 C++
mfc100d.dll!CDocument::SetPathName(const char * lpszPathName, int bAddToMRU) Line 296 C++
mfc100d.dll!COleDocument::SetPathName(const char * lpszPathName, int bAddToMRU) Line 183 C++
WinSTM.exe!CWinSTMDoc::CopyDoc(CWinSTMDoc * pDocNew, int chan) Line 485 + 0x3b bytes C++
WinSTM.exe!CWinSTMView::CreateNewDoc(CWinSTMDoc * pDoc) Line 2715 C++
WinSTM.exe!CWinSTMView::OnImageAutoPlane() Line 4786 + 0x11 bytes C++
However, I think there is a problem going on here based on tracking m_Bitmap, but this occurs before the exception is thrown (the following call stack occurs when I hear a sound that seems to indicate a problem with the bitmap):
HBITMAP CWinSTMBmp::GetHBitmap(void)
{
return HBITMAP(m_Bitmap);
}
WinSTM.exe!CWinSTMBmp::GetHBitmap() Line 68 C++
WinSTM.exe!CWinSTMView::DrawImage(CDC * pDC) Line 774 + 0xe bytes C++
WinSTM.exe!CWinSTMView::OnDraw(CDC * pDC) Line 457 C++
mfc100d.dll!CView::OnPaint() Line 189 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2354 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2067 + 0x20 bytes C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 248 + 0x1c bytes C++
|
|
|
|
|
It's difficult to figure out, but are you sure the m_Bitmap member is valid?
One thing to remember is that you have to stash bitmap handles in the class, or they are destoyed after processing of the of the message, in this case WM_PAINT.
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
It is a valid pointer the first time it is called, but the second time it is initializes something is going wrong (it is remaining NULL when it should contain the information for the bitmap). However, they are destroyed after processing in my code. Here is the part of the bitmap processing code with the constructor/destructor through the "render" member where the flag of (m_Bitmap==NULL) becomes true and I get the message "Bitmap not init" (note, the 'a' in the code is my signal that this is code section telling me something is going wrong). Still, it works when the bitmap is first opened by the program, but not when I try to manipulate the image that results in the document being copied to a new window(CopyDoc is called).
CWinSTMBmp::CWinSTMBmp(void)
{
ZeroMemory(&m_HistogramData,sizeof(int)*256);
m_ImageMode = IMAGE_MODE_HORIZONTAL;
m_Inversion = false;
m_Derivative = false;
m_LineDC = false;
m_Render = false;
m_Bitmap = NULL;
m_BmpBits = NULL;
m_SizeX = 0;
m_SizeY = 0;
}
CWinSTMBmp::~CWinSTMBmp(void)
{
if(m_Bitmap != NULL)
DeleteObject(m_Bitmap);
}
bool CWinSTMBmp::Init(int sizex, int sizey, RGBQUAD* Pal)
{
if (m_Bitmap != NULL)
{
DeleteObject(m_Bitmap);
m_Bitmap=NULL;
}
if (m_Bitmap == NULL)
{
ZeroMemory ( &m_ImageInfo, sizeof (BITMAPINFO) );
m_ImageInfo.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
m_ImageInfo.bmiHeader.biWidth = sizex;
m_ImageInfo.bmiHeader.biHeight = -sizey;
m_ImageInfo.bmiHeader.biPlanes = 1;
m_ImageInfo.bmiHeader.biBitCount = 32;
m_ImageInfo.bmiHeader.biCompression = BI_RGB;
m_ImageInfo.bmiHeader.biSizeImage = 0;
m_Bitmap=CreateDIBSection ( NULL, &m_ImageInfo, DIB_RGB_COLORS, (void **)&m_BmpBits, NULL, NULL );
}
memcpy(m_RGB,Pal,sizeof(RGBQUAD)*256);
m_SizeX = sizex;
m_SizeY = sizey;
return true;
}
HBITMAP CWinSTMBmp::GetHBitmap(void)
{
return HBITMAP(m_Bitmap);
}
BITMAPINFO* CWinSTMBmp::GetBmpInfo(void)
{
return &m_ImageInfo;
}
bool CWinSTMBmp::Render(int* Data,int Min, int Max)
{
if(Data == NULL)
{
AfxMessageBox("Passing in a NULL Data Ptr");
return false;
}
if(m_Bitmap == NULL)
{
AfxMessageBox("aBitmap has not been init");
return false;
}
Do you happen to know what the
return HBITMAP(m_Bitmap);
is doing?
|
|
|
|
|
Couple of ideas:
m_Bitmap=CreateDIBSection ( NULL, &m_ImageInfo, DIB_RGB_COLORS, (void **)&m_BmpBits, NULL, NULL );
That could be failing and not setting m_Bitmap correctly.
return (HBITMAP)(m_Bitmap);
Is casting m_Bitmap to a HBITMAP (bitmap handle).
What is m_Bitmap defined as? A CBitmap?
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
There may be a problem with the first line, but I can't figure out why it initializes the first time I open the file but not when I try to use it. Regarding the second line..is that the same as the HBITMAP(m_Bitmap)? Is what you have shown the proper way to code the line?
As far as I can tell in the header file m_Bitmap is of type HBITMAP, see below:
class CWinSTMBmp
{
public:
CWinSTMBmp(void);
~CWinSTMBmp(void);
bool Init(int sizex, int sizey, RGBQUAD* Pal);
void SetLineDC(bool enable);
void SetInversion(bool enable);
void SetDer(bool enable);
void UpdatePallet(RGBQUAD* Pal);
HBITMAP GetHBitmap(void);
BITMAPINFO* GetBmpInfo(void);
RGBQUAD* GetBmpBits(void);
void SetProperties(bool Derivative, bool LineDC, int Direction, bool Invert);
void DeleteBmp(void);
bool Render(int* Data, int Min, int Max);
bool RenderUI(unsigned short* Data, int Min, int Max);
bool RenderMetaBmp(int * Data, int Min = 0, int Max = 0);
int* GetHistogramData(void);
bool m_Render;
bool m_Derivative;
bool m_LineDC;
bool m_Inversion;
RGBQUAD m_RGB[256];
HBITMAP m_Bitmap;
RGBQUAD *m_BmpBits;
BITMAPINFO m_ImageInfo;
int *m_DataPtr;
int m_HistogramData[256];
int m_SizeX,
m_SizeY;
int m_ImageMode;
int m_Max,
m_Min;
void NewLUT(RGBQUAD* newRGB);
};
|
|
|
|
|
You're probably trying to use the bitmap handle after it's been destroyed. Having the handle to the bitmap is not the same as having the bitmap itself. Generally I keep a CBitmap object in my class definition.
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
I tried what was suggested and have received the following message when I try to manipulate the image using the 'autoplane function'. The error is not occurring at all when I open a new image, but only when a new widow is opened in response to manipulation.
Data4 CXX0017: Error: symbol "IID_IShellItem" not found
This is the value that is causing the problem in for setting the value of hr to E_INVALIDARG. Visual Studio's debugger mentions something about the "value for this item being stale when trying to evaluate it"
What does it mean for a value to be stale?
modified on Wednesday, August 17, 2011 7:22 PM
|
|
|
|
|
The path is where the original source code was compiled. In this case, it's from the MFC Debug library, and the code was compiled on some Microsoft server.
Fortunetely, you have a copy of the MFC source code in the Visual Studio directory under .\VC\atlmfc\src
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
AndrewG1231 wrote:
if (m_Bitmap != 0)
DeleteObject(m_Bitmap);
if (m_Bitmap == NULL)
Is DeleteObject in the above code the same as this[^]? Because this one does not make m_Bitmap NULL. So in this case, you check if m_Bitmap is not NULL, if it is not, you try to destroy the GDI resource (a bitmap i assume), after this m_Bitmap holds an invalid handle, then if (m_Bitmap == NULL) will be false, so it goes on happily with the invalid handle. Could this cause your problem?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
|
I am not really clear about the concept of WS_EX_TRANSPARENT, when it used with a main window, it is not transparent at all, sometimes used with a control window, it does disappear from the parent window. Some people say it's not visually transparent, but we can click through it that the windows beneath will receive the mouse msg.
Do you know what this sytle really means? and in what condition it will work otherwise won't?
|
|
|
|
|
|
An application need to use the sdk to send and receive data with remote computer. But the network case is bad, the application uses the main thread to send and receive data, so the GUI is no-response in several seconds. It is bad for the users. The Main Class is derived from a interface, the sdk calls the callback function of application to transfer data. Is there any design pattern to avoid GUI's long-time no-response?
|
|
|
|
|
Start a thread (with AfxBeginThread for instance) passing the parameters you need and the m_hWnd of your window and make the long call in the static threaded function
Once you get the results in the thread, call PostMessage with the m_hWnd and the results...
Trap the message in your dialog with ON_MESSAGE
That's the short story...
|
|
|
|
|
That's pretty much it... Any significant work should be on its own thread.
|
|
|
|
|
BadJerry wrote: call PostMessage with the m_hWnd and the results...
Trap the message in your dialog with ON_MESSAGE
Can you post some sample code for this?
|
|
|
|
|
I am trying to port my MFC project to iPhone... is there some resources somewhere about some of the core (non GUI) MFC objects ported to XCode?
I have found on codeproject a good CString replacement
CString-clone Using Standard C++[^]
I am looking for COleDateTime... the CArray's MFC source code seems to compile!
Any pointer welcome!
Jerry
|
|
|
|
|
BadJerry wrote: the CArray's MFC source code seems to compile!
I'm not sure that this is a good thing.
But good luck with the port. I've always thought that porting MFC apps was similar to herding fish.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
I think that re-writing code in another language for another platform and expecting the same beaviour on both platforms was like herding fish...
But thanks - luck I need!
|
|
|
|
|
Alternatively if someone had the source code for VariantTimeToSystemTime, I'd be interested!
|
|
|
|
|
Check out the WINE[^] implementation, maybe it helps.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|