home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mltwin.zip / READ.ME < prev    next >
Text File  |  1992-10-06  |  3KB  |  90 lines

  1.  SUMMARY. Gpf generated code normally creates 1 window instance
  2. for 1 class. It allows access to every window through hwndXXXX
  3. and hwndFrameXXXX static variables(XXXX is the window name).  
  4.  
  5. When necessary, it is very simple to work with multiple
  6. instances of a window class in Gpf generated code. 
  7.  
  8.  
  9.  
  10. To create a new instance you must call the CreateXXXX Gpf
  11. generated function from a user function. After this you must be
  12. careful if you use the hwndXXXX and hwndFrameXXXX statics. They
  13. are correct only for the most recently created window. These
  14. statics are only valid during the, possibly short, time after a
  15. window instance is created and before another window is created
  16. or destroyed.  To access these windows it is more correct to use
  17. the GpfParms structure attached to the window.  This structure
  18. is created and updated by Gpf generated code for the current
  19. window. 
  20.  
  21.  
  22.  
  23. Not quite as straightforward is how to destroy the current
  24. window within a Gpf generated application.   In most cases you
  25. wouldn't need to destroy any window.  Normally modal windows are
  26. created and destroyed as they are shown and dismissed
  27. respectively and modeless windows, complete with all controls
  28. and data, exist from when they are created until the program
  29. ends.  In the case of multiple instances of the same window, it
  30. is more likely you would want to destroy an instance when its
  31. work is done.  The problem is that you can't call the
  32. WinDestroyWindow API directly from user code attached to the
  33. current window.  This will cause a protection violation because
  34. GpfParms contains a return field called mresult which is updated
  35. by the current window procedure.  Unfortunately, destroying
  36. window will destroy the attached information (including
  37. GpfParms). This is easily overcome as long as you are aware of
  38. it.  You simply call the WinDestroyWindow API from another
  39. window; i.e. from a user function attached to another window. 
  40.  
  41.  
  42.  
  43. The following example demonstrates one such solution:
  44.  
  45.  
  46.  
  47.  EXAMPLE. This example demonstrates how to destroy windows with
  48. WinDestroyWindow and how to make multiple windows.
  49.  
  50.  Configuration:
  51.  
  52.   MULTWIN.ORC:
  53.  
  54.    window MainWindow   with Button1 'Create next copy'   window
  55. MultWindow   with Button2 'Destroy me'
  56.  
  57.   UFMULTW.C
  58.  
  59.    userFunction UFSelfDestruct    - sends WM_USER_DESTROY message
  60.                   to MainWindow
  61.    userFunction UFMultDestroy - received WM_USER_DESTROY message and
  62.                 destroys window
  63.  
  64.    userFunction UFCreateMultWindow - calls CreateMultWindow, generated
  65.                      by Gpf.
  66.  
  67.   UFMULTW.H
  68.  
  69.    userFunction descriptions
  70.  
  71.  ACTIONS:  in window MainWindow:
  72.  
  73.     on Click Button1
  74.  
  75.        userFunction UFCreateMultWindow
  76.  
  77.        Shell Position MultWindow
  78.  
  79.        Show window MultWindow
  80.  
  81.      on UserMessage
  82.  
  83.        userFunction UFMultDestroy
  84.  
  85.   in window MultWindow:
  86.  
  87.      on Click Button2
  88.  
  89.        userFunction UFSelfDestruct
  90.