home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / extspsht.zip / EXTSPSHT / EXTSPSHT.INF (.txt) < prev    next >
OS/2 Help File  |  1997-09-26  |  11KB  |  255 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Disclaimer ΓòÉΓòÉΓòÉ
  3.  
  4. THIS SOFTWARE IS PROVIDED BY THOMAS KORFHAGE "AS IS'' AND ANY EXPRESSED OR 
  5. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  6. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
  7. EVENT SHALL THOMAS KORFHAGE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  8. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
  9. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
  10. BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
  11. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  12. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  13. POSSIBILITY OF SUCH DAMAGE. 
  14.  
  15.  
  16. ΓòÉΓòÉΓòÉ 2. Extension of VisPro Rexx Spreadsheet Object ΓòÉΓòÉΓòÉ
  17.  
  18. The VisPro Rexx Spreadsheet Object is limited in the way you can start editing 
  19. a field. You have to ALT+LeftClick on the field to get it into the edit state. 
  20.  
  21. I didn't like that to be the only way, so i searched for a way to enhance the 
  22. spreadsheet control. 
  23.  
  24. I did this first for the VisProC object. I subclassified the 
  25. VPSpreadsheetClass. First i thought i had to create a complete new object with 
  26. the VPTOOL kit to do the same for Rexx. Then i got the idea to try the 
  27. subclassing in an external rexx-dll. I found that i seems so work. 
  28.  
  29. But i could not use class subclassing, because there is no way in VisProRexx to 
  30. make the call at the wright time (between registration of the standard 
  31. VisProSpreadSheetObject and the first creation of an instance of it, if the 
  32. spreadsheet is on the first (Main) window form). 
  33.  
  34. So i decided to use window subclassing. That's what is done if you call 
  35. SbcSpsht(window, id). 
  36.  
  37. The Spreadsheet Object (Control id on form window) will be subclassed. You can 
  38. then set the desired edit style and/or let the spreadsheet perform a display 
  39. optimization. 
  40.  
  41. This sample was build with screen resolution 1280x1024. May be it looks bad on 
  42. VGA. 
  43.  
  44. Thomas Korfhage Sep. 1997 
  45.  
  46. Warning: This is the first time i tried the window subclassing in an external 
  47. rexx-dll. During my test cycle (German Warp4 no FP)  i could not watch any side 
  48. effects and problems. This does not mean, that i would not expect them to arise 
  49. in the future. So read the Disclaimer!
  50.  
  51.  
  52. ΓòÉΓòÉΓòÉ 3. How to enable the extensions ΓòÉΓòÉΓòÉ
  53.  
  54. To get access to the extensions, you first have to register the rexx function 
  55. SbcSpsht 
  56.  
  57. /* Event Form events, Opened */
  58. /* Register the extension and subclass the spreadsheet */
  59. call RxFuncAdd 'SbcSpsht', 'SBCSPSHT', 'SbcSpsht'
  60. SbcSpshtRV = SbcSpsht(window, 1000);
  61.  
  62. SbcSpsht must be called for every spreadsheet object after its creation. 
  63. Successfully subclassing is shown by a return value of "1", "0" means 
  64. subclassing could not be done. 
  65.  
  66.  
  67. ΓòÉΓòÉΓòÉ 4. How to configure the edit style ΓòÉΓòÉΓòÉ
  68.  
  69. To set the desired edit style, a message has to be send to the control. Use the 
  70. Create link "Send message 2 longs" from the spreadsheet control. 
  71.  
  72. /* Set the edit style */
  73. Style = SPRS.ENTER_EDITS + SPRS.CHAR_EDITS
  74. value=VpItem(window,1000,'SENDMSG', SPRM.SET_EDTSTYLE, Style, EditKey);
  75.  
  76. The edit styles are non exclusive flags, so they can be added. 
  77.  
  78.  
  79. ΓòÉΓòÉΓòÉ 5. Optimize the Display ΓòÉΓòÉΓòÉ
  80.  
  81. The extension also includes the optimizing of the Spreadsheet widths  and 
  82. heights according to font in use. 
  83.  
  84. To optimize the spreadsheet, a message has to be send to the control. Use the 
  85. Create link "Send message 4 shorts" from the spreadsheet control. 
  86.  
  87.  Short 1   Column to optimize, -1 for all, 0 for the row label column 
  88.  Short 2   Column and/or Header, 1 for column width optimization, 2 for header 
  89.            height optimization, 3 for both 
  90.  Short 3   Additional horizontal space 
  91.  Short 4   Additional vertical space (space for rows) * 256 + space for header 
  92.  
  93.   /* Set the edit style */
  94.   value=VpItem(window,1000,'SENDMSG', SPRM.OPTIMZE, SPRS.OPTIMZE_ALLCOLS, SPRS.OPTIMZE_BOTH, '10', '10');
  95.  
  96.  Be sure to set the max number of cells before this call, because the text of 
  97.  up to all fields must be checked to find the longest. 
  98.  
  99.  If You have set the max number of cells and performed the optimization, You my 
  100.  size the spreadsheet to the size that displays all fields. Be sure the control 
  101.  will fit into your window! 
  102.  
  103.   /* Get item position 1000 Spreadsheet */
  104.   xy=VpItem(window,1000,'ITEMPOS')
  105.   PARSE VAR xy x y
  106.   /* Set item position/size 1000 Spreadsheet */
  107.   CALL VpItem window,1000,'SETITEMPOS',x,y,20000,20000
  108.   /* Repaint item 1000 Spreadsheet */
  109.   rc=VpItem(window,1000,'PAINT')
  110.  
  111.  This uses the functionality build into the original Vispro Spreadsheet to 
  112.  reduce it's size to the maximal needed area. 
  113.  
  114.  
  115. ΓòÉΓòÉΓòÉ 6. Readonly Fields/Columns/Rows ΓòÉΓòÉΓòÉ
  116.  
  117. Any Field can be set readonly. 
  118.  
  119. To set fields readonly, a message has to be send to the control. Use the Create 
  120. link "Send message 4 shorts" from the spreadsheet control. 
  121.  
  122.  Short 1   Column 1-n, -1 for all columns of a row 
  123.  Short 2   Row 1-n, -1 for all of rows of a column 
  124.  Short 3   Readonly Flag, 1 set Readonly, 0 reset Readonly 
  125.  Short 4   Not used, should be 0 
  126.  
  127.  Set field 1,2 readonly. 
  128.  
  129.   value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, 1, 2, 1, 0);
  130.  
  131.  Set row 2 readonly. 
  132.  
  133.   value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, 2, 1, 0);
  134.  
  135.  Set coulumn 3 readonly. 
  136.  
  137.   value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, 3, -1, 1, 0);
  138.  
  139.  Set every field readonly. 
  140.  
  141.   value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, -1, 1, 0);
  142.  
  143.  Reset readonly for every field. 
  144.  
  145.   value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, -1, 0, 0);
  146.  
  147.  This functionality is limited to 1000 rows and/or 1000 columns! 
  148.  
  149.  
  150. ΓòÉΓòÉΓòÉ 7. Change color for cell in edit mode ΓòÉΓòÉΓòÉ
  151.  
  152. The extension also includes the posibility to change the color for a cell that 
  153. is in edit mode. 
  154.  
  155. To optimize the spreadsheet, a message has to be send to the control. Use the 
  156. Create link "Send message 4 longs" from the spreadsheet control. 
  157.  
  158.  Long 1    Fore ground color, use a RGB - value 
  159.  Long 2    Back ground color, use a RGB - value 
  160.  
  161.   /* Set the edit Color to black on red */
  162.   Bcolor = ((255 * 256) + 0)*256+0
  163.   Fcolor = 0
  164.   value=VpItem(window,1000,'SENDMSG', SPRM.SET_EF_COLORS, Fcolor, Bcolor);
  165.  
  166.  
  167. ΓòÉΓòÉΓòÉ 8. Enter edit mode for a cell ΓòÉΓòÉΓòÉ
  168.  
  169. The extension also includes the posibility directly start the edit mode for one 
  170. cell. 
  171.  
  172. To optimize the spreadsheet, a message has to be send to the control. Use the 
  173. Create link "Send message 4 longs" from the spreadsheet control. 
  174.  
  175.  Long 1    Column of Cell 
  176.  Long 2    Row of CellEnter edit mode 
  177.  
  178.   /* Start edit mode for cell 3,3 */
  179.   value=VpItem(window,1000,'SENDMSG', SPRM.EDIT_CELL, 3, 3);
  180.  
  181.  
  182. ΓòÉΓòÉΓòÉ 9. Constant definitions ΓòÉΓòÉΓòÉ
  183.  
  184. To make code more readable following definitions are used: 
  185.  
  186. SPRM.SET_EDTSTYLE = '0x101b'
  187. SPRM.GET_EDTSTYLE = '0x101c'
  188. SPRS.ENTER_EDITS  = 256
  189. SPRS.CHAR_EDITS   = 512
  190. SPRS.EDITFULLSEL  = 1024
  191. SPRS.EDITFIXLEN   = 2048
  192. SPRS.ALLOWDELETE  = 4096
  193. SPRS.GO_LEFT      = 8192
  194. SPRS.GO_DOWN      = 16384
  195.  
  196. SPRS.VIRTUALKEY   = 65536
  197. SPRS.KEY_SHIFT    = 16777216
  198. SPRS.KEY_CTRL     = 33554432
  199. SPRS.KEY_ALT      = 67108864
  200.  
  201. SPRM.OPTIMZE      = '0x101a'
  202. SPRS.OPTIMZE_ALLCOLS   =-1
  203. SPRS.OPTIMZE_COLS      =1
  204. SPRS.OPTIMZE_HEADER    =2
  205. SPRS.OPTIMZE_ROW_HEIGHT =4
  206.  
  207. SPRM.SET_READONLY  = '0x101e'
  208. SPRM.SET_EF_COLORS = '0x101f'
  209. SPRM.EDIT_CELL     = '0x1020'
  210.  
  211.  
  212. ΓòÉΓòÉΓòÉ 10. Additional Edit Key ΓòÉΓòÉΓòÉ
  213.  
  214. Beneath the Enterkey one other user defined key can be set to act in the same 
  215. way. 
  216.  
  217. The Key must be given as a special constant when setting the edit style. 
  218.  
  219. value = SPRS.VIRTUALKEY
  220. if shft then value = value + SPRS.KEY_SHIFT;
  221. if ctrl then value = value + SPRS.KEY_CTRL;
  222. if alt then value = value + SPRS.KEY_ALT;
  223. value = value + 33;        /* key 33 is F2 */
  224. value=VpItem(window,1000,'SENDMSG', SPRM.SET_EDTSTYLE, Style, value);
  225.  
  226.  
  227. ΓòÉΓòÉΓòÉ 11. RXWAITUNTIL ΓòÉΓòÉΓòÉ
  228.  
  229. Included within the spcspsht.dll is the function RXWAITUNTIL. 
  230.  
  231. It can be used, to suspend a the REXX programm until a specified time is 
  232. reached. 
  233.  
  234. ActualDateString = RXWAITUNTIL(h,m,s) 
  235.  
  236.  h 
  237.            hour to wait for (0-23). If h is greater 23 it matches any hour. 
  238.  
  239.  m 
  240.            minute to wait for (0-23). If m is greater 59 it matches any minute. 
  241.  
  242.  s 
  243.            second to wait for. 
  244.  
  245.  If RXWAITUNTIL is called w/o any parameter it will be the same than 
  246.  RXWAITUNTIL(99,99,0). It waits until the next minute start. 
  247.  
  248.  
  249. ΓòÉΓòÉΓòÉ 12. Contact Thomas Korfhage ΓòÉΓòÉΓòÉ
  250.  
  251. 100271.16@compuserve.com 
  252.  
  253.  or 
  254.  
  255. korfhage@t-online.de