Zoom edittable cell to popup form editbox (OpenInsight Specific)
At 25 SEP 1998 09:58:43AM Steve C. wrote:
I remember some time back seeing code that would allow
a user to double-click on an edittable cell, lets call
it COMMENTS.
When this cell is doubleclicked a new window/form pops up
that is simply one big edit box. Delimiters are converted
and the user is able to edit a large comment area. When finished
the COMMENTS window is closed and the delimiters converted again and the info is stored back into the edittable cell.
Does anybody know where I saw this code?? I can't remember if it
was in this discussion section, knowledgebase, SENL newsletter,
or if O just dreamed it up
.
Thanks…
And welcome everybody to my home country…..state of TEXAS next month. Hope to see some of ya'll down in "Houston".
Steve C.
At 25 SEP 1998 10:21AM Cameron Revelation wrote:
Hi Steve,
That example has been done in OpenInsight classes here at Revelation.
I also have source code for a procedure called EditZoom that was going to go in the KB or the Works, but there is a bug in Windows menu processing that keeps the context sensitive menu from working on a dialog, so it did not get completed. (Good excuse, huh?)
Cameron Purdy
Revelation Software
<code> function EditZoom(Instruction, Param) ****************************************************************************** * * This program is proprietary and is not to be used by or disclosed * to others, nor is it to be copied without written permission from * Revelation Technologies, Inc. * * Name : EditZoom * Description: Full featured text editor. * * Parameters : See EditZoom_Equates * * History : * 10/25/97 cp Original programmer * ****************************************************************************** declare subroutine Set_Property, Utility, End_Dialog, Set_EventStatus declare subroutine GetPrivateProfileString, WritePrivateProfileString declare function Get_Property, Utility, Send_Message, Dialog_Box, MixedCase $insert Logical $insert PS_Equates $insert Msg_Equates $insert Style_Equates $insert EditZoom_Equates * dialogs equ EZ_DLG$ to "EDITZOOM" ****** * main ****** Ret=" if assigned(Instruction) else Instruction=1 if assigned(Param) else Param=" on Instruction gosub Zoom, CanZoom, Dialog, Create, Close, Save, Del, InsertDate, InsertTime, ToUpper, ToLower, ToMixed, Indent, UnIndent, Size, Font, BackColor, ForeColor, WordWrap, Zoom return Ret ****************************** * zoom edit the control's text ****************************** Zoom: if len(Param) then Ctrl=Param end else Ctrl=Get_Property("SYSTEM", "FOCUS") end Ctrls=str(@rm: Ctrl, 8) 2,9999 Props=TEXT,TYPE,STYLE,FONT,BACKCOLOR,FORECOLOR,SELPOS,SELECTION" gosub GetProps Text =field(Vals, @rm, 1) Type =field(Vals, @rm, 2) Style =field(Vals, @rm, 3) Font =field(Vals, @rm, 4) Back =field(Vals, @rm, 5) Fore =field(Vals, @rm, 6) SelPos =field(Vals, @rm, 7) TextSel=field(Vals, @rm, 8) if Style 1,2 _eqc "0x" then convert @lower.case to @upper.case in Style MX") end if inlist("EDITFIELD,EDITBOX,COMBOBOX,LISTBOX,EDITTABLE", Type, ",") and (Type # "EDITFIELD" or not(bitand(Style, ES_PASSWORD$))) then * determine read-only, justification, uppercase begin case case Type=EDITFIELD" or Type=EDITBOX" bReadOnly =(bitand(Style, ES_READONLY$ ) # 0) TextJust =LCRL" bitand(Style, 3) + 1, 1 bUpperCase =(bitand(Style, ES_UPPERCASE$) # 0) bNoCtrlChar=(Type=EDITFIELD") case Type=COMBOBOX" bReadOnly =(bitand(Style, CBS_DROPDOWNLIST$)=CBS_DROPDOWNLIST$) TextJust =L" bUpperCase =FALSE$ case Type=LISTBOX" bReadOnly =TRUE$ TextJust =L" bUpperCase =FALSE$ case Type=EDITTABLE" ColStyle =Send_Message(Ctrl, "COLSTYLE", SelPos) bReadOnly =(bitand(ColStyle, DTCS_PROTECT$) # 0) TextJust =LCRL" bitand(ColStyle, 192) / 64 + 1, 1 bUpperCase =FALSE$ bNoCtrlChar=TRUE$ end case * invoke zoom dialog Orig=Text Text=EditZoom(EZCMD_DIALOG$, Text: @fm:bReadOnly: @fm: TextJust: @fm: bUpperCase: @fm: Font: @fm: Back: @fm: Fore: @fm: TextSel) * check for changes if "*":Text # "*":Orig and not(bReadOnly) then if bNoCtrlChar then convert \090D0A\ to space(2) in Text end Set_Property(Ctrl, "DEFPROP", Text) end end return **************************************** * check if zoom is applicable to control **************************************** CanZoom: if len(Param) else Param=Get_Property("SYSTEM", "FOCUS") end Ctrls=Param: @rm: Param Props=TYPE,STYLE" gosub GetProps Type =field(Vals, @rm, 1) 0x" then convert @lower.case to @upper.case in Style MX") end * all text-oriented controls, but no password-style edit fields Ret=inlist("EDITFIELD,EDITBOX,COMBOBOX,LISTBOX,EDITTABLE", Type, ",") and (Type # "EDITFIELD" or not(bitand(Style, ES_PASSWORD$))) return ************************************** * allow zoom to be used on passed text ************************************** * Param in - structure for EZCMD_DIALOG$ as defined in equates Dialog: call Create_Dialog(EZ_DLG$, @window, FALSE$, Param) return Ret=Dialog_Box(EZ_DLG$, @window, Param) if len(Ret) then * first character is a token specifying that a change occurred Ret 1,1=" end else * user didn't save changes Ret=Param end return ************************** * zoom dialog create event ************************** * Param in - structure for EZCMD_DIALOG$ as defined in equates Create: * change menu items (designed with "= as a place-holder for ) [email protected],@.MENU.EDIT.DELETE,@.MENU.SPECIAL.INDENT,@.MENU.SPECIAL.UNINDENT" Props=TEXT,TEXT,TEXT,TEXT" gosub GetProps convert "= to \09\ in Vals gosub SetProps * get structure of the edit box, then destroy it Struct=Get_Property(@window: ".EB", "ORIG_STRUCT") Utility("DESTROY", @window: ".EB") if Style 1,2 _eqc "0x" then convert @lower.case to @upper.case in Style MX") end * no-hide-selection stye required for find/replace then Style += ES_READONLY$ end * apply text justification option TextJust=Param begin case case TextJust 1,1 _eqc "C" Style += ES_CENTER$ case TextJust 1,1 _eqc "R" Style += ES_RIGHT$ end case * apply uppercase-only option if Param then Style += ES_UPPERCASE$ end * apply font option Font=Param if len(Font) then Struct=Font end * apply background color option Back=Param if len(Back) then if num(Back) else Back=Back + Back * 256 + Back * 65536 end Struct=Back end * apply foreground color option Fore=Param if len(Fore) then if num(Fore) else Back=Fore + Fore * 256 + Fore * 65536 end Struct=Fore end * apply selection option TextSel=1: @fm: 0 if len(Param) and num(Param) then TextSel=Param if len(Param) and num(Param) then TextSel=Param end end * recreate structure with new text and style Text=Param Struct=Text Struct=Style Utility("CREATE", Struct) * hook up edit menu to modify on the fly [email protected],@" Props=EVENTQUALIFIER,@ORIG" Vals =2*SYSPROG*EDIT.MENU.OIWIN*": @rm: Text * load default size from INI ][size=str(\00\, 1024) User=": @appid: ",": @username: "" GetPrivateProfileString(EZ_INI_SECT$: \00\, EZ_INI_SIZE$: User: \00\, "", Size, len(Size), EZ_INI_FILE$: \00\) ][size=Size 1, \00\ * set size or visible to display dialog Ctrls := ",@" Props := "," Vals := @rm begin case case Size 1,1 _eqc "M" Props := "VISIBLE" Vals := 3 case len(Size) and num(Size 1,",") convert "," to @fm in Size Props := "SIZE" Vals := Size case OTHERWISE$ Props := "VISIBLE" Vals := TRUE$ end case * set focus to edit control Ctrls := ",SYSTEM,@.EB" Props := ",FOCUS,SELECTION" Vals := @rm: @window: ".EB": @rm: TextSel gosub SetProps return ************************* * zoom dialog close event ************************* Close: Ctrls=@,@.EB" Props=@ORIG,TEXT" gosub GetProps Orig =field(Vals, @rm, 1) Text =field(Vals, @rm, 2) if "*":Orig # "*":Text then Ans=Msg(@window, "", "EDITZOOM_SAVEWARN") begin case case Ans=RET_YES$ * save changes EditZoom(EZCMD_SAVE$) case Ans=RET_NO$ * don't save changes End_Dialog(@window, "") case OTHERWISE$ * prevent closing Set_Property("SYSTEM", "FOCUS", @window: ".EB") Set_EventStatus(TRUE$) end case end else * no changes End_Dialog(@window, "") end return **************************** * close zoom, returning text **************************** Save: End_Dialog(@window, "*": Get_Property(@window: ".EB", "TEXT")) return ********************** * delete selected text ********************** Del: [email protected],@.EB" Props=TEXT,SELECTION" gosub GetProps Text =field(Vals, @rm, 1) Sel =field(Vals, @rm, 2) if Sel then * text is selected if Sel =Sel + Sel Sel=abs(Sel) end Text Sel,Sel=" end else * delete next character Pos=Sel if Text Pos,2=\0D0A\ then Text Pos,2=" end else Text Pos,1=" end end Sel=0 [email protected],@.EB" Props=TEXT,SELECTION" Vals =Text: @rm: Sel gosub SetProps return ****************************** * insert date/time information ****************************** InsertDate: InsertTime: [email protected],@.EB" Props=TEXT,SELECTION" gosub GetProps Text =field(Vals, @rm, 1) Sel =field(Vals, @rm, 2) if Instruction=EZCMD_DATE$ then NewText=MixedCase(fmt(date(), "D")) end else NewText=fmt(time(), "MTS") end * verify that selection is frontwards if Sel =Sel + Sel Sel=abs(Sel) end Text Sel,Sel=NewText Sel=Sel + len(NewText) Sel=0 [email protected],@.EB" Props=TEXT,SELECTION" Vals =Text: @rm: Sel gosub SetProps return ****************************** * change case of selected text ****************************** ToUpper: ToLower: ToMixed: [email protected],@.EB" Props=TEXT,SELECTION" gosub GetProps Text =field(Vals, @rm, 1) Sel =field(Vals, @rm, 2) * verify that a selection exists if Sel then * verify that selection is frontwards if Sel =Sel + Sel Sel=abs(Sel) end * extract selection NewText=Text Sel,Sel * change case begin case case Instruction=EZCMD_TOUPPER$ convert @lower.case to @upper.case in NewText case Instruction=EZCMD_TOLOWER$ convert @upper.case to @lower.case in NewText case OTHERWISE$ NewText=MixedCase(NewText) end case Text Sel,Sel=NewText [email protected],@.EB" Props=TEXT,SELECTION" Vals =Text: @rm: Sel gosub SetProps end return ********************************* * indent/unindent a block of text ********************************* Indent: UnIndent: [email protected],@.EB" Props=TEXT,SELECTION" gosub GetProps Text =field(Vals, @rm, 1) Sel =field(Vals, @rm, 2) * verify that selection is frontwards if Sel =Sel + Sel Sel=abs(Sel) end * determine lines to indent iFirst=count(Text 1, Sel , \0A\) + 1 iLast =count(Text 1, Sel + Sel - 1, \0A\) + 1 * determine text to indent if iFirst=1 then ofFirst=1 end else ofFirst=index(Text, \0A\, iFirst - 1) + 1 end ofLast=index(Text, \0D\, iLast) if ofLast then ofLast -= 1 end else ofLast=len(Text) end * extract text to indent NewText=Text ofFirst, ofLast - ofFirst + 1 * indent/unindent swap \0D0A\ with @fm in NewText cLines=count(NewText, @fm) + (NewText # "") for i=1 to cLines Line=NewText[i] if len(Line) then begin case case Instruction=EZCMD_INDENT$ Line=\09\: Line case Instruction=EZCMD_UNINDENT$ if Line1,1=\09\ or Line1,1= " then Line1,1=" end end case NewText[i]=Line end next i swap @fm with \0D0A\ in NewText * update displayed text Text ofFirst, ofLast - ofFirst + 1=NewText Sel=ofFirst: @fm: len(NewText) [email protected],@.EB" Props=TEXT,SELECTION" Vals =Text: @rm: Sel gosub SetProps return ******************** * window has resized ******************** Size: * determine size of zoom window Ctrls=@,@" Props=VISIBLE,SIZE" gosub GetProps Max =field(Vals, @rm, 1)=3 ][size=field(Vals, @rm, 2) if Max then ][size=MAX" end else convert @fm to "," in Size end * save default size in INI User=": @appid: ",": @username: "" WritePrivateProfileString(EZ_INI_SECT$: \00\, EZ_INI_SIZE$: User: \00\, Size: \00\, EZ_INI_FILE$: \00\) return ***************************** * select font for editor text ***************************** Font: Font=Get_Property(@window: ".EB", "FONT") Font=Utility("CHOOSEFONT", @window, Font) if len(Font) then Set_Property(@window: ".EB", "FONT", Font) end return ************************************ * select background color for editor ************************************ BackColor: Back=Get_Property(@window: ".EB", "BACKCOLOR") Back=Utility("CHOOSECOLOR", @window, Back) if len(Back) then Set_Property(@window: ".EB", "BACKCOLOR", Back) end return ****************************** * select text color for editor ****************************** ForeColor: Fore=Get_Property(@window: ".EB", "FORECOLOR") Fore=Utility("CHOOSECOLOR", @window, Fore) if len(Fore) then Set_Property(@window: ".EB", "FORECOLOR", Fore) end return ************************* * toggle word wrap option ************************* WordWrap: [email protected]_WRAP": str(",@.EB", 8) Props=CHECK,TEXT,SELECTION,ORIG_STRUCT,STYLE,FONT,BACKCOLOR,FORECOLOR,SIZE" gosub GetProps bWrap =field(Vals, @rm, 1) Text =field(Vals, @rm, 2) Sel =field(Vals, @rm, 3) Struct=field(Vals, @rm, 4) Style =field(Vals, @rm, 5) Font =field(Vals, @rm, 6) Back =field(Vals, @rm, 7) Fore =field(Vals, @rm, 8) Size =field(Vals, @rm, 9) if Style 1,2 _eqc "0x" then convert @lower.case to @upper.case in Style MX") end =Text Struct=Style Struct=Size Struct=Size Struct=Size Struct=Size Struct=Font Struct=Back Struct=Fore Utility("DESTROY", @window: ".EB") Utility("CREATE", Struct) [email protected],@.EB" Props=FOCUS,SELECTION" Vals =TRUE$: @rm: Sel gosub SetProps return ***************** internal subroutines ****************** GetProps: swap "@" with @window in Ctrls convert "," to @rm in Ctrls convert "," to @rm in Props Vals=Get_Property(Ctrls, Props) return SetProps: swap "@" with @window in Ctrls convert "," to @rm in Ctrls convert "," to @rm in Props Set_Property(Ctrls, Props, Vals) return</code>