WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

COMCONTROL
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Data Grid In Dialog

 Keywords: Dialog grid control 

Question:

I'm writing a program to collect data from a user computer and display it in a dialog box. I was thinking of a two column grid, but I don't have a clue how to do that...or am I barking up the wrong tree all together?

If you're interested the more detailed version is this:

I want to inventory a machine an report the following:

Scanner Version: 2.1.1.5555
Scan Date (Local): 01:08:21 03-08-2008
Scan Date (Server): 01:08:21 03-08-2008
...and whatever else I might decide I need.

but I don't want to create a bunch of individual boxes for each bit of data I decide to collect.

Answer:

There are several ways to display data in a grid on an WIL Dialog. One possibility is using a 'free' or purchased Grid ActiveX control. Another approach might be to use and html table with the 'MSHTML:' moniker. The later can be relatively easy, if you are at all comfortable with html.

Here is a link to some code the uses the Microsoft Hierarchical Grid Control (mshflxgd.ocx): Basic Grid Tutorial [ W16926 ]


#DefineSubRoutine Main(Proc_Handle,Proc_Message,Proc_ID, Proc_EventInfo, reserved)
   ;DialogprocOptions Constants
   MSG_INIT = 0                ; The one-time initialization
   MSG_TIMER = 1                     ; Timer event
   MSG_BUTTONPUSHED = 2        ; Button press.
   ; New options for DialogObject
   DLGOBJECT_ADDEVENT   = 1 ;DialogObject add event
   DLGOBJECT_REMOVEVENT = 2 ;DialogObject remove event
   DLGOBJECT_GETOBJECT  = 3 ;DialogObject get reference to object
   DLGOBJECT_GETPICTURE = 4 ;DialogObject get a picture object
   ; New callback message
   MSG_COMEVENT         = 14 ;COM control event fired
   ;
   Switch Proc_Message
   Case MSG_INIT
      spreadsheet = DialogObject(Proc_Handle, 003, DLGOBJECT_GETOBJECT)
      ForEach col In spreadsheet.ActiveSheet.VisibleRange.Columns
         col.ColumnWidth = 77
      Next
      For row = 1 To 10
         If row mod 2 == 0
            davalue = Random(99)+1
         Else
            davalue = "This is Text"
         EndIf
         For col = 1 To 5
            spreadsheet.cells(row,col).value = davalue
         Next
      Next
;      DialogProcOptions(Proc_Handle, 1, 500)   ; setup a MSG_TIMER
      Return(-1)
      Break
   Case MSG_BUTTONPUSHED
;         blank...
      Break
   Case MSG_COMEVENT
      ; Test in case more events or COM controls are added later
      If Proc_EventInfo.identifier == 1 && Proc_ID  == 003
         ; Get event source object associated with the event
         Element = document.parentWindow.event.srcElement
      EndIf
      Break
   EndSwitch       ; Proc_Message
   Return(-1)      ; Do default processing
#EndSubRoutine   ; End of Dialog Callback ExamProc

;\OWC.Spreadsheet
;\OWC.Spreadsheet.9
;\OWC10.Spreadsheet
;\OWC10.Spreadsheet.10
;\OWC11.Spreadsheet
;\OWC11.Spreadsheet.11

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`MSHTML Test`
MyDialogX= -1
MyDialogY= -1
MyDialogWidth=247
MyDialogHeight=289
MyDialogNumControls=003
MyDialogProcedure=`Main`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`

MyDialog001=`011,267,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`193,267,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`005,009,232,252,COMCONTROL,DEFAULT,"OWC.Spreadsheet",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Article ID:   W17393
File Created: 2014:07:18:09:50:36
Last Updated: 2014:07:18:09:50:36