Exemplo n.º 1
0
        String Win32Window::GetTitle()
        {
            int l = GetWindowTextLengthW(hWnd);
            if (l == 0) return String();

            Utf16String titleW = Utf16String::Create(l);
            l = GetWindowText(hWnd, titleW.Ptr(), l);

            return Unicode::Utf16To8(titleW);
        }
Exemplo n.º 2
0
    File::File(const String& filename, FileMode mode)
    {
        const char* m = "rb";
        
        switch (mode)
        {
            case FileModeRead: m = "rb"; break;
            case FileModeWrite: m = "wb"; break;
            case FileModeAppend: m = "ab"; break;
            case FileModeReadWrite: m = "r+b"; break;
            case FileModeReadWriteNew: m = "w+b"; break;
            case FileModeReadAppend: m = "a+b"; break;
            default: XLI_THROW("Invalid file mode: " + FileModeInfo::ToString(mode));
        }
        
#ifdef XLI_COMPILER_MSVC
        
        fp = 0;
        
        Utf16String filenameW = Unicode::Utf8To16(filename);
        Utf16String mW = Unicode::Utf8To16(m);
        
        if (_wfopen_s(&fp, filenameW.Ptr(), mW.Ptr()) != 0)
            XLI_THROW_CANT_OPEN_FILE(filename);

#else
        
        fp = fopen(filename.Ptr(), m);
        if (!fp) XLI_THROW_CANT_OPEN_FILE(filename);

#endif

        this->flags = FileFlagsCanClose | FileFlagsCanSeek;
        
        if (mode & FileModeRead)
            this->flags |= FileFlagsCanRead;

        if ((mode & FileModeWrite) || (mode & FileModeAppend))
            this->flags |= FileFlagsCanWrite;
    }
Exemplo n.º 3
0
        Win32Window::Win32Window(int width, int height, const Xli::String& title, int flags)
        {
            this->ownsHwnd = true;
            this->closed = false;
            this->fullscreen = false;
            this->eventHandler = eventHandler;

            if (flags & WindowFlagsFullscreen)
            {
                flags &= ~WindowFlagsFullscreen;
                fullscreen = true;
            }

            rect.top = 0;
            rect.left = 0;
            rect.bottom = height;
            rect.right = width;

            dwStyle = StyleFromXliWindowFlags(flags);
            AdjustWindowRect(&rect, dwStyle, 0);

            Utf16String titleW = Unicode::Utf8To16(title);
            hWnd = CreateWindowW(WindowClassName, titleW.Ptr(), dwStyle, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, 0, 0, HInstance, 0);

            if (!hWnd)
                XLI_THROW("Failed to create window: " + Win32::GetLastErrorString());

            if (!MainWindow)
                MainWindow = this;

            SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));

            ShowWindow(hWnd, SW_NORMAL);
            SetForegroundWindow(hWnd);
            SetFocus(hWnd);

            if (fullscreen)
            {
                fullscreen = false;
                SetFullscreen(true);
            }
        }
Exemplo n.º 4
0
 void Win32Window::SetTitle(const String& title)
 {
     Utf16String titleW = Unicode::Utf8To16(title);
     SetWindowTextW(hWnd, titleW.Ptr());
 }