I'm creating a simple dictionary program and made most of it. I'm fetching the words and their meanings from a access database and I wonder if it would be faster if I use a simple structured file, from which I will fetch the data. Or even better - use Tsunami Record Manager? Which of these ways is best according the speed? Or is there another better?


/siddhartha
Posted on 2004-09-19 15:42:12 by siddhartha
So, anybody with opinion on the topic? I don't think that no one of you has ever played with databases?!


/siddhartha
Posted on 2004-09-24 09:12:25 by siddhartha
I love database programming. I always use access. I think the best way is to use ADO, but if you can't/don't want you can use ODBC. SQL is very simple. Creating a structured file would be difficoult and useless.

You don't see speed differences between differen solutions, because your program doesn't stress the database
Posted on 2004-09-24 09:18:55 by greenant
So, I even don't know what ADO is. I use ODBC with Access and it works pretty well, but when testing it on some slower machines it turned out that it takes some time until all the words are populated into the listbox. I saw many dictionaries using a structured file and they don't have problems on slower computers. So my conclusion is that database is not the best choice for this kind of projects. I may be wrong and most probable is that I don't implement some parts of my program in the best way... So, some explanation about ADO and the other stuff is welcome! Thanks for the reply, greenant!


/siddhartha
Posted on 2004-09-24 09:31:57 by siddhartha
the bottleneck is the listbox and not the database.
I'm programming a software, Gremaf, that has a listview. It reads from an access database and fill the listview. It has 16 columns and about 5500 rows. The first version used a normal listview, but now I use a VirtualListview and now the startup of the program is faster and column sorting is immediate (on my Duron 800).
Posted on 2004-09-24 09:39:04 by greenant
OK. So, you use a listview? Tell me if I'm getting you wrong, but you advise me to use listview instead of listbox? And another thing - initially I tried with listview, but I didn't manage to get it work like a listbox - I mean when you select an item in the listbox it selects not only the text but all the visible area of the row. Got it? So this is the reason why I use listbox. If there's a way to set listview's behaviour in to a similar way, then it's OK for me to use listview. Any link to get started with ADO? Thanks again!


/siddhartha
Posted on 2004-09-24 09:59:20 by siddhartha
I'm not advising you to use a listview, because I don't know exactly what you are doing.

ADO is a COM object and it is not so simple as other COM objects, like MsAgent. I use ADO only with C++ and not asm. The best ADO refercence is the MSDN.

Can you send me your exe file, so I can understand exacly what you are doing?
Posted on 2004-09-24 10:05:15 by greenant
I case you want to use listviews... use the LVS_EX_FULLROWSELECT extended listview style. And if you want fast speed, use virtual listviews - it's pretty easy.
Posted on 2004-09-24 10:06:16 by f0dder
Thanks, f0dder! That was the thing I was looking for! Some explanations for the 'virtual listview'? What does it mean and how do I use it? Thanks for the patience!


/siddhartha
Posted on 2004-09-24 10:45:39 by siddhartha
Virtual Listview means that, rather than you filling the listview with items, windows will send a notification message when it needs an item... it also sends some "cache hints" that you could use if it's slow to fetch an item from your database. Look it up in PlatformSDK - it's easy to use.
Posted on 2004-09-24 10:48:40 by f0dder
I have a Virtual ListView with a stable sort algo (merge sort), and a linked list to retrieve data from the database and store it in an array.
If you want you can look at the code
http://greenant.altervista.org -> Gremaf
Posted on 2004-09-24 10:52:19 by greenant
OK. I don't have the PSDK on this computer, but when I get home after a while I'll take a look at it. Only one more question - does virtual listview mean that I won't be able to just drop the listview control on a dialog inside RadASM and I must create it with CreateWindow(Ex)? Thanks for the fast replies, f0dder!



/siddhartha
Posted on 2004-09-24 10:53:21 by siddhartha
The only difference is the LVS_OWNERDATA style.
Posted on 2004-09-24 10:55:23 by greenant
Humm, I think you can set the type at runtime? If not, it should be possible to change the flags somewhere in RadASM - or bug ketilo until he adds that feature ;). If you don't have PlatformSDK where you are, use http://msdn.microsoft.com ...
Posted on 2004-09-24 10:55:27 by f0dder
Thanks, greenant, I'll take a look! I've once downloaded Gremaf, but I wasn't interested in DB stuff so I deleted it. I think it should be very helpful for me in this very moment! Thanks again!



/siddhartha
Posted on 2004-09-24 10:56:27 by siddhartha
The only difference is the LVS_OWNERDATA style.



