Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Grid within tab, left click = incorrect output.
#1
I have the below QM dialog it is a small QM dialog with 3 tabs, first tab contains a grid.
When a row is clicked I want to output the row number, but I often get -1 after some clicking (4 to 10 times) I finally get normal rownumber output.

I think it has something to do with code under label messages 3, the following are not declared correctly:
NMHDR* , GRID.QM_NMLVDATA* , NMLVDISPINFO* , NMLISTVIEW* , NMITEMACTIVATE*
(I think).

When I use grid without tab, I can get it to work.
But when grid is inside a tab construction I get incorrect output.

Function qm_extra_dlg
Code:
Copy      Help
ARRAY(str)- pleft
ARRAY(str)- pright
ARRAY(str)- lbdescript
str- appname=F"QM extra dlg"
str- tabnames=
;Main
;1
;2

str md=
;BEGIN MENU
;>Settings
;,Option1 :601
;,Option2 :602
;,Option3 :603     
;,<
;END MENU

str dd=
F
;BEGIN DIALOG
;0 "" 0x90CC0AC8 0x0 0 0 177 128 "{appname}"
;1002 Button 0x54032000 0x4 2 96 103 14 "<E#>  tot: ## / cur:##"
;1003 Edit 0x54030080 0x200 115 97 18 13 ""
;1004 Button 0x54032000 0x0 136 96 37 14 "A...  = [ ]"
;1006 Static 0x54000000 0x0 5 115 166 8 ""
;1001 QM_Grid 0x56031041 0x200 2 15 173 78 "0x0,0,0,0x0,0x0[]Title,19%,7,[]Left,40%,7,[]Right,40%,7,"
;1005 Button 0x54020007 0x0 2 108 172 18 ""
;3 SysTabControl32 0x54030040 0x0 -1 -1 182 13 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040308 "*" "0" "" ""


str controls = "1003 1001"
str e1003 qmg1001x
if(!ShowDialog(dd &sub.DlgProc &controls 0 0 0 0 0 0 0 0 md)) ret

#sub DlgProc
function# hDlg message wParam lParam
int+ qm_extra_dlg_id=hDlg
DlgGrid g.Init(hDlg 1001)
sel message
,case WM_INITDIALOG
,,str- tabnames
,,str- show_tabname
,,int- htb=id(3 hDlg)
,,int cnt
,,int i j k v
,,TCITEM ti.mask=WINAPI.TCIF_TEXT        
,,foreach _s tabnames
,,,ti.pszText=_s            
,,,SendMessage htb WINAPI.TCM_INSERTITEMA cnt &ti
,,,cnt=cnt+1
,,int- showtab_number=0
,,DT_Page hDlg showtab_number
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY    goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

;messages3
NMHDR* nh=+lParam
sel nh.code
,;; TAB CHANGE (left click other tab)
,case WINAPI.TCN_SELCHANGE
,,showtab_number=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)        
,,TabGetName(id(3 hDlg) showtab_number show_tabname)
,,DT_Page hDlg showtab_number
,,out F"(LEFT CLICK, SELECTION CHANGE) tabname: {show_tabname} / page: {showtab_number}"

,;; RIGHT CLICK TAB
,case NM_RCLICK        
,,POINT _m; xm _m ;;save mouse position in _m        
,,Acc a.FromMouse
,,TabGetName(id(3 hDlg) a.elem-1 show_tabname)
,,out F"(RIGHT CLICK) Tab nr: {a.elem-1} , Tab: {show_tabname}"

NMHDR* np=+lParam
GRID.QM_NMLVDATA* cd=+np
NMLVDISPINFO* di=+np
NMLISTVIEW* nlv=+np
NMITEMACTIVATE* nc=+np
sel nh.idFrom    
,case 1001
,,sel nh.code
,,,case NM_CLICK                 
,,,,out nc.iItem

Note: I have no idea what the pink declared NM... objects do, but I know they are related to processing the Grid/Tab/...
I just use it from helpfile/forum as template to build/modify.
#2
I cannot reproduce the problem.
-1 is when clicked not the first row.

I just see one bug - case NM_RCLICK is in wrong place, it catches NM_RCLICK of other controls too. All that sel block should be in the second sel block, under case idOfTabControl, like it is now used for the grid control.
#3
Ok! Thank you!


Forum Jump:


Users browsing this thread: 1 Guest(s)