Click here to Skip to main content
15,878,871 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
now, i meet a big question with MFC

i wanna show a message at edit box, but only can show three message

, now , i want to show 256 word at editbox...

how can i do ... please help me


this is my code
C++
void Cnew_test_06_04Dlg::OnBnClickedBt()
{

CString szFilter = L"*.exe|*.*||";
CFileDialog fd(TRUE,L"*", L"*.exe", OFN_HIDEREADONLY, szFilter, this);

if(fd.DoModal() == IDOK)
{
    CString szFileName = fd.GetPathName();//取得開啟檔案全名(包含路徑)
    // fopen(szFileName);
    
    CFile File;
    char *buf;
    buf = new char [256];
    DWORD dwFileLen=0;
    
    if (File.Open(szFileName,CFile::modeRead |CFile::typeBinary)){
    	File.SeekToBegin();
    	File.Read(buf, 256);
    }
    
    CString csOutput;
    while(csOutput.Format !=NULL)
    {
    	IDC_EDIT1.AddString(IDC_EDIT1.GetItemText(IDC_EDIT1));
    	buf=IDC_EDIT.GetNext();
    }
    //csOutput.Format(L"0x%02x 0x%02x 0x%02x", buf[0], buf[1],buf[2]);
    // int buf=0
    // int i=0
    //GetDlgItem(IDC_EDIT1)->SetWindowText(csOutput);
    
    delete [] buf;
}
Posted
v2
Comments
[no name] 5-Jun-14 4:09am    
"i wanna show a message at edit box, but only can show three message "
What does that mean?
Member 10865412 5-Jun-14 5:25am    
it's mean.. i want to show this view

ex :

00 00 00 00 00 00 00 00
aa aa aa aa aa aa aa aa
bb bb bb bb bb bb bb bb

but now, i only can show

00 00 00

, so ,can you help me to write this code?,,please ... i'was crazy with this question ...
Member 10865412 5-Jun-14 5:28am    
CString csOutput;

csOutput.Format(L"0x%02x 0x%02x 0x%02x 0x%02x", buf[0], buf[1],buf[2],buf[3]);
GetDlgItem(IDC_EDIT1)->SetWindowText(csOutput);

delete [] buf;

}
Mohibur Rashid 5-Jun-14 4:36am    
Lots of thing is wrong with your code. IDC_EDIT1 seems like an macro constant. but you are using it like a object. Besides your question is very much unclear
Member 10865412 5-Jun-14 5:27am    
but i was debug, it's correct, the code can run ...


if (File.Open(szFileName,CFile::modeRead |CFile::typeBinary)){
File.SeekToBegin();
File.Read(buf, 256);
}

CString csOutput;

csOutput.Format(L"0x%02x 0x%02x 0x%02x 0x%02x", buf[0], buf[1],buf[2],buf[3]);
// int buf=0
// int i=0
GetDlgItem(IDC_EDIT1)->SetWindowText(csOutput);

delete [] buf;

}

you need to change the size of the edit box in the resource editor.

the string issue is solved bei Mohibur Rsahid.
 
Share this answer
 
<pre lang="c++">CString csOutput;
		
		
		//csOutput.Format(L"0x%02x 0x%02x 0x%02x 0x%02x", buf[0], buf[1],buf[2],buf[3]);
		//GetDlgItem(IDC_EDIT1)->SetWindowText(csOutput);
        buffcount=File.Read(buf, 256);
  
        for(int i=0;i<buffcount;i++)>
		{
			cstring temp; temp.format(L"0x%02x",buf[i]); csoutput+=temp;
		}
		delete [] buf;

	}
 
Share this answer
 
Comments
Mohibur Rashid 5-Jun-14 23:23pm    
aren't you getting what you want?
Member 10865412 6-Jun-14 0:12am    
no,,, not yet

i don't know how can i do ...

debug always error .........

can u give me others reply..? please help me >"<

i can send my code for you with email..

this is mine . ( dangerlover9403@gmail.com )

can you send a mail for me first ?
let i will send back soon >"<
thank you for your reply
Mohibur Rashid 6-Jun-14 1:05am    
I am not going to email you. No one else is going to. Describe your problem properly please. Then we might be able to answer
Member 10865412 6-Jun-14 1:59am    
mm...my question like before , i am really don't know how to write this code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900