home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / next / programm / 8041 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.7 KB  |  61 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!mcdchg!laidbak!katzung
  3. From: katzung@i88.isc.com (Brian Katzung)
  4. Subject: Re: InterfaceBuilder: No KeyAndOrderFront at app's startup??
  5. Message-ID: <1993Jan08.213027.8670@i88.isc.com>
  6. Keywords: ProjectBuilder; InterfaceBuilder; makeKeyAndOrderFront
  7. Sender: usenet@i88.isc.com (Usenet News)
  8. Nntp-Posting-Host: laitnite.i88.isc.com
  9. Organization: Interactive Systems Corporation, Naperville, IL
  10. References: <1993Jan5.130920.29274@oce.nl>
  11. Date: Fri, 08 Jan 1993 21:30:27 GMT
  12. Lines: 47
  13.  
  14. It is considered rude and uncivilized for applications to
  15. unconditionally activate themselves at startup because the
  16. user may have activated some other application in the mean
  17. time (see - activateSelf: (Application)).
  18.  
  19. I have included the source for "activate" that you can use to
  20. activate your application after you "open" it.  You might want
  21. to add some enhancements such as appending ".app" if
  22. NXPortFromName() can't find the application as specified.
  23.  
  24.   -- Brian Katzung  katzung@{i88.isc, swissbank}.com
  25.  
  26. //
  27. // activate -- Tell an application to activate itself
  28. //    Brian Katzung  8 January 1993
  29. //
  30. // Compile with -lNeXT_s.
  31. //
  32.  
  33. #import <appkit/appkit.h>
  34. #import <appkit/Speaker.h>
  35.  
  36. // Activate the named application using the provided speaker
  37. void
  38. activate (id speaker, const char *appName)
  39. {
  40.     BOOL    yes = YES;
  41.  
  42.     [speaker setSendPort: NXPortFromName(appName, NULL)];
  43.     [speaker performRemoteMethod: "activateSelf:"
  44.       with: (const char *) &yes length: sizeof(yes)];
  45. }
  46.  
  47. int
  48. main (int ac, char **av)
  49. {
  50.     if (ac > 1)
  51.     {
  52.         id    speaker;
  53.  
  54.         speaker = [[Speaker alloc] init];
  55.         activate(speaker, av[1]);
  56.         [speaker free];
  57.     }
  58.  
  59.     return 0;
  60. }
  61.