Anyone used unicode headers?

Windows specific questions.
Post Reply
VirusScanner
Posts: 775
Joined: Jul 01, 2005 18:45

Anyone used unicode headers?

Post by VirusScanner »

I'm trying to make a unicode program using the windows API. So at the top I have:

Code: Select all

#define UNICODE
#define DEBUG
#include "windows.bi"
option byval
option explicit
option escape
option base 0
and a bit further down, I have

Code: Select all

with wcl
	.style = CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS
	.lpfnWndProc = @FrameProc
	.cbClsExtra = 0
	.cbWndExtra = 0
	.hInstance = GetModuleHandle(null)
	.hIcon = LoadIcon(null, IDI_APPLICATION)
	.hCursor = 0'LoadCursor(null, IDC_ARROW)
	.hbrBackground = GetStockObject(WHITE_BRUSH)
	.lpszMenuName = null
	.lpszClassName = @wsClassName
end with
The part causing an error is the line
.hIcon = LoadIcon(null, IDI_APPLICATION). I get error 1: argument count mismatch, found: ')'. I've tried many different variations and none seem to work. The next line also will cause an error if the LoadCursor call is uncommented.

It works fine in the hello.bas (non-unicode) example, so I don't think there's a problem with my headers (the ones that came with the .15b download) unless something's wrong with the LPCWSTR type. It works if I change IDI_APPLICATION to wstr("") but that's not what I want to do.
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

Strange, i couldn't reproduce the error, i tried using the unicode version in both hello.bas and the D3D 9.x example, both worked - the only change was that the windows class name had to be converted with wstr().

Any full example that doesn't work there?
Aquarius
Posts: 88
Joined: Jun 27, 2005 19:08

Post by Aquarius »

AFAIK some editors use Byte Order Mark on the beginning of the file encoded in UTF and some other not. Maybe it's the problem... just a shot.
VirusScanner
Posts: 775
Joined: Jul 01, 2005 18:45

Post by VirusScanner »

I'm using SciTE, and compiling with fbc main.bas

This is the code that I'm trying to get to work before I go on

Code: Select all

#define UNICODE
#define DEBUG
#include "windows.bi"
option byval
option explicit
option escape
option base 0

declare function FrameProc(hwnd as HWND, msg as UINT, wParam as WPARAM, lParam as LPARAM) as LRESULT

dim msg as MSG
dim wcl as WNDCLASS
dim hwnd as HWND
dim as wstring ptr wsClassName => @wstr("FrameWND")

with wcl
	.style = CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS
	.lpfnWndProc = @FrameProc
	.cbClsExtra = 0
	.cbWndExtra = 0
	.hInstance = GetModuleHandle(null)
	'Fix the following two:
	.hIcon = LoadIcon(null, IDI_APPLICATION)
	.hCursor = 0'LoadCursor(null, IDC_ARROW)
	.hbrBackground = GetStockObject(WHITE_BRUSH)
	.lpszMenuName = null
	.lpszClassName = wsClassName
end with

if (RegisterClass(@wcl) = false) then
	end
end if

hwnd = CreateWindowEx(0, *wsClassName, wstr("Test App"), WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, null, null, GetModuleHandle(null), null)

ShowWindow(hwnd, SW_NORMAL)
UpdateWindow(hwnd)

while (GetMessage(@msg, null, 0, 0) <> false)
	TranslateMessage(@msg)
	DispatchMessage(@msg)
wend

end msg.wParam

'''''''''''''''''''''''

function FrameProc(hwnd as HWND, msg as UINT, wParam as WPARAM, lParam as LPARAM) as LRESULT
	select case msg
	case WM_CREATE
		return 0
	case WM_DESTROY
		PostQuitMessage(0)
		return 0
	end select
	
	return DefWindowProc(hwnd, msg, wParam, lParam)
end function
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

I see what you mean, the source file itself is unicode too, i was testing using an ascii one.

There was a small bug in the rtlib when assigning wstring's to ascii ones (used internally by the compiler to handle macros defined in ascii header files but used in unicode sources), the fixes are in the CVS repository, it may take up to 5 hours to SF.net update the anonymous access though.

Both rtlib and compiler must be rebuilt.

A regression test was added too.
VirusScanner
Posts: 775
Joined: Jul 01, 2005 18:45

Post by VirusScanner »

Wow, thanks for the quick response and fix! I'll download MinGW and rebuild them later today.
Post Reply