Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Grid: output row, disable rightclick, set checkbox state
#1
Question 1

I have a problem with the below code, which is a more simplified version of the "sample_Grid_images"
The problem lies with the line which contains the following code: out row => (when user LEFT clicks on checkbox or cell/row)
The first time you LEFT click on a cell/row, the output behaves exactly like expected.
After the second time it displays 3 values. (one of which beeing negative).
EXAMPLE: LEFT click on the cell called "checked" after that LEFT click on the cell called "two"
You should see 3 values.

This happens when the following Grid properties are un-set:

properties:
- User cannot edit/first column

properties >> More styles...:
- More space to click checkbox
- LVS_EX_AUTOSIZECOLUMS (Vista/7/8)

If I set the above Grid properties, the LEFT click behavior returns to normal.
The problem still remains when RIGHT clicking.
For example: RIGHT click on "checked" and while the right-click menu is displaying, RIGHT click on "two"
you will probably see 3 values in stead of one.


Function dd
Code:
Copy      Help
\Dialog_Editor

function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "4"
str qmg4x

qmg4x=
;one
;two
;<////2>checked

if(!ShowDialog("" &dd &controls _hwndqm)) ret

;BEGIN DIALOG
;0 "" 0x90C80A48 0x100 0 0 96 106 "QM_Grid"
;4 QM_Grid 0x56831041 0x0 18 14 64 78 "0x36,0,0,4,0x840[]A,,,"
;END DIALOG
;DIALOG EDITOR: "" 0x2040105 "*" "" "" ""

ret
;messages
DlgGrid g.Init(hDlg 3)
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret

;messages2
sel wParam
,case IDOK
ret 1


;messages3
NMHDR* nh=+lParam
NMITEMACTIVATE* na=+nh
sel nh.idFrom
,case 4
,sel nh.code
,,case LVN_ITEMCHANGED
,,int row isChecked
,,;if(g.RowIsCheckNotification(lParam row isChecked)) out "%schecked %i" iif(isChecked "" "un") row
,,g.RowIsCheckNotification(lParam row isChecked)
,,out row    ;; This outputs 3 values AFTER the first click (same for na.iItem)    
,,case NM_RCLICK            
,,,ret 1

Is there a way to have the right-click behaviour corrected?
With this I mean, having the right-click functionality on a grid but with normal row output behaviour?

Question 2
Is there a way to disable the RIGHT click on a cell/row in a grid?
I tried "NM_RCLICK" with "ret 1" but it still displays rightclick menu

Question 3
What is the correct syntax to SET and UNSET a checkbox state in a grid through a button?
If user clicks on button in a dialog, a check box in the grid gets checked / unchecked.
#2
1. It is normal. Listview control sends LVN_ITEMCHANGED when item state changes. For example, when you select other item, previous item state changes to 'not selected', and new item state to 'selected'. Even more messages may be sent, depending on event, style, etc. If want to use this message, need to look what is in NMLISTVIEW structure (lParam). Example in sample_Grid. More info in MSDN libarry.

2. case NM_RCLICK ret DT_Ret(hDlg 1)

3. DlgGrid g.Init(hDlg 4) ... g.RowCheck(row 1)
#3
Thank you very much!!!
#4
Sorry I have another question regarding the chekbox state in a grid.

In the first cell of my grid I also render a checkbox but in that same cell there is data the user can click on.
If the user clicks in the first Cell on a data item it execute something (with data item I mean cell-text).
If the user clicks in the first Cell on a checkbox it must only set the state of the checkbox.

The problem in my code is that when the user clicks on a checkbox it also executes the function which is attached to Cell one.
The below sample code should render a messagebox when the user clicks on the first cell-TEXT (NOT the checkbox).

Function grid_checkbox_dlg
Code:
Copy      Help
,,,case NM_CLICK
,,,,if(na.iSubItem=0)
(`i),,,,,
mes("Cell clicked!, NOT checkbox!") ;; Should only appear when cell-TEXT is clicked, NOT when checkbox is clicked.

To be more clear what I mean with the first cell, QM seems to render the first cell like this
Code:
Copy      Help
{ cell 0} { cell 1 } {.....etc...

Cell 0 has the checkbox AND celltext:
{ [X] [CELL TEXT] }
#5
Macro Macro1566
Code:
Copy      Help
\Dialog_Editor

str controls = "4"
str qmg4x

qmg4x=
;one
;two
;<////2>checked

if(!ShowDialog("" &sub.DlgProc &controls _hwndqm)) ret

;BEGIN DIALOG
;0 "" 0x90C80A48 0x100 0 0 96 106 "QM_Grid"
;4 QM_Grid 0x56831041 0x0 18 14 64 78 "0x36,0,0,4,0x840[]A,,,"
;END DIALOG
;DIALOG EDITOR: "" 0x2040105 "*" "" "" ""


#sub DlgProc
function# hDlg message wParam lParam

DlgGrid g.Init(hDlg 3)
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret

;messages2
sel wParam
,case IDOK
ret 1

;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 4
,sel nh.code
,,case LVN_ITEMCHANGED
,,int row isChecked
,,if g.RowIsCheckNotification(lParam row isChecked)
,,,out "row %i %schecked" row iif(isChecked "" "un")
,,else if g.RowIsSelectNotification(lParam row)
,,,out "row %i selected" row
Member function DlgGrid.RowIsSelectNotification
Code:
Copy      Help
function! lParam [int&row]

;Call this function when received LVN_ITEMCHANGED notification.
;If the message notifies about new item selected, returns 1, else returns 0.
;Error if the message is not LVN_ITEMCHANGED.

;lParam - lParam.
;row - receives 0-based index of the row.


NMLISTVIEW* nlv=+lParam
if(nlv.hdr.code!LVN_ITEMCHANGED) goto ge

if(&row) row=nlv.iItem

ret nlv.uNewState&LVIS_SELECTED and !(nlv.uOldState&LVIS_SELECTED)

err+
,;ge
,end "call this function only on LVN_ITEMCHANGED"
I'll add this function to System. Delete this version after upgrading QM.
#6
thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)