problem gui and wchar_t*

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
full_newbie
Posts: 27
Joined: Mon Apr 05, 2010 7:33 am

Post by full_newbie »

This full code:

Code: Select all

#include <irrlicht.h>
#include <iostream>
#include <fstream>
#include <locale>
#include <string>
#include <stdio.h>
typedef int errno_t;

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
int main()
{

	IrrlichtDevice * device = createDevice(EDT_OPENGL, core::dimension2d<u32>(1024, 768),32,true);

	if (device == 0)
		return 1; 


	device->setWindowCaption(L"Irrlicht Engine - User Interface Demo");
	device->setResizable(true);

	video::IVideoDriver* driver = device->getVideoDriver();
	IGUIEnvironment* env = device->getGUIEnvironment();


	IGUISkin* skin = env->getSkin();
	IGUIFont* font = env->getFont("media/myfont.xml");
	if (font)
		skin->setFont(font);

	skin->setFont(env->getBuiltInFont(), EGDF_TOOLTIP);
//first variant
wchar_t* fileText = L"FAILED TO LOAD FROM FILE";
   FILE *f;
   f = _wfopen(L"test.dlg", L"rt,ccs=UNICODE");
   if (f)
   {
      wchar_t t[1000];
      fgetws(t, 1000, f);
      fclose(f);
      fileText = t;
   }
env->addStaticText(fileText, rect<s32>(200,200,400,250), true);
//second variant
locale::global(locale(""));
wifstream f("test.dlg", std::wifstream::in);
if (! f.is_open())
        throw 42;
wstring s1;
const wchar_t *load_string;
getline(f, s1);
load_string=s1.c_str();
load_string=(wchar_t*)load_string;
env->addStaticText(load_string, rect<s32>(200,200,400,250), true);
	return 0;
}
This arhiv for font and text file:
http://best-scripts.uz/Release.zip
Image
Please help!!!!
Sorry, my english is very bad. | I use minGW+CodeBlocks+Irrlicht 1.7.1(1.6,1.5)
full_newbie
Posts: 27
Joined: Mon Apr 05, 2010 7:33 am

Post by full_newbie »

Special sank's greenya for help me.
Theme closed
Sorry, my english is very bad. | I use minGW+CodeBlocks+Irrlicht 1.7.1(1.6,1.5)
Post Reply