Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QMGrid questions
#1
Hello Gintaras,

I am trying to make a display output within a dialog to make it easier to read the items within a selected row in a qmgrid. As the user arrows up and down through the grid, I would like to somehow to get the content of the selected row. I can get the content out of a specific row number, I just don't know how to trigger it by moving up and down with the arrows (or a mouse click on a non-contiguous row).

Also is there a way to lock a specific row from being deleted by the right click menu?

Thanks so much!,

Stuart
#2
QM_Grid control inherits almost everything from SysListView32 control. When you select an item in list view control, it sends several notification messages in WM_NOTIFY message. Useful can be LVN_ITEMCHANGED, NM_CLICK, LVN_KEYDOWN. Documented in MSDN.

Example:
Function gridNotify
Code:
Copy      Help
sel nh.code ;;nh is NMHDR*, which is lParam of WM_NOTIFY message
,case LVN_ITEMCHANGED
,NMLISTVIEW* nlv=+nh
,if(nlv.iItem<0 or nlv.uNewState&LVIS_SELECTED=0) ret
,out nlv.iItem ;;selected listview item index

---------------------------
By default all rows can be deleted.
If QG_NOAUTOADD style used (see LVM_QG_SETSTYLE message), all rows cannot be deleted.
A single row cannot be protected from deleting.
#3
So quick and so helpful!!!
Thanks so much!
Stuart
#4
I have only partial understanding of the syntax with NMLISTVIEW, etc, as in your example, so sorry if I am asking questioni which I should be able to figure out.
It seems that when I use example with LVN_ITEMCHANGED, it runs many times though the case.
Perhaps, I am trying to do something simpler. Just get row number of row clicked in QM Grid. I tried to do this with NM_Click which only was triggered once by selected on a row but I couldn't get the row number out.

I hope that was not too poorly explained. Thanks for any help!

Stuart
#5
From the original question in this post (how to fill in regular dialog fields from a selected from in a qmgrid in that dialog), I have been successful with text fields but am having trouble with checking and unchecking checkboxes based on the contents of a specific field in the selected row of the qmgrid.


The code I have will check a checkbox if the field is positive but for some reason gives a Can Not Find Item error when it has to uncheck the box. Very strange.


In the gridNotify dialog for the dialog with the qmGrid, I have the following code

Macro
Code:
Copy      Help
str QmGridFieldResult
LvGetItemText QmGridHwnd RowNumber 13 QmGridFieldResult;err ;; get whether column 13 in the selected row is empty or has a "*"
if QmGridFieldResult="*";; checkbox should be checked
,Acc Checkbox=acc("Sample Checkbox" "CHECKBUTTON" DlgHwnd "Button" "" 0x1000)
,int CheckboxState=Checkbox.State()
,if(CheckboxState&STATE_SYSTEM_CHECKED);; leave checked if already checked or check if unchecked
,,out "already checked";; do nothing
,else
,,Checkbox.Mouse(1);; check checkbox
else
,out "not checked";; checkbox should be unchecked or left unchecked
,Checkbox=acc("Sample Checkbox" "CHECKBUTTON" DlgHwnd "Button" "" 0x1000)
,CheckboxState=Checkbox.State()
,if(CheckboxState&STATE_SYSTEM_CHECKED);;if checked, then uncheck it
,,Checkbox.Mouse(1)

Note that this is triggered by a

Function AttendingComments_gridNotify
Code:
Copy      Help
,case LVN_ITEMCHANGED
,,NMLISTVIEW* nlv=+nh
,,if(nlv.iItem<0 or nlv.uNewState&LVIS_SELECTED=0) ret
,,int RowNumber =  nlv.iItem ;;selected listview item index

Any thoughts or advice would be great.
Thanks so much!

Stuart
#6
To get selected listview control items you can use function LvGetSelectedItems from forum -> resources -> first topic. On NM_CLICK is ok but selected item also can be changed with keyboard. Also can be used SetTimer/WM_TIMER.

------------

Why acc, not but?
#7
Quote:Why acc, not but?

An incredibly good question!!!!! :oops:

Never really used that dialog or function - I geuss I didn't need it until now!!!


All that code (multiplied by a large number of checkboxes now is just:

Macro
Code:
Copy      Help
str SampleField
LvGetItemText QmGridHwnd RowNumber 20 SampleField;err
if SampleField ="*"
,but% id(17 DlgHwnd)
else if empty(SampleField)
,if(but(id(17 DlgHwnd)))
,,but- id(17 DlgHwnd)

works great!!!!



Love it! Thanks for making QM so awesome!
Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)