Sorry for all the ?'s, but now I have a problem saving info in an EDITBOX.

This is a discussion on Sorry for all the ?'s, but now I have a problem saving info in an EDITBOX. within the Windows Programming forums, part of the Platform Specific Boards category; When I have the button clicked, how do I get the entered text from each EDITBOX I have and save ...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Sorry for all the ?'s, but now I have a problem saving info in an EDITBOX.

    When I have the button clicked, how do I get the entered text from each EDITBOX I have and save it to a file?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Try using either

    Code:
    char mytext[100];
    FILE *fptr;
    
    fptr = fopen("c:\\somefile.txt", "w");
    GetWindowText(hwnd, mytext, 99);
    fprintf(fptr,mytext);
    fclose(fptr);
    or....

    Code:
    char mytext[100];
    FILE *fptr;
    
    fptr = fopen("c:\\somefile.txt", "w");
    GetDlgItemText(hdlg, ID_EDIT1, mytext, 99);
    fprintf(fptr,mytext);
    fclose(fptr);
    try one or the other.

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question One lil problem

    I tried:

    FILE *theSave, but I got:

    229 book15.cpp
    'FILE' undeclared (first use this function)
    'theSave' undeclared (first use this function)
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Did you #include <stdio.h> ?

  5. #5
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Nevermind, I got it but..

    What do I do? I got it to save but in the file, it doesn't show my variables for the GetWindowText.
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  6. #6
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    try

    fprintf(fptr,"%s",mytext);

  7. #7
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question I have many

    I have many variables. How would I put them all in?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  8. #8
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    What're you talkin about? you mean you need to save from a buncha edit boxes?

  9. #9
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Well..

    Yes. Can I do it?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  10. #10
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    where there's a will, there's a way. Just create a new string for each editbox, plus a cumulative one. Sorta like this...

    char text1[100], text2[100], text3[100], cumulative[300];

    /*call GetWindow/DlgItemText() for each string (except cumulative)*/

    then go

    sprintf(cumulative,"%s%s%s",text1,text2,text3);

    THEN

    fprintf(fprt,"%s",cumulative);
    fclose(fptr);

    there ya go
    Last edited by -KEN-; 10-16-2001 at 08:09 PM.

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Try using CreateFile() ect instead of fopen().

    You are using WIN32 API, not the old C. Why mix them up?

    IF you are using C not C++ or MFC.

    Try in the callback

    Code:
    case IDC_MYEDIT:
    if (EN_CHANGE ==HIWORD(wParam))
    GetDlgItemText(hwnd,IDC_MYEDIT,sBuffer,64);
    break;
    When the dialog closes or user clicks on the SAVE control ect, check that all the edit buffers have valid data and then assemble into a file using WriteFile()

    PS Your 14 and taken? By what Gypsies, Sharks, Flights of Fancy?
    Last edited by novacain; 10-17-2001 at 02:35 AM.

  12. #12
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post LoL

    %d 14 and taken means I have a girlfriend..LoL %d
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about getting an info class from another Form
    By Joelito in forum C# Programming
    Replies: 0
    Last Post: 10-16-2006, 02:02 PM
  2. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 03:12 PM
  3. Saving vectors of structures problem
    By redeck in forum C++ Programming
    Replies: 4
    Last Post: 12-09-2004, 04:47 PM
  4. Binary trees search problem...
    By Umoniel in forum C Programming
    Replies: 2
    Last Post: 02-22-2004, 02:29 PM
  5. hi! saving a struct..., kewl! but need more info...,
    By mickey in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2002, 03:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21