Creating a window without a nib

Discussion in 'Mac Programming' started by printf, Sep 21, 2008.

  1. printf macrumors regular

    Aug 27, 2008
    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!
  2. Catfish_Man macrumors 68030


    Sep 13, 2001
    Portland, OR
    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.
  3. printf thread starter macrumors regular

    Aug 27, 2008
    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!
  4. kainjow Moderator emeritus


    Jun 15, 2000

Share This Page