Author Topic: Mulity choice dialog checkbox table  (Read 2621 times)

erezpaz

  • Newbie
  • *
  • Posts: 35
Mulity choice dialog checkbox table
« on: April 21, 2015, 02:24:16 am »
Hi,

I want to build a dynamic dialog that got multi choice checkbox that limited in window size so user can scroll and also see it as table so there is more information presented related.

Here is an example:



appreciate any help.

Thanks
Erez

td

  • Tech Support
  • *****
  • Posts: 2023
    • WinBatch
Re: Mulity choice dialog checkbox table
« Reply #1 on: April 21, 2015, 06:39:20 am »
You could use a REPORTVIEW control with the check box style.  The one limitation is that the check boxes are restricted to the first column. 
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams


erezpaz

  • Newbie
  • *
  • Posts: 35
Re: Mulity choice dialog checkbox table
« Reply #2 on: April 21, 2015, 07:57:26 am »

Do you have any guide for it or written document or code example?

Thanks

td

  • Tech Support
  • *****
  • Posts: 2023
    • WinBatch
Re: Mulity choice dialog checkbox table
« Reply #3 on: April 21, 2015, 08:50:45 am »
An example and a full description of the control can be found in the WIL Consolidated Help file.  Examples can also be found on the Tech Database site.  You can go directly to the Tech Database by clicking the menu with that name near the top of this forum page.
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams


erezpaz

  • Newbie
  • *
  • Posts: 35
Re: Mulity choice dialog checkbox table
« Reply #4 on: May 20, 2015, 02:40:31 am »
Hi,

REPORTVIEW work fine but I get strange results. I need multi choice table so I use the "Display checkbox" option.
The issue is that if I choose the items with checkbox the result doesn't include them. If I just mark them with CTRL they do...

What going on?

Thanks

td

  • Tech Support
  • *****
  • Posts: 2023
    • WinBatch
Re: Mulity choice dialog checkbox table
« Reply #5 on: May 20, 2015, 08:51:55 am »
What 'result' are you referring to?  How are you determining which items in the control are checked?  Are you using WIL Dialog callback procedure with your dialog? The REPORTVIEW control only places selected rows in the control's variable on dialog exit.  It does not place checked rows in the array, it that is what you mean by 'result'. 
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams


erezpaz

  • Newbie
  • *
  • Posts: 35
Re: Mulity choice dialog checkbox table
« Reply #6 on: May 20, 2015, 11:59:24 am »
I mean that the rows I see in the array the dialog produce are the one I mark but not the one with the checkbox checked.

td

  • Tech Support
  • *****
  • Posts: 2023
    • WinBatch
Re: Mulity choice dialog checkbox table
« Reply #7 on: May 20, 2015, 01:22:33 pm »
Assuming that that you are referring to the contents of a REPORTVIEW control's variable after a the 'Dialog' function returns then as previously mentioned, only selected rows are place in that array variable.  This is expected behavior. A checked item is not the same thing as a selected item.

You will need to  create your own variable of checked items if having a variable of check rows is your goal.  In order to do that you will need to create a dialog callback procedure and handle some combination of  the @deRviCheck (20), @dePbPush (2), and/or @deClose (11) events in the callback.

Here is a bare bones example created using the Dialog Editor and the WinBatch Studio dialog callback generator.  It required all of 7 line beyond what was generated.

Code: Winbatch
; Initialize.
aChecked    = 0
rvVariable1 = Arrayize("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z", ',')

; Dialog Callback subroutine.
#DefineSubroutine RvClickExProc(RvClickEx_Handle,RvClickEx_Event,RvClickEx_Name,RvClickEx_EventInfo,RvClickEx_ChangeInfo)
switch RvClickEx_Event                                   ; Switch based on Dialog Message type
   case @deInit                                          ; Standard Initialization message
      DialogProcOptions(RvClickEx_Handle,@dePbPush,@TRUE)
      return(@retDefault)

   case @dePbPush
      if RvClickEx_Name == "PushButton_OK"               ; O
         aChecked = DialogControlGet( RvClickEx_Handle, "ReportView_1",@dcGetChecked )
         return(@retDefault)
;     elseif RvClickEx_Name == "PushButton_Cancel"       ; Cancel
;        return(@retDefault)
      endif                                              ; RvClickEx_Name
      return(@retDefault)

   endswitch                                                ; RvClickEx_Event
   return(@retDefault)
#EndSubroutine                                              ; End of Dialog Callback RvClickExCallbackProc

RvClickExFormat=`WWWDLGED,6.2`

