• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How make a cocoa lib wich create a window ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How make a cocoa lib wich create a window ?


  • Subject: Re: How make a cocoa lib wich create a window ?
  • From: "rouanet brice" <email@hidden>
  • Date: Wed, 24 Sep 2008 06:41:17 +0200

Hi,

thanks, when I launch a simple app with this code it works :

#import <Cocoa/Cocoa.h>
#import "MyOgView.h"

int main(int argc, char *argv[])
{


    //use TransformProcessType to transform non gui processs in gui process

    //voir -[NSApplication runModalForWindow:].
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSWindow *window;
    MyOgView *ogView;
    ogView = [[MyOgView alloc] initWithFrame:NSMakeRect(0,100,500,375) ];
    window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(50,100,640,480)
                                         styleMask:NSTitledWindowMask |
NSResizableWindowMask
                                           backing:NSBackingStoreBuffered
                                             defer:TRUE];

        const ProcessSerialNumber psn = { 0, kCurrentProcess };
    TransformProcessType(&psn, kProcessTransformToForegroundApplication);


    SetFrontProcess(&psn);

    //add title to the window
    [window setTitle:@"toto gl"];


    //attach glview on the window
    [[window contentView] addSubview:ogView];
    //[[window contentView] addSubview:button];


    [NSApplication sharedApplication];
    [window makeKeyAndOrderFront: nil];
    [pool release];

    [NSApp run];
    return 0;
}

But when I use this code in a dynamic library it not work, I can't see the
window, have you got an idea ?

Regards,
tmator.

2008/9/19 Ken Thomases <email@hidden>

> On Sep 18, 2008, at 11:38 PM, rouanet brice wrote:
>
>  I work on a projetc where the executable haven't GUI but I can launch
>> somme
>> gui window with plugins.
>>
>> test <- no gui application
>>  -plugin
>>   -triangle <- this plugin display a triangle in a cocoa window
>>   -rectangle <- this plugin display a rectangle in a cocoa window
>>
>> All plugins works in standolone applications, but when I launch test, I
>> cant
>> see the window.
>>
>
> You need a couple of things.  First, you will need to use
> TransformProcessType to turn your non-GUI process into a GUI process.
>  Second, you will need to initialize an NSApplication and its connection to
> the window server.  Read the class overview for NSApplication.  You will
> also need to run the event loop somehow.  Normally, this would be done using
> -[NSApplication run], but you may be able to get away with just
> -[NSApplication runModalForWindow:].
>
> Cheers,
> Ken
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How make a cocoa lib wich create a window ?
      • From: Ken Thomases <email@hidden>
References: 
 >How make a cocoa lib wich create a window ? (From: "rouanet brice" <email@hidden>)
 >Re: How make a cocoa lib wich create a window ? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Converting from Carbon Event Manager to NSTimer
  • Next by Date: Re: CGLayer questions
  • Previous by thread: Re: How make a cocoa lib wich create a window ?
  • Next by thread: Re: How make a cocoa lib wich create a window ?
  • Index(es):
    • Date
    • Thread