By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,836 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

Displaying text file into a dialog

P: n/a
Hello,

I am using VS C++ to make a gui that displays a text file contents from
main dialog. So I created main dialog and another dialog for text file
viewer. From the main dialog, I call text file viewer
dialog(ViewDialog) when button is pressed.
I added edit control(called IDC_EDIT1) and its control
variable(my_edit). How do I display the text file contents in this?

In ViewDialog::ViewDialog, I get the contents of the text file

FILE *f=fopen(LOG_FILE,"rb");

fseek(f,0,SEEK_END);
int ltext=ftell(f);
fseek(f,0,SEEK_SET);

text = (char *)malloc(ltext+1);
fread(text,ltext,1,f);
fclose(f);
text[ltext]='\0';
And to display, I tried all four but it doesn't seem to work.

SetWindowText(text);
::SetWindowText(GetSafeHwnd(),text);
GetDlgItem(IDC_EDIT1)->SetWindowText(text);
m_edit.SetWindowText(text);

Thanks,

Seung

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
semi wrote:
I am using VS C++ to make a gui [...]


Please go to comp.os.ms-windows.programmer.win32. Here your
issues are off-topic. Another place is microsoft.public.vc.*

V
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.