A Dib Handle Problem
Guys:
I am now working on a application which processing .BMP files.
use the following statements I get the memory handle of the picture:
//
//do something open the bitmap
//
HGLOBAL m_hDib;
m_hDib = (HGLOBAL)::GlobalAlloc(GHND, Length);
then ,after some action, I want to delete the memory block I alloc,I use statement :
::GlobalFree((HGLOBAL)m_hDib);
I get a messagebox says that "illegal operation".I am not sure why I get this answer for all what I do is to operate on the fact points that only influence the apperance of a bitmap.
Can anybody tell me WHY?Thanks.
[735 byte] By [
Jacky Boy] at [2007-11-17 22:39:44]

# 1 Re: A Dib Handle Problem
It obviously depends on what you do between those two lines of code. Are you passing that handle to some API function ? It would be helpful to show the whole code (if it's not too long). Be sure to use the [code] and [/code] tags.
Yves M at 2007-11-10 8:41:48 >

# 2 Re: A Dib Handle Problem
As Yves already pointed out that the problem will most-likely between the given lines.
A common pitfall is that the length of allocated memory was calculated to small and therefore you/a function will write over the boundaries of the allocated memory and causes trouble...