Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

hitan problem sa MFC

[es] :: C/C++ programiranje :: hitan problem sa MFC

[ Pregleda: 2641 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

bjtetf

Član broj: 77307
Poruke: 117
*.dlp390.bih.net.ba.



+1 Profil

icon hitan problem sa MFC09.01.2006. u 14:43 - pre 222 meseci
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.
 
Odgovor na temu

itf
Zagreb

Član broj: 59794
Poruke: 993
*.fsb.hr.



+9 Profil

icon Re: hitan problem sa MFC09.01.2006. u 14:51 - pre 222 meseci
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);


 
Odgovor na temu

bjtetf

Član broj: 77307
Poruke: 117
*.dlp423.bih.net.ba.



+1 Profil

icon Re: hitan problem sa MFC09.01.2006. u 16:17 - pre 222 meseci
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
 
Odgovor na temu

bjtetf

Član broj: 77307
Poruke: 117
*.dlp11.bih.net.ba.



+1 Profil

icon Re: hitan problem sa MFC09.01.2006. u 18:22 - pre 222 meseci
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.
 
Odgovor na temu

bjtetf

Član broj: 77307
Poruke: 117
*.dlp237.bih.net.ba.



+1 Profil

icon Re: hitan problem sa MFC10.01.2006. u 09:12 - pre 222 meseci
Problem sam rijesio :)
 
Odgovor na temu

[es] :: C/C++ programiranje :: hitan problem sa MFC

[ Pregleda: 2641 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.