Creating a window without a nib

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

  1. macrumors regular

    Joined:
    Aug 27, 2008
    #1
    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. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #2
    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. thread starter macrumors regular

    Joined:
    Aug 27, 2008
    #3
    think i just found another way:

    Code:
    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. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4

Share This Page