ImageVerifierCode 换一换
格式:PPT , 页数:24 ,大小:266KB ,
资源ID:379357      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
注意:如需开发票,请勿充值!
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-379357.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Case Study- Porting an MFC Application to Unicode.ppt)为本站会员(registerpick115)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

Case Study- Porting an MFC Application to Unicode.ppt

1、 2000 Microsoft Corporation.,Case Study: Porting an MFC 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

2、10 Strategy Unicode Strings FrontPage 2000 User Interface FrontPage 10 User Interface Achieving a Mixed Unicode and ANSI Execution Environment with MFC Unicode and ANSI windows and messages described,How do messages travel to a window in MFC? How can we allow Unicode messages to survive ANSI MFC? Co

3、nclusions and Relevance Futures Contributors, References and Contact Info Q & A, 2000 Microsoft Corporation.,Assumptions and Terminology,A familiarity with technical topics: C+ programming Windows programming MFC programming Some terms: ANSI (A) used for code that stores and manipulates data using c

4、ode 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 a

5、pplication 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., 2000 Microsoft Corporation.,Two-Executable Model,Established by the operating systems group a

6、t 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

7、the APIs called (SendMessageW vs SendMessageA), data structure definitions and the representation of strings (“help” vs L”help”)., 2000 Microsoft Corporation.,FrontPage 10 Objectives,A single World-Wide Office executable: Fully functional on both Windows 9x and Windows NT/2000 Manipulate Unicode dat

8、a 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

9、Windows 9x on the periphery Dont abandon MFC; dont rewrite app, 2000 Microsoft Corporation.,Microsoft Foundation Classes (MFC),Object oriented programming model on top of the native OS windowing architecture Set of C+ classes wrapping Win32 APIs Follows the two-executable model: mfc42.dll and mfc42u

10、.dll. Two application compilations: All classes (CString, CWnd, etc.) either store, pass and manipulate Unicode data or ANSI code page data. Very flexible allows the application developer to override and specialize almost all behaviors., 2000 Microsoft Corporation.,FrontPage 10 Strategy,Create an ex

11、ecution 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 platform

12、s Write our own code to support Unicode on Win9x Convert data to the active code page as a last resort, 2000 Microsoft Corporation.,Unicode Strings,Abandoned MFCs CString. Implemented a new Unicode string class, CWString: Method compatible with CString, but with Unicode arguments and return values.

13、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 Wind

14、ows 9x, so code using them wont compile., 2000 Microsoft Corporation.,FrontPage 2000 User Interface,Custom Views,Common Controls: Trees, Lists, StatusBar, ToolTips,System Controls: Edit, ListBox, ComboBox, 2000 Microsoft Corporation.,FrontPage 10 User Interface,Custom Views,Common Controls: Trees, L

15、ists, StatusBar, ToolTips, ,RichEdit 4.0: RichEd20W, ListBox, ComboBox,MFC,CEditW, CListBoxW, CComboBoxW,CEdit, CListBox, CComboBox,CTreeCtrl, CListCtrl, ,CTreeCtrlW, CListCtrlW, ,MSO, 2000 Microsoft Corporation.,Unicode and ANSI Windows and Messages,How does a mixed Unicode and ANSI environment wor

16、k on Windows NT/2000? What is a Unicode or ANSI window? How do we make a Unicode or ANSI window? What behavior changes between a Unicode and ANSI window? What if a window is subclassed?, 2000 Microsoft Corporation.,Whats a Unicode or ANSI window?,Windows NT/2000 implements the interoperation of ANSI

17、 and Unicode windows Each window has a window procedure (WNDPROC) that the OS invokes when the window receives a message The OS remembers if each WNDPROC handles Unicode or ANSI messages A window with a WNDPROC that handles Unicode is a “Unicode window” and IsUnicodeWindow() will return TRUE. If its

18、 WNDPROC handles ANSI messages, the window is an ANSI window Unicode windows and WNDPROCs only exist on Windows NT/2000., 2000 Microsoft Corporation.,How do we make a Unicode or ANSI window?,To create a window, call CreateWindowEx() and pass a window class name. The window class determines the windo

19、ws initial WNDPROC If the window class was originally registered using RegisterClassExW(), the OS remembers to pass the WINPROC Unicode messages; RegisterClassExA(), ANSI messages CreateWindowExA() vs CreateWindowExW() just determines if the arguments and ANSI or Unicode strings, 2000 Microsoft Corp

20、oration.,What changes between a Unicode and ANSI window?,When the OS invokes a Unicode windows WNDPROC, it will ensure that all OS messages are Unicode. If an ANSI message is sent, then the OS will perform a conversion on the input parameters before passing them to the Unicode WNDPROC. Output parame

