![]() |
|
#1
|
|||
|
|||
trouble with wm_gettext -- crashing and odd behaviorthis is weird. my program, GeekEdit, after displaying a Save As... dialog box, displays a message box (for debugging purposes) with the text grabbed from the edit control, and then saves it into a file. (right now it doesn't actually save anything; all it does is open the file with CreateFile() and then close it with CloseHandle()). anyway, it isn't grabbing the text correctly, or something. if there is one character in the edit control, nothing displays in the message box. if there are two or more characters, the program crashes. huh?i would appreciate it if anyone can help me with this...
p.s. the attachment mechanism is broken (doesn't open a new window and therefore closes itself and leaves attachments in permanent "in progress" state) in firefox, so my source files are posted: 1. http://www.geocities.com/zapguyd/dow...ekedit.cpp.txt 2. http://www.geocities.com/zapguyd/dow...geekedit.h.txt 3. http://www.geocities.com/zapguyd/dow...eekedit.rc.txt |
|
#2
|
|||
|
|||
|
You know, it's easier to call GetWindowTextLength() and GetWindowText() functions, I've never had any trouble with those. Another problem might be that you're using an int for the size, when it usually calls for a DWORD (unsigned long). I also don't see you allocating any memory, which might be somewhat problematic. In example:
CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
|
thanx dr. evil, that works
although, the program compiled and ran without the GlobalAlloc() and GlobalFree() calls. i omitted them because i didn't know what they did and had never used them before--what do they do and why are they necessary? |
|
#4
|
|||
|
|||
|
Quote:
They're basically the API versions of calloc() and free(), which would allocate memory to a pointer from the heap, otherwise you'd be trying to write/read memory which dosn't belong to you. However, I think C++ takes care of most of this for allocation and freeing for you, which would be why yours worked without those calls. |
|
#5
|
|||
|
|||
|
thx, however...i have another, equally vexing, problem now
my program crashes on its call to WriteFile() to actually perform the save! the files pointed to by the links in my first post have been updated I get error code 0xc0000005, and I am assuming that means 5, which is ERROR_ACCESS_DENIED. So I am guessing (wild guess) that there is a problem with memory, or WriteFile() is trying to access part of tbw_text that isn't actually there (like going past the end of an array). argh. someone please help |
|
#6
|
|||
|
|||
|
i forgot to add, if anyone cares, the error is reported as happening in the kernel32.dll module of my program, at address 0x000000007c810fb4
and i am running winxp sp2, compiled w/ dev-c++ 5 beta also, i thought of another possibility for the error, if the file hadn't really been created. but i checked for that possibility, with the writefile() being inside an if(hFile)... |
|
#7
|
|||
|
|||
|
YES! i fixed it
i found msdn's example, and played w/ the pointers so that it looked like what they had. it turns out i do need those memory calls, stuff crashes without it thanx 4 your help dr. evil |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The