Launch app with params as front process and wait?

2010-04-17 Thread Gaurav Srivastava
Hi,

I was working with NSTask and came across some issues. I searched on the
internet and found that there has been a similar query but that didn't have
any solution. The link for that is
http://lists.apple.com/archives/cocoa-dev//2003/May/msg01468.html. Could you
suggest any possible solution for this.

Also, if my parent application has a non-modal dialog up, on launching
another app, it goes behind the non-modal dialog. Please suggest some
solution as I am stuck with it for last few days.


Thanks,
Gaurav Srivastava
___

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 arch...@mail-archive.com


Re: Launch app with params as front process and wait?

2010-04-17 Thread Gaurav Srivastava
Hi Ken,

Thanks for the prompt reply. I got a better insight into the APIs. But
somehow I am not able to fix my problem.

I am using following:

NSTask* task = [NSTask launchedTaskWithLaunchPath:@path arguments:args];
int pid  = [task processIdentifier];
ProcessSerialNumber psn;
GetProcessForPID(pid, psn);
SetFrontProcess(psn);
[task waitUntilExit];
SetFrontProcess(psn);

Even on switching to NSWorkSpace doesn't seem to solve the purpose. The
launched application does not get highlighted. Also, one more issue I am
facing is how to send custom events from launched application to parent
application. Thanks in advance.

On Sat, Apr 17, 2010 at 7:13 PM, Ken Thomases k...@codeweavers.com wrote:

 On Apr 17, 2010, at 8:14 AM, Gaurav Srivastava wrote:

  I was working with NSTask and came across some issues. I searched on the
  internet and found that there has been a similar query but that didn't
 have
  any solution. The link for that is
  http://lists.apple.com/archives/cocoa-dev//2003/May/msg01468.html. Could
 you
  suggest any possible solution for this.
 
  Also, if my parent application has a non-modal dialog up, on launching
  another app, it goes behind the non-modal dialog. Please suggest some
  solution as I am stuck with it for last few days.

 To launch a secondary application, you should use NSWorkspace or Launch
 Services.  That will bring it to the front, even if it's already running.
  To wait until it's finished, you can use the techniques outlined in this
 tech note http://developer.apple.com/mac/library/technotes/tn/tn2050.html
 .

 If you need to pass information into the other application, and you control
 the implementation of that application, I recommend using one of:

 * -[NSWorkspace launchApplicationAtURL:options:configuration:error:] with
 the relevant information in the configuration parameter

 * -[NSWorkspace
 launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:]
 with an AppleEvent descriptor

 * LSOpenFromURLSpec() with an AppleEvent descriptor in the passThruParams
 fields of the inLaunchSpec parameter

 You can also pass information into the application through a scripting
 interface.


 If you don't control the implementation of the other application and the
 above techniques don't suffice, you can use NSTask to launch it, but it
 wouldn't be my first choice.  If you need to bring it to the foreground,
 you'd want to use NSWorkspace to monitor for when it's launched and ready,
 and then activate it.  You know when it is launched when you receive the
 NSWorkspaceDidLaunchApplicationNotification notification which matches the
 application that you ran.  On 10.6 and later, you get an
 NSRunningApplication object with that notification, and you can activate it
 by invoking -activateWithOptions: on it.  For 10.5 and earlier, you get a
 dictionary that includes a ProcessSerialNumber, and you can use
 SetFrontProcess with that.

 Regards,
 Ken




-- 
Gaurav Srivastava
___

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 arch...@mail-archive.com


Setting front window when launched from another application

2010-04-15 Thread Gaurav Srivastava
Hi,

I am facing some issues with setting an application as front process when it
is launched from another application. Basically, I have a parent application
A. When user performs certain action, the parent application launches
another application B. It does so by doing fork(). In child process, it
launches the application B by calling execv(). In parent process, it runs an
event loop in which it waits for events received from B. It is basically
done to avoid user interaction with application A. Only when the user is
done with application B, it can interact with A. Now, what happens is that
on launching B from A, B does not come to focus. Even on explicitly setting
B as front process, the issue does not get solved. One more issue I am
facing is that when some modal dialog is up in A and then I launch B, it
goes behind the modal dialog.

Could you suggest some possible solution for this.

Thanks,
Gaurav Srivastava.
___

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 arch...@mail-archive.com


Re: Setting front window when launched from another application

2010-04-15 Thread Gaurav Srivastava
So, is there any way to prevent the user interaction with the parent
application and still keep receiving events from child application.

On Thu, Apr 15, 2010 at 11:44 PM, Jens Alfke j...@mooseyard.com wrote:


 On Apr 15, 2010, at 10:32 AM, Gaurav Srivastava wrote:

  When user performs certain action, the parent application launches
  another application B. It does so by doing fork().

 Whoa — don’t do this. GUI apps should be launched by calling LaunchServices
 (or NSWorkspace, which is a wrapper around it.)

 One of the effects of failure to do this is that the frontmost app doesn’t
 relinquish its frontmost status, so the new app can’t claim it and become
 frontmost. There are other issues too.

 —Jens




-- 
Gaurav Srivastava
Btech CSE
MNNIT,Allahabad
___

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 arch...@mail-archive.com


Setting parent window

2010-02-25 Thread Gaurav Srivastava
Is there any corresponding function call for ::SetParent(in Windows) in
Cocoa?
Basically I have a parent application from which I have to launch another
application. I want the child application to open as modal within the parent
application and not as a separate application.
I have the window handles of both applications.
I tried using [NSWindow setParentWindow] but this was not working for me.

Is there any possible solution?

-- 
Gaurav Srivastava
___

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 arch...@mail-archive.com