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 PROTECTED]>

> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to