现在的位置: 首页 > 综合 > 正文

wxWidgets中字符串操作例子

2014年01月14日 ⁄ 综合 ⁄ 共 610字 ⁄ 字号 评论关闭

在wxWidgets中,常见的字符串不能直接使用,而且照顾到跨平台的特性,所以字符串的处理通常是比较繁琐的,以下的代码均是工作中所所用到的片段。通过这样的方式可以将字符串进行格式化。并且由wxMessageBox弹出对话框,将字符串输出.
  wxString strImagePath;
  strImagePath.Printf(wxT("The picture adds to carry a mistake!!!")); 
  wxMessageBox(strImagePath,_([url]www.xxx.com[/url]));

 
还有一个方法是在声明wxSting时对构造函数进行初始化.并且将其赋值给另一个变量.
#ifndef PICTUREPROC_H_INCLUDED
#define PICTUREPROC_H_INCLUDED
const char defaultPicture[100]="img/pic/topmain.jpg";
const char rCallOpen0[100]="img/pic/rCallOpen0.jpg";
const char rCallOpen1[100]="img/pic/rCallOpen1.jpg";
#endif // PICTUREPROC_H_INCLUDED

wxString tempWxString(rCallOpen0,wxConvUTF8);
strImagePath = tempWxString;

抱歉!评论已关闭.