CStdioFile emlfile;
emlfile.Open( "1212.eml",CFile::modeReadWrite|CFile::modeCreate);
emlfile.Write(smsg,smsg.GetLength());
emlfile.Close();
结果1212.eml文件用ultraedit打开的时候提示是否要转为dos格式,而且,所有的邮件浏览器都不能正常现实。后来把代码中的CFile就一切正常了,看来虽然CStdioFile是从CFile继承来的,但是Write()的调用方式也是重载过了的。
这一点从mfc源代码里面得到了证实, CStdioFile中的Open()调用的_fdopen(),而CFile的Open()调用的是::CreateFile,同样的,在Write中分别用的fwrite()和::WriteFile();
暂时就不追踪下去了,完成毕业设计要紧,等设计完了再看看底层代码吧!
Tags:
编程
IT技术
blog
沒有留言 »
CFont* pFont = new CFont();
pFont->CreateFont(60,0,0,0,550,0,0,0,ANSI_CHARSET,OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,0,3,NULL);
cwnd类有一个成员函数SetFont,所以直接调用就可以了。而且这只是修改一个控件的字体,不需要修改回来吧….
Tags:
hust
大学
生活
沒有留言 »
要修改VC模式对话框控件属性,必然,最重要的是弄清楚对话框上的控件在何时创建,要在保证创建之后才修改,在网上找到一些资料,提出了修改对话框类的构造函数的方法,但是经测试,不能完成。后来把
m_ListSet.AddString("属性");
放到对话框类的 OnInitDialog()函数中,响应WM_INITDIALOG消息,顺利执行!
具体原因等毕业设计做完之后去研究。
当DoModal被调用后,实际在幕后引起一系列如下的动作:
CDialog::DoModal->CEx06Dialog::OnInitDialog->其它的初始化->CDialog::OnInitDialog->CWnd::UpdateData(FALSE)->CEx06Dialog::DoDataExchange
用户输入数据…
用户单击OK按钮
CEx06Dialog::OnOk->…其它的确认处理…->CDialog::OnOk->CWnd::UpDateData(TURE)->CEx06Dialog::DoDataExchange->CDialog::EndDialog(IDOK)
说明:
1)virtual BOOL OnInitDialog( );
//CDialog::OnInitDialog This member function is called in response to the WM_INITDIALOG message. This message is sent to the dialog box during the Create, CreateIndirect, or DoModal calls, which occur immediately before the dialog box is displayed.
//Override this member function if you need to perform special processing when the dialog box is initialized.
2)BOOL UpdateData( BOOL bSaveAndValidate = TRUE );
//CWnd::UpdateData :Call this member function to initialize data in a dialog box, or to retrieve and validate dialog data.
//bSaveAndValidate:Flag that indicates whether dialog box is being initialized (FALSE) or data is being retrieved (TRUE).
//By default UpdateData(TRUE) is called in the default CDialog::OnOK handler and UpdateData(FALSE) is called in the default CDialog::OnInitDialog.
3)virtual void DoDataExchange( CDataExchange* pDX );
//CWnd::DoDataExchange Called by the framework to exchange and validate dialog data.
//Never call this function (DoDataExchange) directly. It is called by the UpdateData member function.
//Call UpdateData to initialize a dialog box’s controls or retrieve data from a dialog box.
4)void EndDialog( int nResult );
//CDialog::EndDialog makes the dialog box invisible but does not destroy it.
//Call this member function to terminate a modal dialog box. This member function returns nResu
Tags:
hust
2 Comments »
如果想做出高彩工具栏,只需以下几步:
1、在res目录下找到Toolbar.bmp,记下尺寸,比如128×31;
2、用同样大小做一幅24位色的高彩图片,存为CoolBar.bmp;
3、把此图片引入资源,命名为IDB_COOLBAR,会提示无法正确显示,不用管它;
4、在CMainFrm中添加成员变量CBitmap m_bmpToolbarHi,在CMainFrame::OnCreate()里
,在工作栏创建代码的后面加上下面两行:
m_bmpToolbarHi.LoadBitmap(IDB_COOLBAR);
m_wndToolBar.SetBitmap((HBITMAP)m_bmpToolbarHi);
5、在CMainFrm的析构函数中加上m_bmpToolbarHi.DeleteObject();
Tags:
编程
IT生活
软件
一个回复 »
在毕业设计中,发现,listview中每改变一次选择,OnItemchanged函数执行了,三次,后来查证之后发现,state不光是选择的变化,还包括了焦点,还有其它的的变化
第1次是iOldItem从LVIS_SELECTED到0(取消选择)
第2次是iOldItem从LVIS_FOCUSED到0(取消焦点)
第3次是iNewItem从0到LVIS_SELECTED | LVIS_FOCUSED(获得选择,同时获得焦点)
只在获得选择的时候执行,就需要这样
if( (pNMListView->uNewState & LVIS_SELECTED) &&
!(pNMListview->uOldState & LVIS_SELECTED) )
{
int nNewItem = pNMListView->iItem;
……
}
Tags:
hust
3 Comments »