Beruflich Dokumente
Kultur Dokumente
Application to Unicode
Harley Rosnow
Software Development Lead
Microsoft Corporation
2000 Microsoft Corporation.
Table of Contents
Assumptions and Terminology
Two-Executable Model
FrontPage 10 Objectives
Microsoft Foundation Classes
FrontPage 10 Strategy
Unicode Strings
FrontPage 2000 User Interface
FrontPage 10 User Interface
Achieving a Mixed Unicode
and ANSI Execution
Environment with MFC
Some terms:
ANSI (A) used for code that stores and manipulates data using
code pages
Wide (W) used for code and APIs that support Unicode data
UI user interface the appearance and implementation of all
windows and user interactions
ACP active code page the default system code page used to
store most data on Windows 9x including file names. Retained on
Windows NT for ANSI application compatibility
FrontPage 10 the official name of this release has not yet been
determined, so were using this name since this version of
FrontPage ships with the 10th release of Microsoft Office.
Two-Executable Model
Established by the operating systems group at
Microsoft and basis for Microsoft development tools.
Use UNICODE define to create a Unicode version of
your software.
Unicode version fully functional only on Windows
NT/2000.
ANSI version fully functional on both Windows 9x
and NT/2000, but cannot manipulate Unicode data.
UNICODE define controls the APIs called
(SendMessageW vs SendMessageA), data structure
definitions and the representation of strings (help
vs Lhelp).
FrontPage 10 Objectives
A single World-Wide Office executable:
Fully functional on both Windows 9x and Windows
NT/2000
Manipulate Unicode data internally
Takes advantage of OS capabilities:
Typing, displaying of Unicode characters and storing of
Unicode file names on Windows NT/2000
Displaying Unicode surrogate characters on Windows 2000
Typing and display of multiple codepage data on Windows 9x
Convert to ANSI code pages as required by Windows 9x on
the periphery
FrontPage 10 Strategy
Create an execution environment with a
mixture of ANSI and Unicode data,
messages and windows
Leave MFC as ANSI and dynamically link to mfc42.dll
Override the MFC classes to use Unicode data
Implement our own alternative classes where required
Take advantage of Unicode facilities supporting all
Windows platforms
Write our own code to support Unicode on Win9x
Convert data to the active code page as a last resort
Unicode Strings
Abandoned MFCs CString.
Implemented a new Unicode string class,
CWString:
Method compatible with CString, but with Unicode
arguments and return values.
Use the ANSI-standard Unicode C/C++ runtime library
routines instead of the Win32 versions.
Use MSO routines supporting all Windows platforms.
Implemented custom resource loading, formatting
routines, etc. which retains Unicode data on Windows 9x.
Redefined all Unicode routines that dont support
Windows 9x, so code using them wont compile.
Common Controls:
Trees, Lists, StatusBar,
ToolTips
MFC
FrontPage
Custom
Views
Common Controls:
Trees, Lists, StatusBar,
ToolTips,
CTreeCtrl,
CListCtrl,
CTreeCtrlW, CListCtrlW,
FrontPage
Custom
Views
MFC
MSO
SendMessage() Conversions
FROM UNICODE
MultiBytetoWideChar()
TO UNICODE
SETTEXTW stw;
WNDPROC from
RegisterClassExW()
SendMessageW(&stw)
Or SetWindowLongW()
FROM ANSI
TO ANSI
SETTEXTA sta;
WNDPROC from
RegisterClassExA()
SendMessageA(&sta)
WideChartoMultiByte()
Or SetWindowLongA()
CallWindowProc() Conversions
FROM UNICODE
MultiBytetoWideChar()
TO UNICODE
Convert from ANSI if
OldWndProc is a handle.
Dont convert if pointer.
CallWindowProcW
(OldWndProc, hWnd,
Msg, wParam, lParam)
FROM ANSI
TO ANSI
CallWindowProcA
(OldWndProc, hWnd,
Msg, wParam, lParam)
WideChartoMultiByte()
(C++ Inheritance)
DispatchMessageA/W
MFC WNDPROC
3
Always Executed
If Prior Step
Doesnt Handle
CallWindowProcA/W
(Original WNDPROC)
2000 Microsoft Cor
5
(C++ Inheritance)
DispatchMessageW
MFC WNDPROC
3
Always Executed
If Prior Step
Doesnt Handle
Original WNDPROC as
function not handle
Override DefWindowProc to
use CallWindowProcW()
IsDialogMessageA() &
WM_CHAR
Resubclass as Unicode
WNDPROC
CallWindowProcA/W
(Original WNDPROC)
2000 Microsoft Cor
5
Futures
Applications somewhat lead
development tools and system
support
Cross-code page Plug UI
Full Unicode file name and URL
support
Resources:
Reference for international development:
http://www.microsoft.com/globaldev.
Design a Single Unicode App that Runs on Both Windows 98 and
Windows 2000, F. Avery Bishop,
http://www.microsoft.com/globaldev/articles/singleunicode.asp, April
1999.
MFC Internals: Inside the Microsoft Foundation Class Architecture, George
Shepherd and Scott Wingo, Addison-Wesley Developers Press, 1996.
Programming Windows with MFC, Second Edition, Jeff Prosise, Microsoft
Press, 1999.
Developing International Software for Windows 95 and Windows NT,
Nadine Kano, Microsoft Press, 1995.