Results 1 to 9 of 9

Thread: MVC++ and resources

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    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

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    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

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    First retrieve the text using WM_GETTEXTLENGTH and WM_GETETXT then put thet text and the new line back.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  6. #6

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    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

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  8. #8

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    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

  9. #9
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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];
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width