21、ters are converted prior to returning from the SendMessage call. The opposite behavior occurs for an ANSI window., 2000 Microsoft Corporation.,Which messages are converted?,This conversion only takes place for OS messages: Windows Messages: WM_* like WM_CHAR, WM_SETTEXT, WM_GETTEXT, IME Messages: WM

22、_IME_* like WM_IME_CHAR, WM_IME_CONVERSION ListBox and ComboBox Messages: LB_* like LB_ADDSTRING, The conversion only affects text and characters This conversion has no affect on user messages, RichEdit messages (EM_*), Common Control messages and all other types of messages, 2000 Microsoft Corporat

23、ion.,SendMessage() Conversions,SETTEXTW stw; SendMessageW(&stw),MultiBytetoWideChar(),WideChartoMultiByte(),SETTEXTA sta; SendMessageA(&sta),Only known system messages are converted: WM_CHAR, WM_SETTEXT, WM_GETTEXT, CB_ADDSTRING, etc.,FROM UNICODE,TO UNICODE,FROM ANSI,TO ANSI,WNDPROC from RegisterCl

24、assExW() Or SetWindowLongW(),WNDPROC from RegisterClassExA() Or SetWindowLongA(), 2000 Microsoft Corporation.,What if a window is subclassed?,Subclass a window by associating a new WNDPROC using OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, NewWndProc); where NewWndProc and OldWndProc are function p

25、ointers of type WNDPROC. If SetWindowLongW() is called, the OS remembers the WNDPROC is Unicode; SetWindowLongA(), ANSI. Its the responsibility of the new WNDPROC to forward messages to the previous WNDPROC, if it doesnt handle the message itself., 2000 Microsoft Corporation.,What if a window is sub

26、classed? (contd),If the OldWndProc and NewWndProc match as either Unicode or ANSI, then OldWndProc is a function pointer. If they dont match, a handle is returned. The OldWndProc must be invoked using: CallWindowProc (OldWndProc, hWnd, Msg, wParam, lParam) The CallWindowProc API will convert message

27、s in the following manner:, 2000 Microsoft Corporation.,CallWindowProc() Conversions,CallWindowProcW (OldWndProc, hWnd, Msg, wParam, lParam),Convert from ANSI if OldWndProc is a handle. Dont convert if pointer.,MultiBytetoWideChar(),WideChartoMultiByte(),Only known system messages are converted: WM_

28、CHAR, WM_SETTEXT, WM_GETTEXT, CB_ADDSTRING, etc.,FROM UNICODE,TO UNICODE,FROM ANSI,TO ANSI,CallWindowProcA (OldWndProc, hWnd, Msg, wParam, lParam),Convert from Unicode if OldWndProc is a handle. Dont convert if pointer., 2000 Microsoft Corporation.,How do messages travel to a window in MFC?,MFC PreT

29、ranslateMessage (C+ Inheritance),DispatchMessageA/W,MFC WNDPROC,MFCs Message Map and Runtime Class Hierarchy,CallWindowProcA/W (Original WNDPROC),Always Executed,If Prior Step Doesnt Handle, 2000 Microsoft Corporation.,Making Unicode message survive ANSI MFC,MFC PreTranslateMessage (C+ Inheritance),

30、DispatchMessageW,MFC WNDPROC,MFCs Message Map and Runtime Class Hierarchy,CallWindowProcA/W (Original WNDPROC),Always Executed,If Prior Step Doesnt Handle,IsDialogMessageA() & WM_CHAR,Resubclass as Unicode WNDPROC,New Unicode classes handle messages as appropriate,Original WNDPROC as function not ha

31、ndle Override DefWindowProc to use CallWindowProcW(),All messages Unicode on Windows NT/2000, 2000 Microsoft Corporation.,Conclusions and Relevance,Technical feasibility shown for Unicode MFC applications on all Windows platforms Code built for FrontPage 10 and not in sharable form Any developer can

32、 use these techniques: CString class Common Controls Editing control Text rendering routines using UniScribe Owner-drawn ListBox and ComboBox, 2000 Microsoft Corporation.,Futures,Applications somewhat lead development tools and system support Cross-code page Plug UI Full Unicode file name and URL su

33、pport, 2000 Microsoft Corporation.,Contributors, References and Contact Info,Contributors: Craig Hajduk , Tracey Setoda, Vinny Romano Resources: Reference for international development: http:/ Design a Single Unicode App that Runs on Both Windows 98 and Windows 2000, F. Avery Bishop, http:/ April 19

34、99. 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. Contact Info: ,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1