You mean that if I directly set this style in RadASM I get a virtual listview? Or what?


/siddhartha
Posted on 2004-09-24 10:58:48 by siddhartha
You get a virtuallistview but you should handle LNV_GETDISPINFO to show text.

This is a sample code in C++ of a WM_NOTIFY handler for a VirtualListview

long listview::Notify(LPNMHDR pHdr)

{
switch(pHdr->code)
{
case LVN_GETDISPINFO:
{
NMLVDISPINFO* pnmv = (NMLVDISPINFO*) pHdr;
if (pnmv->item.mask & LVIF_TEXT)
{
long si = pnmv->item.iSubItem;
long i = pnmv->item.iItem;
switch(si)
{
case LVC_DATA:
lstrcpy(pnmv->item.pszText, pAnalisiStr[i]->data);
break;

case LVC_IMBALLO:
lstrcpy(pnmv->item.pszText, pAnalisiStr[i]->imballo);
break;

case LVC_LOTTO:
lstrcpy(pnmv->item.pszText, pAnalisiStr[i]->lotto);
break;

......
case LVC_CLIENTE:
if(pAnalisiVal[i]->cliente)
lstrcpy(pnmv->item.pszText, pAnalisiStr[i]->cliente);
else
pnmv->item.pszText[0] = 0;
break;

case LVC_CONF:
lstrcpy(pnmv->item.pszText, pAnalisiStr[i]->conforme);
break;

case LVC_NOTE:
lstrcpy(pnmv->item.pszText, pAnalisiStr[i]->note);
break;
}
}
}
break;

case LVN_COLUMNCLICK:
SortOrder *= -1;
Sort(((NMLISTVIEW*) pHdr)->iSubItem);
break;

case NM_CUSTOMDRAW:
{
NMLVCUSTOMDRAW* nmcd = (NMLVCUSTOMDRAW*) pHdr;

switch(nmcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
return CDRF_NOTIFYITEMDRAW;

case CDDS_ITEMPREPAINT:
if(pAnalisiVal[nmcd->nmcd.dwItemSpec]->conforme == CONF_VALUE)
return 0;
else
return CDRF_NOTIFYSUBITEMDRAW;

case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
{
long conforme = pAnalisiVal[nmcd->nmcd.dwItemSpec]->conforme;
switch(nmcd->iSubItem)
{
case LVC_PH: //pH
if(conforme & (1<<4))
nmcd->clrText = CONF;
else
nmcd->clrText = NON_CONF;
break;

case LVC_VISCO1: //Viscost?
if(conforme & (1<<3))
nmcd->clrText = CONF;
else
nmcd->clrText = NON_CONF;
break;

case LVC_R30: //R30
if(conforme & (1<<2))
nmcd->clrText = CONF;
else
nmcd->clrText = NON_CONF;
break;

case LVC_UMIDITA: //Umidit?
if(conforme & (1<<1))
nmcd->clrText = CONF;
else
nmcd->clrText = NON_CONF;
break;

case LVC_IMPACCA: //Impaccamento
if(conforme & (1))
nmcd->clrText = CONF;
else
nmcd->clrText = NON_CONF;
break;

case LVC_CONF: //Conforme
if(conforme == CONF_VALUE)
nmcd->clrText = CONF;
else
nmcd->clrText = NON_CONF;
break;

default:
nmcd->clrText = CONF;
break;

}

return CDRF_NEWFONT;
}
}
}
}
return 0;
}
Posted on 2004-09-24 11:02:28 by greenant
Thanks for the fast and exact reply! I really appreciate it! I'll take a closer look later at home... I have a lot of homework for tonight :)



/siddhartha
Posted on 2004-09-24 11:04:35 by siddhartha
When doing this:

invoke SendMessage,hList,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,1


nothing happens. What am I doing wrong? Thanks in advance!



/siddhartha
Posted on 2004-09-25 07:19:15 by siddhartha
Parameters

dwExMask
DWORD value that specifies which styles in dwExStyle are to be affected. This parameter can be a combination of Extended List-View Styles. Only the extended styles in dwExMask will be changed. All other styles will be maintained as they are. If this parameter is zero, all of the styles in dwExStyle will be affected.
dwExStyle
DWORD value that specifies the extended list-view control style. This parameter can be a combination of Extended List-View Styles.


You shoud do this


invoke SendMessage,hList,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS _EX_FULLROWSELECT,LVS _EX_FULLROWSELECT

but I prefer this


invoke SendMessage,hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS _EX_FULLROWSELECT
Posted on 2004-09-25 07:26:02 by greenant