Tham khảo tài liệu 'mac os x programming phần 4', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | DrawString pBeep Now you re ready to build and run the application. Running BeepWorld results in the window shown back in Figure less the two lines of text that say Beep . To draw that text to the window choose the Beep item from the Sound menu. Experienced Mac Programmer You probably are familiar with SetPort which is the port-setting routine that s part of the original Macintosh Toolbox. That function accepts a WindowPt as its argument. In Carbon the WindowPtr is out and the WindowRef is in. The new SetPortWindowPort exists to take the place of etPort. After the port is set drawing proceeds as it has for Mac OS 8 9 for the most part. Use QuickDraw routines such as MoveTo and DrawString to achieve the graphics results you want. As shown in the preceding code snippet those two routines-and most other original QuickDraw routines-remain a part of the API. MyCloseWindow Handling a Window-Related Event The purpose of MyCloseWindow is to demonstrate how to handle a window-related event in a manner different from that governed by the window s standard behavior. In particular the program responds to a click on the Close button of the program s only window. Instead of just closing the window the program sounds a beep and then closes the window. Normally the Carbon Event Manager s default window event handler handles most window-related events dragging resizing closing and so forth . It s possible though to override the standard behavior the system takes to implement a new behavior. Using this example s technique you can intervene on any window-related event and then either completely handle the event or handle the event as your program sees fit and then enable the standard behavior to occur. You can base the MyCloseWindow project on any of the example projects from this chapter. I started with the last version of BeepWorld and made a couple of changes to its resource file and then edited the source code file. Editing the Nib File The MyCloseWindow program requires