OS 9 to OS X Dialog programming confusion

goldenmeg

Registered
I am porting my OS 9 code to OS X using xcode 1.5 on Panther. I'm confused about how to handle dialogs and items within dialogs.

I have some sample code that creates a dialog by handling a window created from a nib (CreateWindowFromNib). I need code to get and set numbers (floating point and integer) from edit text boxes. The only reference I can find for this in the dialog reference is to GetDialogItemText(). Even then, I don't know what function to call for the handle to the item (the refernce library links to a list of constants). I also don't know how to convert the text to a number.

Should I just use my old OS 9 dialogs? Then I can get numbers using GetLongItem(), etc. Or are there equivalents for these functions in Carbon? Also, can the function GetNewDialog() pull off my dialog from my .nib file?

Thanks, Meg
 
Do not use your old dialogs and do not use the Dialog Manager. You're on the right path with the CreateWindowFromNib() file call. That will load the dialog from the nib.

What you have to do is replace the Dialog Manager calls with HIView calls. Call HIViewFindByID() to retrieve a reference to a control from the dialog. The functions GetControlData() and SetControlData() will help you with the edit text boxes.

Apple has a document titled Upgrading to the Mac OS X HIToolbox that will help you. In the Porting Steps section of the document, read the Convert Resources to Nibs material. There is a lot of material on transitioning from the Dialog Manager. The document is part of Apple's Carbon documentation, under Human Interface Toolbox.

Apple also has a piece of sample code called DialogsToHIViews that should help.
 
Thanks! I think the resources you have listed will help me solve my problems. I was able to create the dialog from the .nib, display it and close it - but not do anything with the controls. I sure didn't want to go back to ResEdit... InterfaceBulder is much better.

Meg
 
Back
Top