smcd
Active member
To load text into an edit window, read it and then SetWindowText, or SendMessage with WM_SETTEXT, or to append (in a rather hacky sort of way) you can SendMessage with EM_REPLACESEL if the cursor is at the end of the text
Whoah shizzie, you're mixing standard C functionality with Windows in an improper way. fopen returns NULL if it fails to open the file, you shouldn't use Windows constants in instances like that. Also, what exactly is that code supposed to do? It looks like you're opening for writing, when later it looks like you're trying to read... Also you free something that is never allocated, nor is it commented that it is dynamically allocated coming into the function. Calling CloseHandle on a FILE* is improper as well, you should use fclose. Not to mention some variable names that appear in the function that aren't declared?! ^gives up trying to figure out that code^
ShizZie said:If this isn't what you want, I'm not really sure what you're looking for - try to rephrase the question
Code:#include <windows.h> #include <memory.h> #include <stdio.h> #include <commctrl.h> #include <commdlg.h> BOOL LoadFile(HWND hEdit, LPSTR pszFileName) { FILE *hFile; BOOL bSuccess = FALSE; hFile == fopen("log.txt", "w"); if(hFile != INVALID_HANDLE_VALUE) { if(1) { if(pszFileText != NULL) { DWORD dwRead; if(fprintf(hFile, "Here is the memory:\n %x ", memory);) { //pszFileText[dwFileSize] = 0; // Null terminator //if(SetWindowText(hEdit, pszFileText)) bSuccess = TRUE; // It worked! } GlobalFree(pszFileText); } } CloseHandle(hFile); } return bSuccess; }
Whoah shizzie, you're mixing standard C functionality with Windows in an improper way. fopen returns NULL if it fails to open the file, you shouldn't use Windows constants in instances like that. Also, what exactly is that code supposed to do? It looks like you're opening for writing, when later it looks like you're trying to read... Also you free something that is never allocated, nor is it commented that it is dynamically allocated coming into the function. Calling CloseHandle on a FILE* is improper as well, you should use fclose. Not to mention some variable names that appear in the function that aren't declared?! ^gives up trying to figure out that code^
Last edited: