═══ 1. Disclaimer ═══ THIS SOFTWARE IS PROVIDED BY THOMAS KORFHAGE "AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THOMAS KORFHAGE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ═══ 2. Extension of VisPro Rexx Spreadsheet Object ═══ The VisPro Rexx Spreadsheet Object is limited in the way you can start editing a field. You have to ALT+LeftClick on the field to get it into the edit state. I didn't like that to be the only way, so i searched for a way to enhance the spreadsheet control. I did this first for the VisProC object. I subclassified the VPSpreadsheetClass. First i thought i had to create a complete new object with the VPTOOL kit to do the same for Rexx. Then i got the idea to try the subclassing in an external rexx-dll. I found that i seems so work. But i could not use class subclassing, because there is no way in VisProRexx to make the call at the wright time (between registration of the standard VisProSpreadSheetObject and the first creation of an instance of it, if the spreadsheet is on the first (Main) window form). So i decided to use window subclassing. That's what is done if you call SbcSpsht(window, id). The Spreadsheet Object (Control id on form window) will be subclassed. You can then set the desired edit style and/or let the spreadsheet perform a display optimization. This sample was build with screen resolution 1280x1024. May be it looks bad on VGA. Thomas Korfhage Sep. 1997 Warning: This is the first time i tried the window subclassing in an external rexx-dll. During my test cycle (German Warp4 no FP) i could not watch any side effects and problems. This does not mean, that i would not expect them to arise in the future. So read the Disclaimer! ═══ 3. How to enable the extensions ═══ To get access to the extensions, you first have to register the rexx function SbcSpsht /* Event Form events, Opened */ /* Register the extension and subclass the spreadsheet */ call RxFuncAdd 'SbcSpsht', 'SBCSPSHT', 'SbcSpsht' SbcSpshtRV = SbcSpsht(window, 1000); SbcSpsht must be called for every spreadsheet object after its creation. Successfully subclassing is shown by a return value of "1", "0" means subclassing could not be done. ═══ 4. How to configure the edit style ═══ To set the desired edit style, a message has to be send to the control. Use the Create link "Send message 2 longs" from the spreadsheet control. /* Set the edit style */ Style = SPRS.ENTER_EDITS + SPRS.CHAR_EDITS value=VpItem(window,1000,'SENDMSG', SPRM.SET_EDTSTYLE, Style, EditKey); The edit styles are non exclusive flags, so they can be added. ═══ 5. Optimize the Display ═══ The extension also includes the optimizing of the Spreadsheet widths and heights according to font in use. To optimize the spreadsheet, a message has to be send to the control. Use the Create link "Send message 4 shorts" from the spreadsheet control. Short 1 Column to optimize, -1 for all, 0 for the row label column Short 2 Column and/or Header, 1 for column width optimization, 2 for header height optimization, 3 for both Short 3 Additional horizontal space Short 4 Additional vertical space (space for rows) * 256 + space for header /* Set the edit style */ value=VpItem(window,1000,'SENDMSG', SPRM.OPTIMZE, SPRS.OPTIMZE_ALLCOLS, SPRS.OPTIMZE_BOTH, '10', '10'); Be sure to set the max number of cells before this call, because the text of up to all fields must be checked to find the longest. If You have set the max number of cells and performed the optimization, You my size the spreadsheet to the size that displays all fields. Be sure the control will fit into your window! /* Get item position 1000 Spreadsheet */ xy=VpItem(window,1000,'ITEMPOS') PARSE VAR xy x y /* Set item position/size 1000 Spreadsheet */ CALL VpItem window,1000,'SETITEMPOS',x,y,20000,20000 /* Repaint item 1000 Spreadsheet */ rc=VpItem(window,1000,'PAINT') This uses the functionality build into the original Vispro Spreadsheet to reduce it's size to the maximal needed area. ═══ 6. Readonly Fields/Columns/Rows ═══ Any Field can be set readonly. To set fields readonly, a message has to be send to the control. Use the Create link "Send message 4 shorts" from the spreadsheet control. Short 1 Column 1-n, -1 for all columns of a row Short 2 Row 1-n, -1 for all of rows of a column Short 3 Readonly Flag, 1 set Readonly, 0 reset Readonly Short 4 Not used, should be 0 Set field 1,2 readonly. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, 1, 2, 1, 0); Set row 2 readonly. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, 2, 1, 0); Set coulumn 3 readonly. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, 3, -1, 1, 0); Set every field readonly. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, -1, 1, 0); Reset readonly for every field. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, -1, 0, 0); This functionality is limited to 1000 rows and/or 1000 columns! ═══ 7. Change color for cell in edit mode ═══ The extension also includes the posibility to change the color for a cell that is in edit mode. To optimize the spreadsheet, a message has to be send to the control. Use the Create link "Send message 4 longs" from the spreadsheet control. Long 1 Fore ground color, use a RGB - value Long 2 Back ground color, use a RGB - value /* Set the edit Color to black on red */ Bcolor = ((255 * 256) + 0)*256+0 Fcolor = 0 value=VpItem(window,1000,'SENDMSG', SPRM.SET_EF_COLORS, Fcolor, Bcolor); ═══ 8. Enter edit mode for a cell ═══ The extension also includes the posibility directly start the edit mode for one cell. To optimize the spreadsheet, a message has to be send to the control. Use the Create link "Send message 4 longs" from the spreadsheet control. Long 1 Column of Cell Long 2 Row of CellEnter edit mode /* Start edit mode for cell 3,3 */ value=VpItem(window,1000,'SENDMSG', SPRM.EDIT_CELL, 3, 3); ═══ 9. Constant definitions ═══ To make code more readable following definitions are used: SPRM.SET_EDTSTYLE = '0x101b' SPRM.GET_EDTSTYLE = '0x101c' SPRS.ENTER_EDITS = 256 SPRS.CHAR_EDITS = 512 SPRS.EDITFULLSEL = 1024 SPRS.EDITFIXLEN = 2048 SPRS.ALLOWDELETE = 4096 SPRS.GO_LEFT = 8192 SPRS.GO_DOWN = 16384 SPRS.VIRTUALKEY = 65536 SPRS.KEY_SHIFT = 16777216 SPRS.KEY_CTRL = 33554432 SPRS.KEY_ALT = 67108864 SPRM.OPTIMZE = '0x101a' SPRS.OPTIMZE_ALLCOLS =-1 SPRS.OPTIMZE_COLS =1 SPRS.OPTIMZE_HEADER =2 SPRS.OPTIMZE_ROW_HEIGHT =4 SPRM.SET_READONLY = '0x101e' SPRM.SET_EF_COLORS = '0x101f' SPRM.EDIT_CELL = '0x1020' ═══ 10. Additional Edit Key ═══ Beneath the Enterkey one other user defined key can be set to act in the same way. The Key must be given as a special constant when setting the edit style. value = SPRS.VIRTUALKEY if shft then value = value + SPRS.KEY_SHIFT; if ctrl then value = value + SPRS.KEY_CTRL; if alt then value = value + SPRS.KEY_ALT; value = value + 33; /* key 33 is F2 */ value=VpItem(window,1000,'SENDMSG', SPRM.SET_EDTSTYLE, Style, value); ═══ 11. RXWAITUNTIL ═══ Included within the spcspsht.dll is the function RXWAITUNTIL. It can be used, to suspend a the REXX programm until a specified time is reached. ActualDateString = RXWAITUNTIL(h,m,s) h hour to wait for (0-23). If h is greater 23 it matches any hour. m minute to wait for (0-23). If m is greater 59 it matches any minute. s second to wait for. If RXWAITUNTIL is called w/o any parameter it will be the same than RXWAITUNTIL(99,99,0). It waits until the next minute start. ═══ 12. Contact Thomas Korfhage ═══ 100271.16@compuserve.com or korfhage@t-online.de