-
MVC++ and resources
How do you create a resource file from scratch with MSVC++?. Every time I go to insert-->resource It makes me use the MFC.
one other thing.
Code:
char ch;
ifstream in("C:/FIGURE2.txt");
if(in.fail()) {
MessageBox(NULL, "Cannot open file","Error",MB_OK);
}
while(in.get(ch)){
SendMessage(editbx,WM_SETTEXT,(WPARAM)0,(LPARAM)ch);
}
I want to be able to load a text file into a edit box. But this does not seem to work.
Any help appreciated
-
If you go File->New->Resource Script it doesn't force you to use MFC :)
WM_SETTEXT sets the whole text. You need to load into a buffer and then set using that.
Code:
in.readline(buffer, bufsize)
-
ok, im getting the text into the box, but it keeps deleting what its written and replaces it with the next line. :confused:
-
First retrieve the text using WM_GETTEXTLENGTH and WM_GETETXT then put thet text and the new line back.
-
Read the entire file into a string, then use that. string will definitely handle enough to fit into an edit box (limited to 64K on Win9x)
-
with the resource editor how do you actually write in the code for it. All I see is the editor with the folder in it but I can't write or figure out how to write code in it.
-
Right-click on the top-level resource and go "Insert".
-
How do you adjust the size of the buffer depending on the size of the text file? thanks
Code:
char buffer[500];
while(in){
in.read(buffer,sizeof(buffer));
}
-
You can first retrieve the file size in bytes (move the file pointer to the end of the file and read its current position). See the FAQ for this:
Then you could do
Code:
char *buffer = new char[filelen];