Click here to Skip to main content
15,887,027 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Authentication client-server using message queues in c language Pin
ralph 230-Jul-10 3:20
ralph 230-Jul-10 3:20 
QuestionProgressBar and Threading.. Pin
Anil Kumar.Arvapalli29-Jul-10 19:53
Anil Kumar.Arvapalli29-Jul-10 19:53 
AnswerRe: ProgressBar and Threading.. Pin
Richard MacCutchan29-Jul-10 22:24
mveRichard MacCutchan29-Jul-10 22:24 
QuestionAdd Publisher name to my application Pin
Cvaji29-Jul-10 2:20
Cvaji29-Jul-10 2:20 
GeneralRe: Add Publisher name to my application Pin
Sauro Viti29-Jul-10 9:15
professionalSauro Viti29-Jul-10 9:15 
QuestionHow to play flash movies with transparent background color in a Window? Pin
itmagina28-Jul-10 14:51
itmagina28-Jul-10 14:51 
AnswerRe: How to play flash movies with transparent background color in a Window? Pin
sunlin730-Jul-10 18:30
sunlin730-Jul-10 18:30 
Questionwhy does this thread just show the last one record? Pin
wangningyu27-Jul-10 20:59
wangningyu27-Jul-10 20:59 
I use ADO + MS SQL2000 ,I don't hope the window hang,when I read the records in the main thread.

So I use other thread to read the datebase.Just like this:

(if I didn't use thread,this record is the last one.)

void CxxDlg::UpdateListCtrl()
{
	CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)StartRead,this,NULL,NULL);
	Sleep(100);
}

DWORD WINAPI CxxDlg::StartRead(LPVOID lParam)
{
	CoInitialize(NULL);
	CxxDlg *pDlg = (CxxDlg *)lParam;
	ASSERT( pDlg != NULL );

	_variant_t	vA,vB,vC,vD;
	CString		strTemp;
	int			nItem,nCount;
	try
	{
		// use ADO + MS SQL2000 to access the datebase
		pDlg->m_List1.DeleteAllItems();
		m_pRecordset.CreateInstance("ADODB.Recordset");	
		strTemp.Format("select * from db_somedate");
		m_pRecordset->Open((_variant_t)strTemp,_variant_t((IDispatch*)
			m_pConnection,TRUE),adOpenStatic,adLockOptimistic,adCmdText);
		
		while(VARIANT_FALSE == m_pRecordset->adoEOF)
		{
			// when I set a point here,and enter the debug mode,the listctrl can read all date.
			// but when I canceled the point,it just read only one record
			// the debug mode,output window warn the thread exit with code (DATE_SUCCESS)
			vA	= m_pRecordset->GetCollect("A");
			vB	= m_pRecordset->GetCollect("B");
			vC	= m_pRecordset->GetCollect("C");
			vD	= m_pRecordset->GetCollect("D");
			
			nItem = pDlg->m_List1.InsertItem(0,(_bstr_t)vA);
			pDlg->m_List1.SetItem(nItem,1,1,(_bstr_t)vB,NULL,0,0,0);
			pDlg->m_List1.SetItem(nItem,2,1,(_bstr_t)vC,NULL,0,0,0);
			pDlg->m_List1.SetItem(nItem,3,1,(_bstr_t)vD,NULL,0,0,0);

			m_pRecordset->MoveNext();
		}
		// Set last line highlight
		nCount = pDlg->m_List1.GetItemCount();
		pDlg->m_List1.SetFocus();
		pDlg->m_List1.SetItemState(nCount-1, LVIS_SELECTED,  LVIS_SELECTED);
		pDlg->m_List1.EnsureVisible(nCount-1,FALSE);
	}
	catch (_com_error e)
	{
		CString errormessage;  
		errormessage.Format("Connect Datebase failed.\r\n\r\nError code:%s",e.ErrorMessage());
		return DATE_FAILED;
	}
	return DATE_SUCCESS;
}

QuestionATL error [modified] Pin
shakumar_212-Jul-10 21:32
shakumar_212-Jul-10 21:32 
AnswerRe: ATL error Pin
Stephen Hewitt4-Jul-10 14:48
Stephen Hewitt4-Jul-10 14:48 
QuestionCapturing IE Events Pin
Adeel Mirza1-Jul-10 0:08
Adeel Mirza1-Jul-10 0:08 
QuestionHow to get Drive name of current OS installed Pin
am 200928-Jun-10 18:46
am 200928-Jun-10 18:46 
AnswerRe: How to get Drive name of current OS installed Pin
gpsushil28-Jun-10 20:26
gpsushil28-Jun-10 20:26 
QuestionDisplay controls in editor-created tab control [modified] Pin
Splatt4223-Jun-10 7:59
Splatt4223-Jun-10 7:59 
AnswerRe: Display controls in editor-created tab control Pin
Jonathan Davies10-Jul-10 3:04
Jonathan Davies10-Jul-10 3:04 
QuestionUsing CoCreateInstance crashes the program?? [modified] Pin
Kiran Satish22-Jun-10 11:40
Kiran Satish22-Jun-10 11:40 
QuestionRetriving the active contents of a Webpage Pin
Adeel Mirza21-Jun-10 2:07
Adeel Mirza21-Jun-10 2:07 
AnswerRe: Retriving the active contents of a Webpage Pin
Eddy Vluggen22-Jun-10 0:42
professionalEddy Vluggen22-Jun-10 0:42 
QuestionInternet Explorer ExplorerBar Pin
Adeel Mirza15-Jun-10 20:52
Adeel Mirza15-Jun-10 20:52 
AnswerRe: Internet Explorer ExplorerBar Pin
Richard MacCutchan15-Jun-10 21:39
mveRichard MacCutchan15-Jun-10 21:39 
GeneralRe: Internet Explorer ExplorerBar Pin
Adeel Mirza15-Jun-10 23:58
Adeel Mirza15-Jun-10 23:58 
GeneralRe: Internet Explorer ExplorerBar Pin
Richard MacCutchan16-Jun-10 1:52
mveRichard MacCutchan16-Jun-10 1:52 
GeneralRe: Internet Explorer ExplorerBar Pin
Adeel Mirza16-Jun-10 1:56
Adeel Mirza16-Jun-10 1:56 
GeneralRe: Internet Explorer ExplorerBar Pin
Richard MacCutchan16-Jun-10 3:01
mveRichard MacCutchan16-Jun-10 3:01 
GeneralRe: Internet Explorer ExplorerBar Pin
Adeel Mirza16-Jun-10 3:13
Adeel Mirza16-Jun-10 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.