[ bjtetf @ 09.01.2006. 14:43 ] @
imam sljedeci problem:
imam dugme,text box.
Kako sa napravim u visual C++ ( MFC ) da kada kliknem na dugme,text iz text_boxa
posalje u neki tekstualni file.
[ itf @ 09.01.2006. 14:51 ] @
Probaj ovako:

Tekst box-u dodijeli neku varijablu, a zatim da dohvatis tekst iz tog tekst box-a mozes napraviti ovo:

Code:
TextBox1.GetWindowText(Pom); // sprema tekst u znakovno polje Pom


Sada kada je to u varijabli Pom, nju onda zapises u datoteku:

Code:
FILE* f;

if((f = fopen("NekaDat.txt", "w"))==NULL){
   MessageBox("Datoteka se ne moze otvoriti!", "Greska", 0);
   return;
}

fprintf(f, "%s", Pom);
fclose(f);


[ bjtetf @ 09.01.2006. 16:17 ] @
Slicno sam i ja radio,ali =>
pri ovom kodu:
char pom;
m_strMessage.GetWindowsText(pom);
FILE* f;

if((f = fopen("proba.txt", "w"))==NULL)
{
MessageBox("Datoteka se ne moze otvoriti!", "Greska", 0);
return;
}
fprintf(f, "%s", pom);
fclose(f);

m_strMessage je varijabla za Edit box(tipa string),dobijam ovu gresku:

'GetWindowsText' : is not a member of 'CString'.

i naravno ne radi
[ bjtetf @ 09.01.2006. 18:22 ] @
itf,rijesio sam problem koji sam te pitao =>

CEdit* ed1 = (CEdit*) GetDlgItem(IDC_MSG);
CString strText;
ed1->GetWindowText(strText);

FILE* f;

if((f = fopen("C:/proba.txt", "w"))==NULL)
{
MessageBox("Datoteka se ne moze otvoriti!", "Greska", 0);
return;
}
fprintf(f,"%s", m_strAdresa1);
fprintf(f,"\n");
fprintf(f,"%s",strText);
fclose(f);

Ali imam sada drugi problem: U fajl sam zapisao jednu ip adresu,a u novom redu odredjeni text i zasto onda ne radi ovaj kod:

FILE* f;
char buffer1[19],buffer2[19];
int i,ch1,ch2;

if((f=fopen("C:/proba.txt","r"))==NULL)
{
MessageBox("Datoteka se ne moze otvoriti!", "Greska", 0);
return;
}

/* Read in first 19 characters and place them in "buffer": */
ch1 = fgetc( f );
for( i=0; (i < 18 ) && ( feof( f ) == 0 ); i++ )
{
buffer1 = (char)ch1;
ch1 = fgetc( f );
}
/* Add null to end string */
buffer1 = '\0';
// MessageBox(buffer1);
ch2=fgetc( f );
for( i=0; (i < 18 ) && ( feof( f ) == 0 ); i++ )
{
buffer2 = (char)ch2;
ch2 = fgetc( f );
}

/* Add null to end string */
buffer2= '\0';

if(buffer1=="81 . 98 . 145 . 9")
// ovo je taj broj u fajlu
{
MessageBox(buffer2);
}
else
{
MessageBox("Nema novih poruka");
}

fclose( f );

tj.ja hocu da ako je ista ip adresa u kodu i u fajlu da on meni prikaze tekstualni dio u fajlu.
[ bjtetf @ 10.01.2006. 09:12 ] @
Problem sam rijesio :)