文本文件在SDI中打开 [英] Text File Open in SDI

查看:80
本文介绍了文本文件在SDI中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!:)

热烈的问候!!!

我创建了一个SDI应用程序,用于在标记后显示文本文件。在创建SDI应用程序时,我将基类命名为CView。

我的需求在输出窗口中我必须单击File-> Open->xxx.txt并输出需要要显示。

文本文件包含以下数据

AB:C,D



代码我写的如下



Hello everyone :)
Warm Greetings !!!
I have created a SDI Application to display a text fle after tokenizing it. While creating SDI application i gave the base class as "CView" .
My requierement is in the output window i have to click File->Open->"xxx.txt" and the output needs to be displayed.
The text file contains following data
A-B:C,D

The code that i have written is as follows

void CFileView::OnFileOpen()
{
	// TODO: Add your command handler code here

	CString pathname,strLine; 
	CStdioFile File; 

	if(File.Open(pathname, CFile::modeRead)) // Open file to be read 
	{ 

		while(File.ReadString(strLine)) // Read file 
		{	
			int Position = 0; 
			CString Token; 

			Token = strLine.Tokenize(_T("-:,"), Position); 
			while(Token!="") 
				{ 
					_tprintf_s(_T("Token: %s\n"), Token); 
					Token = strLine.Tokenize(_T("-:,"), Position); 
				} 
		}
	}

}





但是在当我打开文件时没有得到任何东西的输出屏幕..请帮助



But in the output screen when i open a file im not getting anything .. Please Help

推荐答案

你正在使用 _tprintf_s 哪个将格式化的字符串打印到 stdout ,如上所述在MSDN上 [ ^ ]。您需要在文件读取代码中创建内部结构,数组或类似内容,它将以某些有用的顺序包含所有令牌。然后在 OnPaint 方法中,将该数据呈现到SDI客户端视图中,并根据您的要求进行制表。文章部分有很多样本可以告诉你如何操作。
You are using _tprintf_s which prints a formatted string to stdout, as described here on MSDN[^]. You need to create an internal structure, array or similar in the file reading code, which will contain all your tokens in some useful order. Then in your OnPaint method you render that data onto your SDI client view, tabulated according to your requirements. There are lots of samples in the articles section that should show you how to do it.


这篇关于文本文件在SDI中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