static void FillHistoryThread(void* param) { TCHAR str[200], eventText[256], strdatetime[64]; HANDLE hDbEvent; DBEVENTINFO dbei; int newBlobSize,oldBlobSize,i; HWND hwndList; THistoryThread *hInfo = ( THistoryThread* )param; SendDlgItemMessage(hInfo->hwnd,IDC_LIST,LB_RESETCONTENT,0,0); i=CallService(MS_DB_EVENT_GETCOUNT,(WPARAM)hInfo->hContact,0); SendDlgItemMessage(hInfo->hwnd,IDC_LIST,LB_INITSTORAGE,i,i*40); ZeroMemory(&dbei,sizeof(dbei)); dbei.cbSize=sizeof(dbei); oldBlobSize=0; hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDLAST,(WPARAM)hInfo->hContact,0); hwndList = GetDlgItem(hInfo->hwnd,IDC_LIST); while ( hDbEvent != NULL ) { if ( !IsWindow( hInfo->hwnd )) break; newBlobSize=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)hDbEvent,0); if(newBlobSize>oldBlobSize) { dbei.pBlob=(PBYTE)mir_realloc(dbei.pBlob,newBlobSize); oldBlobSize=newBlobSize; } dbei.cbBlob = oldBlobSize; CallService( MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei ); GetObjectSummary(&dbei,str,SIZEOF(str)); if(str[0]) { tmi.printTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, SIZEOF(strdatetime), 0); mir_sntprintf( eventText, SIZEOF(eventText), _T("%s: %s"), strdatetime, str ); i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText ); SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); } hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDPREV,(WPARAM)hDbEvent,0); } mir_free(dbei.pBlob); SendDlgItemMessage(hInfo->hwnd,IDC_LIST,LB_SETCURSEL,0,0); SendMessage(hInfo->hwnd,WM_COMMAND,MAKEWPARAM(IDC_LIST,LBN_SELCHANGE),0); EnableWindow(GetDlgItem(hInfo->hwnd, IDC_LIST), TRUE); mir_free(hInfo); }
static void FillHistoryThread(void* param) { Thread_SetName("HistoryWindow::FillHistoryThread"); THistoryThread *hInfo = (THistoryThread*)param; HWND hwndList = GetDlgItem(hInfo->hwnd, IDC_LIST); SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0); int i = db_event_count(hInfo->hContact); SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_INITSTORAGE, i, i * 40); DBEVENTINFO dbei = { sizeof(dbei) }; int oldBlobSize = 0; MEVENT hDbEvent = db_event_last(hInfo->hContact); while (hDbEvent != NULL) { if (!IsWindow(hInfo->hwnd)) break; int newBlobSize = db_event_getBlobSize(hDbEvent); if (newBlobSize > oldBlobSize) { dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); oldBlobSize = newBlobSize; } dbei.cbBlob = oldBlobSize; db_event_get(hDbEvent, &dbei); TCHAR str[200], eventText[256], strdatetime[64]; GetObjectSummary(&dbei, str, _countof(str)); if (str[0]) { TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, _countof(strdatetime), 0); mir_sntprintf(eventText, _T("%s: %s"), strdatetime, str); i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText); SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); } hDbEvent = db_event_prev(hInfo->hContact, hDbEvent); } mir_free(dbei.pBlob); SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_SETCURSEL, 0, 0); SendMessage(hInfo->hwnd, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); EnableWindow(GetDlgItem(hInfo->hwnd, IDC_LIST), TRUE); mir_free(hInfo); }