*sigh*. I always seem to butt my head against probs. that make no sense when I use the win32 api. Anyone have some insites on the problem that follows?
When the code below executes, at the Edit_SetText macro call, I get a:
Unhandled exception in fontConstruct.exe (NTDLL.DLL): oxC00000FD: Stack Overflow
Code:
Code:void SizeChanged() { int charsCopied = 0; TCHAR * buff; TCHAR * buffptr; TCHAR * buff2; int len; int i = 0; HWND ctrl; ctrl = GetDlgItem(hdlgActive, IDE_FONTSIZE); len = Edit_GetTextLength(ctrl); if(!len) { // feild cleared // set flag return; } buff = (TCHAR*) malloc(sizeof(TCHAR)*(len + 1)); buffptr = buff; buff2 = (TCHAR*) malloc(sizeof(TCHAR)*(len + 1)); if(buff == NULL) { // error } Edit_GetText(ctrl, buff, len+1); while(*buffptr != '\0') { if(isdigit(*buffptr)) { buff2[i++] = *buffptr; } buffptr++; } buff2[i] = '\0'; Edit_SetText(ctrl, buff2); // ERROR HERE free(buff); free(buff2); }
TIA for any help
-John



LinkBack URL
About LinkBacks



According to "Win32 Programming" "Another odd-and undocumented-feature is that the length you give must be one character longer than the maximum line lenght your can retrieve. Although the EM_GETLINE message does not put a terminating NUL byte at the end of the string, it assumes that you problaby will do this. Hence, it will not copy more then the character count minus one character to the buffer. This is for GETLINE, but by single stepping through the code, I found the ALMOST the same situation for GETTEXT but it does put the terminator in. So the +1 is nessesary. As for the alternate code, I suppose could do that, but don't see the need other then a possible marginal increase in speed by gettin rid of the array access. The program is (suppose to be) quick and dirty hacked together prog for to make a header file and bitmap of a selected true type font for a font engine for a dx lib. I'm wriing. So speed doesn't really mater at all, and that's the first way that came to mind