home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / PRNTCHLD.E < prev    next >
Text File  |  1996-05-21  |  2KB  |  51 lines

  1.  
  2. ; Sample code for setting up a parent-child relationship between two
  3. ; edit windows.  The initial edit window issues an OpenChild command,
  4. ; which opens another edit window and sends in a ParentWindow command,
  5. ; giving the initial edit window's handle as an argument.  The new window
  6. ; responds to this command by sending back to the parent window the
  7. ; child's window handle.  At this point, two-way communication is
  8. ; possible.
  9. ;    Note that this need not be included in the base macros; if
  10. ; desired, it can be a separate linkable .ex file, and the child
  11. ; can be told to link it dynamically:  openchild 'link prntchld'
  12. ;                        By:  Larry Margolis
  13.  
  14. compile if not defined(TRUE)
  15. include 'stdconst.e'  -- Required to define EPMINFO_EDITCLIENT
  16. compile endif
  17.  
  18. ; The following command opens a new edit window and passes it a command
  19. ; telling it what the current window's handle is.
  20. defc openchild  -- accepts an optional list of files to edit and/or cmds
  21.    'open' arg(1) "'parent_window" getpminfo(EPMINFO_EDITCLIENT)"'"
  22.  
  23. ; This command is telling us what the parent window's window handle is;
  24. ; we respond by telling it our window handle.  In a more complicated
  25. ; scenario, involving multiple children, the openchild command could
  26. ; have passed in an index as well as the parent's window handle, and
  27. ; we could respond with that index as well as our (the child's) own
  28. ; window handle, or we could send back the file name in addition to
  29. ; the window handle if you wanted the parent to keep track of children
  30. ; by name.
  31. defc parent_window
  32.    universal parent_hwnd
  33.    parent_hwnd = arg(1)
  34. ;  sayerror 'Parent window handle is' parent_hwnd
  35.    cmd = 'child_window' getpminfo(EPMINFO_EDITCLIENT)
  36.    call windowmessage(0,  parent_hwnd,
  37.                       5377,               -- EPM_EDIT_COMMAND
  38.                       put_in_buffer(cmd),
  39.                       1)  -- Flag to free the buffer
  40.  
  41. ; This command is received from a child window by a parent window;
  42. ; it simply records the window handle for future use.  If multiple
  43. ; children were involved, it would parse off the index and filename
  44. ; and keep track of them in an appropriate manner (possibly in an
  45. ; EPM array).
  46. defc child_window
  47.    universal child_hwnd
  48.    child_hwnd = arg(1)
  49. ;  sayerror 'Child window handle is' child_hwnd
  50.  
  51.