Author Topic: Check Box in ReportView  (Read 4472 times)

JTaylor

  • Pundit
  • *****
  • Posts: 919
    • Data & Stuff Inc.
Check Box in ReportView
« on: July 31, 2013, 11:40:01 am »
Is there a way to  programatically check a checkbox in the reportview?   If not, consider it  a feature request.

Assuming not since I've looked high and low and have not found anything can it be done via the API?  I've tried using IfICantByte's UDFs and can't make it work.  Maybe I'm passing the wrong parameters?  Here is one example of many things I've tried.

    LVSetCheckState(hListView,2,61440,61440)


Also, have tried adding this to my CommControl Extender but could never make it work and still can't.  Below is one of MANY attempts.  Suggestions?

  case 24:
    {
     
      LVITEM lvi;
      HWND ControlHandle = LongToHandle(lpvvArg[0].x);
      int indx           = lpvvArg[1].x - 1;
      int iState         = lpvvArg[2].x;
      int lv_resp        = 0;

      lvi.iSubItem   = 0;
      lvi.mask         = LVIF_STATE;
      lvi.stateMask = INDEXTOSTATEIMAGEMASK(iState);
      lvi.state         = LVIS_STATEIMAGEMASK;

      lv_resp = SendMessage(ControlHandle,LVM_SETITEMSTATE,indx,(LPARAM)&lvi);

      RETLONG(lv_resp);

    }

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Check Box in ReportView
« Reply #1 on: July 31, 2013, 12:00:12 pm »
Jim here is a sample that uses a dialog callback procedure to check a specific item in a ReportView using DialogControlSet:

Code: Winbatch
#DefineSubroutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   MSG_INIT=0                    ; The one-time initialization
   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton
   DC_CHECKBOX=1             ; CHECKBOX REPORTVIEW
   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
      Case MSG_INIT                                         ; Standard Initialization message
         DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
         Return(RET_DO_DEFAULT)

     Case MSG_BUTTONPUSHED
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        If MyDialog_Name == "PushButton_Select"
              itemname = DialogControlGet( MyDialog_Handle, "EditBox_1", 3 )  
              item = ArraySearch( arrArray, itemname)
              if item == -1
                 Pause('Notice','That item was not found')
              else
                 DialogControlSet( MyDialog_Handle, "ReportView_1", DC_CHECKBOX, arrArray[item,0] )
              endif
             Return(RET_DO_NOT_EXIT)
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ElseIf MyDialog_Name == "PushButton_Cancel"        ; Cancel
              Return(RET_DO_CANCEL)

        EndIf                                              ; MyDialog_Name
        Return(RET_DO_DEFAULT)

;     case MSG_RVITEMSELROW                                 ; ID "ReportView_1"  arrSafeArray
;        return(RET_DO_DEFAULT)

   EndSwitch                                                ; MyDialog_Message
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                                ; End of Dialog Callback MyDialogCallbackProc


filename = 'C:\TEMP\Data\CSV\Authors.csv'
arrArray = ArrayFileGetCSV(filename, 1)


MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`ReportView Check an Item`
MyDialogX=138
MyDialogY=141
MyDialogWidth=566
MyDialogHeight=243
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`191,181,066,012,PUSHBUTTON,"PushButton_Select",DEFAULT,"Check Item Name",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`365,223,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`187,063,174,100,REPORTVIEW,"ReportView_1",arrArray,DEFAULT,DEFAULT,30,142606336,DEFAULT,DEFAULT,"192|192|192"`
MyDialog004=`259,181,100,012,EDITBOX,"EditBox_1",ebVariable1,"Au_ID",DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")
Deana F.
Technical Support
Wilson WindowWare Inc.

JTaylor

  • Pundit
  • *****
  • Posts: 919
    • Data & Stuff Inc.
Re: Check Box in ReportView
« Reply #2 on: July 31, 2013, 01:00:58 pm »
Thanks.  Wish I'd asked sooner as I've spent several hours on this question.   Never crossed my mind that you would have used the checkbox control call for reportview changes. 

For my further edification...any suggestions on how to make it work via the LVM_SetItemState call in an Extender?

Thanks again.

Jim

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Check Box in ReportView
« Reply #3 on: July 31, 2013, 01:10:41 pm »
Thanks.  Wish I'd asked sooner as I've spent several hours on this question.   Never crossed my mind that you would have used the checkbox control call for reportview changes. 

For my further edification...any suggestions on how to make it work via the LVM_SetItemState call in an Extender?

Thanks again.

Jim

If you take a look at the DialogControlGet and DialogControlSet documentation you will see that request 1 applies to both the Checkbox and the Reportview control.

RequestApplicable ControlsSet-info
1CHECKBOX
REPORTVIEW
CHECKBOX: (i) 1 means check the box, 0 means unchecked the box

REPORTVIEW: (s) Checks or unchecks an item in a REPORTVIEW control. Use the function's set-info (fourth) parameter to indicate the first column text of the row to check or uncheck.  The text can be a delimited list to indicate which row should be checked or unchecked when multiple rows have the same first column text.

Not to mention the comment, in the code you posted, makes note of this as well:

Code: Winbatch
DC_CHECKBOX=1            
; CHECKBOX REPORTVIEW

I am not sure what if any message can be sent to accomplish this from your extender. Anyone else?
Deana F.
Technical Support
Wilson WindowWare Inc.

....IFICantBYTE

  • Full Member
  • ***
  • Posts: 120
Re: Check Box in ReportView
« Reply #4 on: August 03, 2013, 05:56:31 pm »
Hi Jim,
in the Tech Database, there is an example using the API via my UDF for querying the check state of an item in a Listview.
Search for "How to Query Checkbox in ListView Control".

The first bit was for a particular Listview control on windows XP, but once the window handle was obtained the same applies to any standard Listview.
That should help you along the way with your API extender.. also read the comments in my LVGetItemState and LVSetItemState UDFs.

Basically, the checkboxes are imagelist icons and you want to get or set the state of the item with the LVIS_STATEIMAGEMASK set to see what is returned or to pass the correct value to change it.  If 4096 decimal is returned (as part of the state bits set.. you need to OR or MASK things), then the standard tick is set.. ie the item is checked.. if it is not set, or you take it away, then the item will not show the tick icon.
Remember, if you are going to set an item's state, then it is a good idea to do a GET first, and then just alter the particular state value you want to with an OR, and set the new value back, otherwise you might change other state info and get unwanted results.

Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

JTaylor

  • Pundit
  • *****
  • Posts: 919
    • Data & Stuff Inc.
Re: Check Box in ReportView
« Reply #5 on: August 04, 2013, 08:48:15 pm »
I was able to query the State with no problem.   Just can't make the Set work.   I'll try what you have suggested with the Get and see what happens.  Thanks.


Jim