Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: OWC Grid Dialog Office Web Component
; by Mike Suding December 2008 ; This is an example of using a Grid in a dialog box using OWC (MS-office Web Components) ; you can select one or more rows or cells and click OK and do something with the selected info ; you must download and install the free OWC from www.Microsoft.com/downloads ;based on a tutorial posting from Stan Littlefield - February 22, 2006 ;///////////////////////////////////////////////////// titleBar=`Grid-using-OWC` IntControl(49,3,0,0,0) ; puts a X in titlebar to close a popup window ;debug(1) db=0 GoSub Define_functions instructions=`Select a row then click OK` ;debug(1) CSV_file = StrCat(DirScript(), `products.csv`) MyDialogFormat=`WWWDLGED,6.2` MyDialogCaption=`Grid example` MyDialogX=080 MyDialogY=058 MyDialogWidth=368 MyDialogHeight=267 MyDialogNumControls=003 MyDialogProcedure=`OWCspreadsheet` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialogConfig=0 MyDialog001=`009,041,346,190,COMCONTROL,"ComControl_1",DEFAULT,"OWC11.Spreadsheet",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`295,239,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog003=`015,005,328,026,EDITBOX,"EditBox_1",instructions,"instructions",DEFAULT,1,8,DEFAULT,DEFAULT,"192|192|192"` ButtonPushed=Dialog("MyDialog") If db>1 Then Debug(1) If ButtonPushed==1 oXL.Selection.Copy() myClip_contents=ClipGet() Display(2,`Clipboard contents`, StrCat(`the clipboard contents:`,@CRLF, myClip_contents)) EndIf Exit ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ :define_functions ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;debug(1) #DefineSubRoutine OWCSpreadsheet(handle,msg,id,p4,p5) ;======================= Switch msg Case 0 ;do case 0 stuff at Dialog Initialization DisableMenuItem(handle,1) DisableMenuItem(handle,2) DialogProcOptions(handle, 11,-1) oXL = DialogObject(handle,"ComControl_1",3) DialogObject(handle, "ComControl_1", 1,"BeforeContextMenu",001001);DialogObject( dialog-handle, control-number, request-code, event-name, event-id ) ; BeforeContextMenu(x, y, Menu, Cancel) DialogObject(handle, "ComControl_1", 1,`DblClick`, 001002) ; csvInit() ; set various settings like colors and show row headings etc Return(-1) Break Case 11 ; Close oXL=0 Break Case 14 ;COM events If p4.identifier == 001001 rmenu() ; if you right click on cells or rows oXL.Selection.Copy() myClip_contents=ClipGet() Display(2,`Clipboard contents`, StrCat(`the clipboard contents:`,@CRLF, myClip_contents)) Break EndIf If p4.identifier == 001002 ; double click on a row oXL.Selection.Copy() myClip_contents=ClipGet() Display(2,`Clipboard contents`, StrCat(`the clipboard contents:`,@CRLF, myClip_contents)) Break EndIf Break EndSwitch ; switch msg Return -2 #EndSubRoutine ;==================================== #DefineSubRoutine rMenu() ;===============( not really needed if just selecting a row )============== aCopy = ArrDimension(2) aCopy[0] = "&Copy Highlighted Row" aCopy[1] = "something2" cmContextMenu = ArrDimension(1) cmContextMenu[0] = ObjectType("ARRAY", aCopy) p4.parameters(3).value.value = cmContextMenu Return(1) #EndSubRoutine ;====================================================== #DefineSubRoutine csvInit() ;============================================= ;oXL.TitleBar.Caption = "CSV Data" c = oXL.Constants oXL.DataType = "CSVURL" oXL.CSVURL = CSV_file oXL.Refresh() oXL.ActiveSheet.UsedRange.Interior.Color = "LightBlue" oXL.ActiveSheet.UsedRange.Font.Bold = @TRUE oXL.ActiveSheet.UsedRange.Columns.Autofit oXL.ActiveSheet.UsedRange.Borders.Weight = c.owcLineWeightMedium oXL.ActiveSheet.UsedRange.Borders.Color = "blue" ; color of the GRIDLINES oXL.ActiveSheet.Name = "CSV Data" ;/////////////////////////////////////////////////////////////////// ;add some special effects, so it resembles a grid [based on OWC 11] ;oXL.ActiveSheet.UsedRange.AutoFilter ; this shows a pulldown on each column heading oXL.ActiveWindow.DisplayRowHeadings = @TRUE oXL.ActiveWindow.DisplayColumnHeadings = @FALSE oXL.ActiveWindow.DisplayWorkbookTabs = @FALSE oXL.ActiveSheet.Range(`A2`).Select oXL.ActiveWindow.FreezePanes = @TRUE ;this allows you to scroll and keep headers in view oXL.DisplayToolBar = @FALSE ;//////////////////////////////////////////////////////////////////// ;we only need 1 Worksheet n=oXL.Sheets.Count For i = 2 To n oXL.Worksheets(2).Delete Next Return(1) #EndSubRoutine ;==================================================== #DefineFunction DisableMenuItem(dmiHandle, dmiItem) ; Disable menu items on windows. Possible ItemCode combinations are: ; 1 - Maximize ; 2 - Minimize ; 4 - Size ; NOTE Call DisableMenuItem before showing dialog. Otherwise, disabling the Size item means ; that crud gets left around the inside window border when another window overlaps your WinBatch box. dmiUser32 = StrCat(DirWindows(1),"User32.DLL") GWL_STYLE = -16 dmiButton = 0 If (dmiItem & 1) dmiButton = dmiButton | 65536 ; WS_MAXIMIZEBOX EndIf If (dmiItem & 2) dmiButton = dmiButton | 131072 ; WS_MINIMIZEBOX EndIf If (dmiItem & 4) dmiButton = dmiButton | 262144 ; WS_SIZEBOX (WS_THICKFRAME) EndIf dmiPrevStyle = DllCall(dmiUser32, long:"GetWindowLongA", long:dmiHandle, long:GWL_STYLE) dmiDesStyle = dmiPrevStyle & ~dmiButton DllCall(dmiUser32, long:"SetWindowLongA", long:dmiHandle, long:GWL_STYLE, long:dmiDesStyle) Return #EndFunction ;=================================== Return ;###############################################################
Article ID: W17781
Filename: Grid Sample - Office Web Component.txt
File Created: 2009:01:05:12:30:22
Last Updated: 2009:01:05:12:30:22