|
Another potential error is that both your list boxes have the same ID; IDC_LIST. They should be different.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
SON OF A B****!!!
I was looking through other parts of the code and found the problem somewhere else! As it turns out, that run-time error simply refers to an array index out of bounds error (not quite a divide-by-zero, but )
I don't even know why this only came up when I added list boxes, the array had nothing to do with them.
Anyway, sorry for wasting your time.
|
|
|
|
|
I am having some weired situation going on in my VC++ program when I allocate and deallocate memory wihtin the application. Lemme explain the scenario, I am having an applicaiton where I allocate memory to a variable (which are initialized to NULL when the program starts) whenever the user requests and only deallocates it when the user requests the same variable again where I reallocate the memory again. But when I deallocate the memory it is not releasing the whole memory that I have allocated it before.
For example-
My program starts with total mem usage of 92596 bytes (At this point I haven't allocated any memory to those variables)
When I allocate memory to the first variable using either GlobalAlloc or VirtualAlloc it increases by 94752 bytes which equals to ~2000bytes
When I deallocate the memory using either GlobalFree or VirtualFree it is deallocating only half of the memory ~1000bytes
Now When I reallocate the memory in the same way as above, it is allocating new 2000bytes.
So, in this way slowly the memory being used by my program is increasing drastically after a while, as I sometimes allocate about 225 variables of ~2000bytes each.
But when I deallocate the memory of the same variables when I am exiting the application it does deallocate ~2000bytes of each variable.
Is there something I am doing wrong??
thanks.
-Pavan
|
|
|
|
|
pavanbabut wrote: Is there something I am doing wrong??
As long as you are freeing all memory that you allocate, then no
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
You can make calls to GetProcessWorkingSetSize and GlobalMemoryStatus to see if the numbers are changing.
|
|
|
|
|
Whenever I check it, it is freeing only half of the allocated size. But it frees the whole allocated memory when I deallocate it at the time of terminating the application, not while 'm running the application.
-Pavan.
|
|
|
|
|
How are you checking this? There's no accurate way that I know of.
Try this if you'd like:
MEMORYSTATUS OrigMemoryStat;
::GlobalMemoryStatus(&PrevMemoryStat);
TRACE(_T("********************************\n"));
for (int i = 0; i < 100; ++i)
{
HGLOBAL hGlobal = ::GlobalAlloc(GHND, 2000);
::GlobalFree(hGlobal);
MEMORYSTATUS MemoryStat;
::GlobalMemoryStatus(&MemoryStat);
TRACE(_T("********************************\n"));
TRACE(_T("** Delta dwAvailPhys %li Bytes\n"), (long)MemoryStat.dwAvailPhys - (long)OrigMemoryStat.dwAvailPhys);
TRACE(_T("** Delta dwAvailVirtual %li Bytes\n"), (long)MemoryStat.dwAvailVirtual - (long)OrigMemoryStat.dwAvailVirtual);
}
TRACE(_T("********************************\n"));
Trust the OS
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Ok, I figured out the problem. Once I allocate the memory, I am saving data into the variable by calling another function, in this process I am allocating more memory to another variable to hold a bitmap data, which is not being deallocated later and its piling up.
-Pavan.
|
|
|
|
|
|
Nice article... thanks..
|
|
|
|
|
|
Anil K P wrote: While trying, I get it as RGB(205,205,205) which is White.
More of a gray.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Anil K P wrote: I need to get the background color of an active window. While trying, I get it as RGB(205,205,205) which is White
How are you doing this?
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Anil K P wrote: RGB(205,205,205) which is White
wrong, white is RGB(255, 255, 255)
|
|
|
|
|
|
Bookmarked/Favorited. Thanks!
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
|
I was too searching for the same
Thanks
|
|
|
|
|
|
I am wondering if anyone knows a reliable way using GDI to detect whether an HFONT has unicode support?

|
|
|
|
|
Does the GetFontUnicodeRanges() API help to determine Unicode support for a font?
CClientDC dc(this);
CFont font;
VERIFY(font.CreatePointFont(120, _T("Arial Unicode MS"), &dc));
CFont* def_font = dc.SelectObject(&font);
DWORD dwGlyphSetSize = ::GetFontUnicodeRanges(dc, 0);
GLYPHSET *pGlyphSet = (GLYPHSET *)new BYTE[dwGlyphSetSize];
::GetFontUnicodeRanges(dc, pGlyphSet);
delete[] (BYTE *)pGlyphSet;
dc.SelectObject(def_font);
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Thanks Mark
I looked into that API call, however the other stipulation that I forgot to mention is that it has to work with windows 98. Unfortunatly that call only works for 2000 and up.
If there is any other way that you know of?
Thanks again Mark
Dave
|
|
|
|
|
Hmmm, maybe this KB article will help: Unicode support in Windows 95 and Windows 98[^]
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
I have a DefWindowProc() function to catch unhandled messages. This function returns an LRESULT. I have a switch statement and in some cases I call CWnd::DefWindowProc(). So I simply return the result of the call to CWnd::DefWindowProc(). In other cases, I handle the message.
What should the value of LRESULT be when I handle the message?
|
|
|
|
|
Depends on the message. The documentation will tell you if the message needs a certain return value. If it does not then simply return zero.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|