有关“Windows编程模式”的中英文翻译.doc

上传人:文库蛋蛋多 文档编号:2392932 上传时间:2023-02-17 格式:DOC 页数:4 大小:20KB
返回 下载 相关 举报
有关“Windows编程模式”的中英文翻译.doc_第1页
第1页 / 共4页
有关“Windows编程模式”的中英文翻译.doc_第2页
第2页 / 共4页
有关“Windows编程模式”的中英文翻译.doc_第3页
第3页 / 共4页
有关“Windows编程模式”的中英文翻译.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《有关“Windows编程模式”的中英文翻译.doc》由会员分享,可在线阅读,更多相关《有关“Windows编程模式”的中英文翻译.doc(4页珍藏版)》请在三一办公上搜索。

1、附录1 外文原文8The Windows Programming ModelNo matter which development tools you use, programming for Windows is different from old-style batch-oriented or transaction-oriented programming. To get started, you need to know some Windows fundamentals. As a frame of reference, well use the well-known MS-DOS

2、 programming model. Even if you dont currently program for plain MS-DOS, youre probably familiar with it. Message ProcessingWhen you write an MS-DOS-based application in C, the only absolute requirement is a function named main. The operating system calls main when the user runs the program, and fro

3、m that point on, you can use any programming structure you want. If your program needs to get user keystrokes or otherwise use operating system services, it calls an appropriate function, such as getchar, or perhaps uses a character-based windowing library. When the Windows operating system launches

4、 a program, it calls the programs WinMain function. Somewhere your application must have WinMain, which performs some specific tasks. Its most important task is creating the applications main window, which must have its own code to process messages that Windows sends it. An essential difference betw

5、een a program written for MS-DOS and a program written for Windows is that an MS-DOS-based program calls the operating system to get user input, but a Windows-based program processes user input via messages from the operating system. NOTEMany development environments for Windows, including Microsoft

6、 Visual C+ version 6.0 with the Microsoft Foundation Class (MFC) Library version 6.0, simplify programming by hiding the WinMain function and structuring the message-handling process. When you use the MFC library, you need not write a WinMain function but it is essential that you understand the link

7、 between the operating system and your programs. Most messages in Windows are strictly defined and apply to all programs. For example, a WM_CREATE message is sent when a window is being created, a WM_LBUTTONDOWN message is sent when the user presses the left mouse button, a WM_CHAR message is sent w

8、hen the user types a character, and a WM_CLOSE message is sent when the user closes a window. All messages have two 32-bit parameters that convey information such as cursor coordinates, key code, and so forth. Windows sends WM_COMMAND messages to the appropriate window in response to user menu choic

9、es, dialog button clicks, and so on. Command message parameters vary depending on the windows menu layout. You can define your own messages, which your program can send to any window on the desktop. These user-defined messages actually make C+ look a little like Smalltalk. 待添加的隐藏文字内容1Dont worry yet

10、about how these messages are connected to your code. Thats the job of the application framework. Be aware, though, that the Windows message processing requirement imposes a lot of structure on your program. Dont try to force your Windows programs to look like your old MS-DOS programs. Study the exam

11、ples in this book, and then be prepared to start fresh. The Windows Graphics Device InterfaceMany MS-DOS programs wrote directly to the video memory and the printer port. The disadvantage of this technique was the need to supply driver software for every video board and every printer model. Windows

12、introduced a layer of abstraction called the Graphics Device Interface (GDI). Windows provides the video and printer drivers, so your program doesnt need to know the type of video board and printer attached to the system. Instead of addressing the hardware, your program calls GDI functions that refe

13、rence a data structure called a device context. Windows maps the device context structure to a physical device and issues the appropriate input/output instructions. The GDI is almost as fast as direct video access, and it allows different applications written for Windows to share the display. Resour

14、ce-Based ProgrammingTo do data-driven programming in MS-DOS, you must either code the data as initialization constants or provide separate data files for your program to read. When you program for Windows, you store data in a resource file using a number of established formats. The linker combines this binary resource file with the C+ compilers output to generate an executable program. Resource files can include bitmaps, icons, menu definitions, dialog box layouts, and strings. They can even include custom resource formats that you define.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号