Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to apply #sub to diffrent Grid objects
#1
i have 2 Grids objects in Dialog box. i want to write a sub-function that applies to both Grids but dont want to write the function 2x (g.CellSet then g2.CellSet)
i want to create the instructions once and do a IF statement that tells the function which grid to activate as the Object then apply function to that specific Grid

If sub.test pass a 1 then create grid object 1 in sub-function and apply to grid 1, if 2 create grid 2 and apply to grid#2...  Or whats the right way?
sub is in Case 4 and sub below it. Hope i made sense
 
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;3 QM_Grid 0x56031041 0x200 88 4 96 48 "0[]A[]B"
;4 Button 0x54032000 0x0 8 12 48 14 "Button"
;5 Button 0x54012003 0x0 12 40 48 10 "Check"
;6 QM_Grid 0x56031041 0x200 88 60 96 48 "0[]A[]B"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 5 6"
str qmg3 c5Che qmg6
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
#region ...
ICsv csv._create
DlgGrid g.Init(hDlg 3)
DlgGrid g2.Init(hDlg 6)

sel message
,case WM_INITDIALOG
,str s =""
,csv.FromString(s)
,csv.ToQmGrid(g)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL

,case 4
,sub.test2(1 hDlg message wParam lParam)
ret 1

#sub test2
function grid hDlg message wParam lParam

if(grid = 1)
,DlgGrid g.Init(hDlg 3) ;; 1st grid
else if(grid = 2)
,DlgGrid g.Init(hDlg 6) ;; 2nd grid

int rct = g.RowsCountGet
g.CellSet(rct 1 "yes")
#2
Function Function11
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;3 QM_Grid 0x56031041 0x200 88 4 96 48 "0[]A[]B"
;4 Button 0x54032000 0x0 8 12 48 14 "Button"
;5 Button 0x54012003 0x0 12 40 48 10 "Check"
;6 QM_Grid 0x56031041 0x200 88 60 96 48 "0[]A[]B"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 5 6"
str qmg3 c5Che qmg6
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
#region ...
ICsv csv._create
DlgGrid g.Init(hDlg 3)
DlgGrid g2.Init(hDlg 6)

sel message
,case WM_INITDIALOG
,str s =""
,csv.FromString(s)
,csv.ToQmGrid(g)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL

,case 4
,out sub.test2(6 hDlg)
,out sub.test2(3 hDlg)
ret 1

#sub test2
function controlId hDlg
DlgGrid grid

grid.Init(hDlg controlId)

ret grid.CellSet(grid.RowsCountGet 1 "yes")
Is this what your looking for?
#3
works perfectly. thanks for the help


Forum Jump:


Users browsing this thread: 1 Guest(s)