Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image grid and sqlite
#1
Hello,

I'm new with Quick Macros, I am interested to use images in a grid with sqlite.

I am using sample_Grid_images and sample_Grid_Sqlite to do this:

Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam

Shows how to use grid control with Sqlite database.

if(hDlg) goto messages

str- t_dbfile="$desktop$\lp1.db3"
Sqlite- t_db
________________________________________________

if !FileExists(t_dbfile) ;;create database for testing
    Sqlite CopyNote.Open(t_dbfile)
    str sql=
     CREATE TABLE table1 (ID PRIMARY KEY, TYPE, INFO);
     INSERT INTO table1 VALUES
     (<//1>,'LOGIN','Extra'),
     (<//2>,'DIVERS','that work'),
     (<//3>,'DIVERS','Good !');
    CopyNote.Exec(sql)
    CopyNote.Close
________________________________________________


if(!ShowDialog("" &Function1)) ret

BEGIN DIALOG
0 "" 0x90C80AC8 0x0 0 0 338 174 "Dialog"
3 QM_Grid 0x54030000 0x0 2 6 334 126 ""
1 Button 0x54030001 0x4 2 156 48 14 "OK"
2 Button 0x54030000 0x4 54 156 48 14 "Cancel"
4 Static 0x54000000 0x0 176 156 160 13 "Click a cell, add text. OK will save the changes."
END DIALOG
DIALOG EDITOR: "" 0x2040003 "" "" "" ""

ret
messages
DlgGrid g.Init(hDlg 3)

sel message
    case WM_INITDIALOG
    
     add columns to the grid control, if not added in dialog editor
    g.ColumnsAdd("ID,100,,0[]TYPE,100,1,[]INFO,,,0" 1)
     open database and add table1 to the grid control
    t_db.Open(t_dbfile)
    t_db.ToQmGrid(g "SELECT * FROM table1")
    
    __ImageList- il.Load("$qm$\il_dlg.bmp")
    il.SetOverlayImages("0 1")
    g.SetImagelist(il il)
    
    case WM_DESTROY
    case WM_COMMAND goto messages2
    case WM_NOTIFY goto messages3
ret
messages2
sel wParam
    case IDOK
     save changes
    t_db.FromQmGrid(g "table1" 2)
ret 1

messages3

But I don't see images in my first column, juste <//1>...<//2>...

How to do that ?

Sincerely,

Laurent
#2
Function sample_Grid_images_sqlite
Code:
Copy      Help
\Dialog_Editor

;Shows how to use icons and Sqlite with QM grid control.
;Columns and styles are defined in dialog editor.
;More info in QM Help.

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

str- t_dbfile="$desktop$\test84.db3"
Sqlite- t_db

if !FileExists(t_dbfile) ;;create database for testing
,Sqlite dbTest.Open(t_dbfile)
,str sql=
,;CREATE TABLE table1 (A PRIMARY KEY, B,C);
,;INSERT INTO table1 VALUES
,;('<//2>a1','b1','c1'),
,;('<//4>a2','b2','c2');
,dbTest.Exec(sql)
,dbTest.Close


str controls = "3"
str qmg3x
if(!ShowDialog("" &sample_Grid_images_sqlite &controls _hwndqm)) ret
out qmg3x

;BEGIN DIALOG
;0 "" 0x90C80A48 0x100 0 0 281 159 "QM_Grid"
;3 QM_Grid 0x56831041 0x0 0 0 206 134 "0x7,0,0,0[]A,50%,,[]B,20%,,[]C,20%,1,[]"
;1 Button 0x54030001 0x4 2 142 48 14 "OK"
;2 Button 0x54030000 0x4 52 142 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030203 "*" "" ""

ret
;messages
DlgGrid g.Init(hDlg 3)
sel message
,case WM_INITDIALOG
,;set imagelist for the grid control
,__ImageList- il.Load("$qm$\il_dlg.bmp")
,g.SetImagelist(il)
,
,;open database and add table1 to the grid control
,t_db.Open(t_dbfile)
,t_db.ToQmGrid(g "SELECT * FROM table1")
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,;save changes
,t_db.FromQmGrid(g "table1")
ret 1

;messages3
;NMHDR* nh=+lParam
;sel nh.idFrom
,;case 3
,;sel nh.code
,,;case LVN_ITEMCHANGED


Forum Jump:


Users browsing this thread: 1 Guest(s)