Working With WIL Dialog's REPORTVIEW

Started by td, March 12, 2020, 10:34:20 AM

Previous topic - Next topic

td

Happened to be fiddling with WIL Dialog's REPORTVIEW control and need to set the text of a column added while the dialog was being displayed.  Reloading the entire contents or removing and adding rows was not an option so I created this simple UDF that sets the text of a single item.  Thought it might be a time-saver for the few users that like to fiddle with this sort of thing.

As per usual use at your own risk...
Code (winbatch) Select
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SetRvColText
;;
;; Changes the text of a single item or subitem of a
;; WIL dialog's REPORTVIEW control.
;;
;; _hWind - window handle to the control.
;; _nRow  - zero based row number of item or subitem.
;; _nCol  - zero based column number of item or subitem.
;; _strText - string of text to set.
;;
;; Retuns @TRUE on success: otherwise, @FALSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#defineFunction SetRvColText(_hWnd, _nRow, _nCol, _strText)
   ;; Comment out next line when testing or debugging.
   IntControl(73, 1,0,0,0)
   bResult      = 0
   hlvItem      = 0
   LVM_SETITEMW = 4096+76
   LVIF_TEXT    = 1
   LVITEMW      = $"
    UINT::mask;
    int::iItem;
    int::iSubItem;
    UINT::state;
    UINT::stateMask;
    LPWSTR::pszText;
    int::cchTextMax;
    int::iImage;
    LPARAM::lParam;
    int::iIndent;
    int::iGroupId;
    UINT::cColumns;
    UINT*::puColumns;
    int*::piColFmt;
    int::iGroup;
  $"
   
  hlvItem = DllStructAlloc(LVITEMW)
  DllStructPoke( hlvItem, "mask",LVIF_TEXT)
  DllStructPoke( hlvItem, "iItem",_nRow)
  DllStructPoke( hlvItem, "iSubItem",_nCol)
  DllStructPoke( hlvItem, "pszText", _strText)
  bResult = DllCall('user32.dll',long:'SendMessageW', long:_hwnd, long:LVM_SETITEMW, long:0, lpstruct:hlvitem)

:WBERRORHANDLER
  if hlvItem then DllStructFree(hlvItem)
  return bResult
#EndFunction
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor


JTaylor

Any plans to add this type of functionality?   Happy to send you my C++ code for all the things I did in my Extender.   Although I am sure you can do it better and probably faster than sorting through my mess.

Here are  the things I implemented if looking for ideas.

lvSetImageList(ControlHandle)
lvDeleteItem(ControlHandle,Index,Scope)
lvGetItemCheck(ControlHandle,Index)
lvGetItemCount(ControlHandle)
lvGetItemCountSel(ControlHandle)
lvGetItemState(ControlHandle,Index,State)
lvGetItemText(ControlHandle,Index,SubIndex)
lvInsertItem(ControlHandle,Index,Value)
lvInsertColumn(ControlHandle,Index,Heading)
lvScrollTo(ControlHandle,Index,Offset)
lvSetItemText(ControlHandle,Index,SubIndex,Value)
lvSetBkImage(ControlHandle,x-pos,y-pos,image,style)
lvSetColumnWidth(ControlHandle,Index,Width)
lvSetColumnFill(ControlHandle,Index,Value)
lvSetColumnFillSeq(ControlHandle,Index,StartValue,Increment_By)
lvSetImageList(ControlHandle,Img_List)
lvSetItemImage(ControlHandle,Index,SubIndex,ImageIndex)
lvSetItemState(ControlHandle,Index,Mask,State)

Jim

td

To be honest the motivation for posting the script was as much about highlighting underutilized WinBatch features as anything else.  I just happened to need that bit of functionality for a new test I was adding to a test suite.   The list view control API is fairly straight forward and relatively easy to script with a few DllCalls.  The biggest problem, at least for me, is remembering all the manifest constants for messages and other stuff.  A quick trip to either the MSFT online version of the common control header file or the same header file on a local hard drive usually takes care of that.       
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

Just one little data point: I've used these of Jim's routines with good success:
  lvSetImageList
  lvSetItemImage
  lvSetItem
  lvInsertItem

The image thing is fiddly as hell, but it's enough that I can put a red/yellow/green traffic light on each line of the report control for a HUGE increase in at-a-glance cognition.

$0.03
-Kirby

The mind is everything; What you think, you become.

JTaylor

Can you tell if there is anything I can do to improve it.  What gives you problems?

Hopefully I haven't hijacked Tony's thread  :(      Mostly hoped they might incorporate some of these functions because a number of people want to be able to do this type of thing and having it native would be nice.

Jim

Quote from: kdmoyers on March 12, 2020, 03:23:26 PM
Just one little data point: I've used these of Jim's routines with good success:
  lvSetImageList
  lvSetItemImage
  lvSetItem
  lvInsertItem

The image thing is fiddly as hell, but it's enough that I can put a red/yellow/green traffic light on each line of the report control for a HUGE increase in at-a-glance cognition.

$0.03
-Kirby

kdmoyers

QuoteWhat gives you problems?
Well, it's been quite a while since I did it.  The issues are not problems with the lcmctrl_lv_44i library, nor with winbatch, but rather the list view controls as windows provides them. 

I remember 2 things:

[1] I was hard to figure out exactly what I was to do to arrange the images and get them loaded up.  That might be solved by some good winbatch-centric doc on the procedure.  I guess the burden of writing that could fall to me was well, since I have in fact made it work.  So I'm not throwing stones.

[2] the individual images are stacked together in one master image, and editing that master image is a royal pain.  Maybe there could be an ancillary program that compiled the master from the individuals, and reported size and dimension errors to the user, and maybe generate some constants for use in the winbatch source code.  Once again, a person like me might use imagemagik to write this, so I'm not throwing stones.

-Kirby
The mind is everything; What you think, you become.

JTaylor

Okay.  Will take a look and see if there is a better way.   Maybe there is a way to load individual images or, as you note, provide some better instructions on how to make this work.   Thanks.

Jim

....IFICantBYTE

Hi guys, remember me? .. I did a lot of listview (reportview) stuff and image list stuff with dll calls 15+ years ago.. you might find some of it in the tech database and it might give you some ideas or help. I think I had almost exactly what Tony just made too, albeit without the new struct commands etc.
I haven't used WB for about 3 years now (different job) in case you were wondering, but I still look in to the forum here sometimes.
Cheers.
Regards,
....IFICantBYTE

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

JTaylor


td

Quote from: ....IFICantBYTE on March 13, 2020, 09:09:14 AM
Hi guys, remember me? .. I did a lot of listview (reportview) stuff and image list stuff with dll calls 15+ years ago.. you might find some of it in the tech database and it might give you some ideas or help. I think I had almost exactly what Tony just made too, albeit without the new struct commands etc.
I haven't used WB for about 3 years now (different job) in case you were wondering, but I still look in to the forum here sometimes.
Cheers.

Good to hear from you.  Here's  a link to your script:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UDF~-~UDS~Library/Dialog~Boxes+ListView~UDFs~-~IFICantBYTE.txt

And here's Guido's take:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UDF~-~UDS~Library/Dialog~Boxes+ListView~UDFs~by~Guido.txt
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade