|
-
Jun 8th, 2001, 03:57 PM
#1
Thread Starter
Hyperactive Member
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
Last edited by MPrestonf12; Jun 8th, 2001 at 05:35 PM.
Matt 
-
Jun 8th, 2001, 06:46 PM
#2
Monday Morning Lunatic
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)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 8th, 2001, 07:21 PM
#3
Thread Starter
Hyperactive Member
ok, im getting the text into the box, but it keeps deleting what its written and replaces it with the next line.
Last edited by MPrestonf12; Jun 8th, 2001 at 07:47 PM.
Matt 
-
Jun 9th, 2001, 05:21 AM
#4
Frenzied Member
First retrieve the text using WM_GETTEXTLENGTH and WM_GETETXT then put thet text and the new line back.
-
Jun 9th, 2001, 06:09 AM
#5
Monday Morning Lunatic
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)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 9th, 2001, 05:52 PM
#6
Thread Starter
Hyperactive Member
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.
Matt 
-
Jun 9th, 2001, 06:01 PM
#7
Monday Morning Lunatic
Right-click on the top-level resource and go "Insert".
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 9th, 2001, 08:10 PM
#8
Thread Starter
Hyperactive Member
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));
}
Matt 
-
Jun 10th, 2001, 04:19 AM
#9
Frenzied Member
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];
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|