Did i miss something? The corresponding code (of course with adapted types for variables) for PowerBASIC works as expected - with and without UNICODE defined.
Code: Select all
'#compiler freebasic
'#Define UNICODE
#include once "windows.bi"
declare function FB_MAIN as uinteger
declare FUNCTION WindowProc (BYVAL hWnd AS HWND, BYVAL wMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
END FB_MAIN
'***********************************************************************************************
'***********************************************************************************************
FUNCTION FB_MAIN AS uinteger
'***********************************************************************************************
' Main Program entry point
'***********************************************************************************************
dim uMsg AS TAGMSG
dim hinst AS hinstance
dim wce AS WNDCLASSEX
#ifdef unicode
dim szClassName AS wSTRing * 64
dim szCaption AS wstring * 64
#else
dim szClassName AS zSTRing * 64
dim szCaption AS zstring * 64
#endif
dim hMenu AS hmenu
dim hwnd AS hwnd
dim wstyle AS DWORD
dim xstyle AS DWORD
hinst = GetModuleHandle(byval 0)
szClassName = "NEWTEST"
wce.cbSize = SIZEOF(wce)
wce.STYLE = CS_HREDRAW OR CS_VREDRAW 'or CS_DBLCLKS
wce.lpfnWndProc = procptr(WindowProc)
wce.hInstance = hInst
wce.hCursor = LoadCursor(NULL, BYVAL IDC_ARROW)
wce.hbrBackground = GetSyscolorbrush(COLOR_3DFACE)
wce.lpszClassName = strptr(szClassName)
wce.hIcon = LoadIcon(0, BYVAL IDI_APPLICATION)
wce.hIconSm = LoadIcon(0, BYVAL IDI_APPLICATION)
RegisterClassEx(@wce)
szCaption = " New Window"
wstyle = WS_POPUP OR WS_BORDER OR WS_DLGFRAME OR WS_THICKFRAME OR WS_SYSMENU OR WS_MAXIMIZEBOX OR WS_CLIPSIBLINGS OR WS_CLIPCHILDREN OR WS_VISIBLE OR WS_CAPTION
xstyle = WS_EX_WINDOWEDGE OR WS_EX_LEFT OR WS_EX_LTRREADING OR WS_EX_RIGHTSCROLLBAR
hwnd = CreateWindowEx(xstyle, szClassName, szCaption, wstyle, 100, 100, 200, 100, byval 0, byval 0, hinst, byval 0)
if hwnd = 0 then
dim szh AS zstring * 1024
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM OR FORMAT_MESSAGE_IGNORE_INSERTS, _
BYVAL NULL, getlasterror, 0, @szh, 1023, BYVAL NULL )
messageboxA(0, szh, "Error", MB_OK)
exit function
end if
ShowWindow hwnd, SW_SHOWDEFAULT 'show main window
UpdateWindow hwnd 'draw main window
DO WHILE GetMessage(@uMsg, BYVAL NULL, 0, 0) 'message loop
IF IsDialogMessage(hwnd, @uMsg) = 0 THEN 'dialog processing
TranslateMessage @uMsg
DispatchMessage @uMsg
END IF
LOOP
FUNCTION = uMsg.wParam
END FUNCTION
'***********************************************************************************************
FUNCTION WindowProc (BYVAL hWnd AS HWND, BYVAL wMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
'***********************************************************************************************
' Main window procedure
'***********************************************************************************************
SELECT CASE wMsg
CASE WM_CREATE 'creation of the main window
FUNCTION = 0 'success
EXIT FUNCTION
CASE WM_DESTROY
PostQuitMessage 0 'exit message loop in MAIN
EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam) 'default processing
END FUNCTION
'***********************************************************************************************
'***********************************************************************************************
'***********************************************************************************************
Any help appreciated - thanks
JK