home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / mswindo / programm / misc / 4508 < prev    next >
Encoding:
Text File  |  1992-12-29  |  1.5 KB  |  41 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!think.com!rpi!newsserver.pixel.kodak.com!ekcolor!dj
  3. From: dj@ekcolor.ssd.kodak.com (Dave Jones)
  4. Subject: Re: Sending message for multiple program instances
  5. Message-ID: <1992Dec29.213656.29352@pixel.kodak.com>
  6. Sender: news@pixel.kodak.com
  7. Organization: Vonnegut Tent Rentals, Inc.
  8. X-Newsreader: TIN [version 1.1 PL7]
  9. References: <9212291505.PN05751@LL.MIT.EDU>
  10. Distribution: comp
  11. Date: Tue, 29 Dec 92 21:36:56 GMT
  12. Lines: 27
  13.  
  14. Sarir Khamsi (khamsi@ll.mit.edu) wrote:
  15. > Yo,
  16. > Does somebody have a code segment that will display a message window
  17. > (with OK button) stating that the program is currently running? I am
  18. > using the condition :
  19. >    if( hPrevInstance)
  20. >       return FALSE;
  21. > in my WinMain() to check currently, but it tells the user nothing.
  22. > Thanks in advance.
  23. You ought to be able to use: MessageBox(NULL, "Program is already running!",
  24. "Oops!", MB_OK);
  25. You don't need an application window to use MessageBox.  This in fact is the
  26. answer to those smartalecs who gloat that you can't write a 1-line "Hello 
  27. World" program in Windows.  You can, and I have.
  28.  
  29. If you want something a little less rough and ready, you can query 
  30. hPrevInstance for its main window, then send that a message of your own 
  31. devising (WM_USER or somesuch).  You will add code to the Window procedure
  32. so that the original instance notifies the user.
  33.  
  34. --
  35. ||------------------------------------------------------------------------
  36. ||Dave Jones (dj@ekcolor.ssd.kodak.com)|Eastman Kodak Co. Rochester, NY  |
  37.