View Full Version : Creating a window without a nib

Sep 21, 2008, 06:56 AM
i like breaking all the rules - is there a way to just create a window 'from scratch' with no nib to serve as a template?

CreateWindowFromNib has it's uses in some instances for me - but since this is for a win32 port and there are times where it'd be more convenient to do it 'from scratch'. plus, it would just be nice to know how - especially if such a method were able to be used for other objects like buttons, text boxes, etc..

(note: carbon is my weapon of choice - despite the fine folk that suggested otherwise), so if you've got a related example, that would be nice - but I'll take anything ya got!

Sep 21, 2008, 07:06 AM
Sure, just (Cocoa, sorry; my Carbon is not so great) instantiate an NSWindow, add your views to its content view using addSubview:, and then call makeKeyAndOrderFront or similar.

Sep 21, 2008, 07:11 AM
think i just found another way:

OSStatus CreateNewWindow (
WindowClass windowClass,
WindowAttributes attributes,
const Rect * contentBounds,
WindowRef * outWindow

sorry, still familiarizing myself with the xcode api reference - too used to msdn!

Sep 21, 2008, 11:27 AM
Apple has a lot of documentation that walks you through this stuff:

Handling Carbon Windows and Controls (http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_intro/chapter_1_section_1.html)