tailieunhanh - Mac OS X Programming phần 5

Đối số thứ tư, NULL, bỏ qua các bản ghi của các thông tin cảnh báo thêm. Đối số cuối cùng, cảnh báo, nói với CreateStandardAlert để tạo ra một cảnh báo rằng có thể sau đó được tham chiếu bằng cách sử dụng các cảnh báo biến DialogRef. Trước đó trong chương này, bạn đọc mô tả về các kiểu dữ liệu WindowRef. DialogRef | The nib file for this project requires two window resources. This example uses a document window and a utility window but you re free to change the window types. In the nib file the windows should be named MainWindow and InfoWindow . If you use different names you ll need to change the arguments to calls to CreateWindowFromNib to match your names. Both windows are empty. Their content will be created in window update routines in the source code. The program doesn t make use of any of the menu items so you can leave the menu bar resource unchanged. Example contains the entire listing for the example program. Here you see an example of the multiple window updating technique described in the previous section a global variable is declared for each of two window types and a single event handler is used to invoke the proper update routine for the window that needs to be redrawn. The code that comprises each update routine is similar to the code discussed in the previous example WindowUpdate. Example MultipleWindowUpdate Source Code include Carbon pascal OSStatus MyWindowEventHandler EventHandlerCallRef handlerRef EventRef event void userData void UpdateMainWindow void void UpdateInfoWindow void WindowRef gMainWindow WindowRef gInfoWindow int main int argc char argv IBNibRef nibRef OSStatus err EventTargetRef target EventHandlerUPP handlerUPP EventTypeSpec windowEvent kEventClassWindow kEventWindowDrawContent err CreateNibReference CFSTR main nibRef err SetMenuBarFromNib nibRef CFSTR MainMenu err CreateWindowFromNib nibRef CFSTR MainWindow gMainWindow target GetWindowEventTarget gMainWindow handlerUPP NewEventHandlerUPP MyWindowEventHandler InstallEventHandler target handlerUPP 1 windowEvent void gMainWindow NULL err CreateWindowFromNib nibRef CFSTR InfoWindow gInfoWindow target GetWindowEventTarget gInfoWindow handlerUPP NewEventHandlerUPP MyWindowEventHandler InstallEventHandler target handlerUPP 1 windowEvent void gInfoWindow NULL DisposeNibReference .

TỪ KHÓA LIÊN QUAN