RvClickExCaption=`Reportview Click Example`
RvClickExX=081
RvClickExY=099
RvClickExWidth=304
RvClickExHeight=166
RvClickExNumControls=003
RvClickExProcedure=`RvClickExProc`
RvClickExFont=`DEFAULT`
RvClickExTextColor=`DEFAULT`
RvClickExBackground=`DEFAULT,DEFAULT`
RvClickExConfig=0

RvClickEx001=`077,145,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
RvClickEx002=`185,145,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
RvClickEx003=`011,023,282,110,REPORTVIEW,"ReportView_1",rvVariable1,DEFAULT,DEFAULT,30,@csFullSel|@csNoHeader|@csColCheck,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("RvClickEx")

; Test results.
if VarType(aChecked) == 256 then strChecked = ArrayItemize(aChecked, @CR)
else strChecked = "Non checked"

Message("Checked Rows", strChecked)
 
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams


erezpaz

  • Newbie
  • *
  • Posts: 35
Re: Mulity choice dialog checkbox table
« Reply #8 on: May 23, 2015, 06:55:17 am »
Hi,

That is exactly what I needed. Thanks!  :)

Now I need to do another thing: after selecting the lines, the script will save them to file.

Next time he run the script I want to read a file and show the same list but with the lines he selected last time.

The question is: how to show Reportveiw with preselected lines (with the check box marked)?

Thanks!
Erez

erezpaz

  • Newbie
  • *
  • Posts: 35
Re: Mulity choice dialog checkbox table
« Reply #9 on: May 24, 2015, 11:46:14 am »
Hi,

I found out how to preselect a check box and mark it but I don't know how to compare between two Arrays. Here is an example of two arrays that I want to compare and mark any lines that first character is equal in both. Lets say that rvVariable2[0,0] = rvVariable1[0,0] then I want to mark the check box up front in the REPORTVIEW in the dialog.

Thanks
Code: [Select]
rvVariable2 = ArrDimension (3,3)
rvVariable2[0,0] = "3"
rvVariable2[0,1] = "3"
rvVariable2[0,2] = "4"
rvVariable2[1,0] = "2"
rvVariable2[1,1] = "3"
rvVariable2[1,2] = "4"
rvVariable2[2,0] = "3"
rvVariable2[2,1] = "4"
rvVariable2[2,2] = "4"

rvVariable1 = ArrDimension (3,3)
rvVariable1[0,0] = "2"
rvVariable1[0,1] = "3"
rvVariable1[0,2] = "4"
rvVariable1[1,0] = "2"
rvVariable1[1,1] = "3"
rvVariable1[1,2] = "4"
rvVariable1[2,0] = "3"
rvVariable1[2,1] = "4"
rvVariable1[2,2] = "4"

; Dialog Callback subroutine.
#DefineSubroutine RvClickExProc(RvClickEx_Handle,RvClickEx_Event,RvClickEx_Name,RvClickEx_EventInfo,RvClickEx_ChangeInfo)
switch RvClickEx_Event                                   ; Switch based on Dialog Message type
   case @deInit                                          ; Standard Initialization message
      DialogProcOptions(RvClickEx_Handle,@dePbPush,@TRUE)
i=0
x=0
rvVariable1 = ObjectType ("ARRAY", rvVariable1)

;foreach test in rvVariable2
; if  test == rvVariable1[x,i] then DialogControlSet( RvClickEx_Handle, "ReportView_1",@dcCheck,rvVariable1[x,i])
i=i+1
;next
      return(@retDefault)

   case @dePbPush
      if RvClickEx_Name == "PushButton_OK"               ; O
         aChecked = DialogControlGet( RvClickEx_Handle, "ReportView_1",@dcGetChecked )
         return(@retDefault)
;     elseif RvClickEx_Name == "PushButton_Cancel"       ; Cancel
;        return(@retDefault)
      endif                                              ; RvClickEx_Name
      return(@retDefault)

   endswitch                                                ; RvClickEx_Event
   return(@retDefault)
#EndSubroutine                                              ; End of Dialog Callback RvClickExCallbackProc

RvClickExFormat=`WWWDLGED,6.2`

RvClickExCaption=`Reportview Click Example`
RvClickExX=081
RvClickExY=099
RvClickExWidth=304
RvClickExHeight=166
RvClickExNumControls=003
RvClickExProcedure=`RvClickExProc`
RvClickExFont=`DEFAULT`
RvClickExTextColor=`DEFAULT`
RvClickExBackground=`DEFAULT,DEFAULT`
RvClickExConfig=0

RvClickEx001=`077,145,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
RvClickEx002=`185,145,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
RvClickEx003=`011,023,282,110,REPORTVIEW,"ReportView_1",rvVariable1,DEFAULT,DEFAULT,30,@csFullSel|@csNoHeader|@csColCheck,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("RvClickEx")

rvVariable1 = ObjectType ("ARRAY", rvVariable1)

exit