Click here to Skip to main content
15,905,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: syntax error '<' Pin
gr8coaster32931-Oct-05 9:26
gr8coaster32931-Oct-05 9:26 
AnswerRe: syntax error '<' Pin
David Crow31-Oct-05 9:49
David Crow31-Oct-05 9:49 
QuestionPrinting an image Pin
DanYELL29-Oct-05 17:07
DanYELL29-Oct-05 17:07 
AnswerRe: Printing an image Pin
Christian Graus30-Oct-05 11:41
protectorChristian Graus30-Oct-05 11:41 
GeneralRe: Printing an image Pin
DanYELL30-Oct-05 16:50
DanYELL30-Oct-05 16:50 
GeneralRe: Printing an image Pin
Christian Graus30-Oct-05 16:53
protectorChristian Graus30-Oct-05 16:53 
QuestionSPDRP_FRIENDLYNAME Pin
LiYS29-Oct-05 16:41
LiYS29-Oct-05 16:41 
QuestionCListCtrl Error Pin
Allad29-Oct-05 15:05
Allad29-Oct-05 15:05 
Hello,
I'm writing an application that uses MFC.
It is a kind of media player and I use CListCtrl to display playlist.
But I get a strange error when I add items to my list control. After the 17th item added, my app crashs with a message box showing "Invalid Hook Descriptor".
I am attaching some code. To keep it simple, I've just extracted parts liable to contain the bad code : the overrided Create member method and the UpdateList method.
An explanation : I'm displaying playlist. So I read the M3U file and I call Update list method to add the file paths to the CListCtrl.
Any help would be appreciated. That bug is driving me crazy.Sigh | :sigh:
Thanks
bool CMusicBox::CreateWnd(CWnd* Parent)<br />
{<br />
	parent = Parent;<br />
	if(parent)<br />
	{<br />
<br />
		RECT client;<br />
		parent->GetClientRect(&client);<br />
		int result = this->Create(WS_CHILD|WS_VSCROLL|WS_BORDER|WS_VISIBLE|LVS_SHOWSELALWAYS|LVS_REPORT|LVS_ALIGNLEFT,client,parent,1234);<br />
                //Extended CListCtrl style<br />
		this->SetExtendedStyle(0x00004000|0x00000100|0x00000020|0x00000010);<br />
		<br />
		this->SetBkColor(RGB(237,242,249));<br />
}<br />


The UpdateList method

void CMusicBox::UpdateList(void)<br />
{<br />
        // Clean Up<br />
	this->DeleteAllItems();<br />
	ASSERT(this->GetItemCount() == 0);<br />
	int max = this->play.playList.GetCount();<br />
<br />
        //Number of items to be added<br />
	this->SetItemCount(max);<br />
<br />
	int i = 0;<br />
<br />
        //Update loop<br />
	for(i = 0;i<max;i++)<br />
	{<br />
		CFile myFile;<br />
<br />
		CString title;// sample title<br />
		CString path;<br />
		unsigned long siz = 0;<br />
<br />
                //File length<br />
		if(myFile.Open(this->play.GetSong(i),CFile::modeRead|CFile::shareDenyNone))<br />
		{<br />
			title = myFile.GetFileTitle();<br />
			siz = myFile.GetLength();<br />
			myFile.Close();<br />
		}<br />
		else {<br />
			title.Format("Access Denied");<br />
		}<br />
		HMS dure = {0,0,0};<br />
<br />
		path = CString(this->play.GetSong(i));<br />
<br />
                //Dummy MCIWnd Instance to retrieve sample length in seconds<br />
		HWND tester = MCIWndCreate(NULL,AfxGetInstanceHandle(),WS_BORDER|MCIWNDF_NOERRORDLG,path.GetString());<br />
		if(tester)<br />
		{<br />
			long len = MCIWndGetLength(tester);<br />
			dure = GetHMSTime(len);<br />
			MCIWndDestroy(tester);<br />
		}<br />
<br />
                //Print the attributes in char buffers<br />
		char *taille = new char[50];<br />
		char *duree = new char[50];<br />
		char *chemin = new char[MAX_PATH];<br />
		char *titre = new char[MAX_PATH];<br />
<br />
		sprintf(taille,"%.2f",siz/(1024.0*1024));<br />
		if(dure.h == 0) <br />
			sprintf(duree,"%d : %02d", dure.m, dure.s);<br />
		else sprintf(duree,"%d : %02d : %02d",dure.h, dure.m, dure.s);<br />
		strcpy(chemin, path.GetString() );<br />
<br />
		CPath filePath(path);<br />
<br />
		sprintf(titre,"%s",filePath.GetTitle());<br />
<br />
                //Adding it to the CListCtrl<br />
		LVITEM lvi;<br />
<br />
		ZeroMemory(&lvi,sizeof(LVITEM));<br />
<br />
		lvi.mask = LVIF_TEXT;<br />
<br />
		//lvi.iItem = i;<br />
		//lvi.iSubItem = 1;<br />
		//lvi.pszText = titre;<br />
		//this->InsertItem(&lvi);<br />
		this->InsertItem(i,"item");<br />
		<br />
		// Sub items<br />
		this->SetItem(i,0,LVIF_TEXT,titre,NULL,NULL,NULL,NULL);<br />
		this->SetItem(i,1,LVIF_TEXT,duree,NULL,NULL,NULL,NULL);<br />
		this->SetItem(i,2,LVIF_TEXT,chemin,NULL,NULL,NULL,NULL);<br />
		this->SetItem(i,3,LVIF_TEXT,taille,NULL,NULL,NULL,NULL);<br />
			<br />
<br />
	}<br />
}<br />


-- modified at 21:05 Saturday 29th October, 2005
Questionnumber picker thingie Pin
alex@zoosmart.us29-Oct-05 12:11
alex@zoosmart.us29-Oct-05 12:11 
AnswerRe: number picker thingie Pin
Joe Woodbury29-Oct-05 13:06
professionalJoe Woodbury29-Oct-05 13:06 
GeneralRe: number picker thingie Pin
alex@zoosmart.us30-Oct-05 12:05
alex@zoosmart.us30-Oct-05 12:05 
GeneralRe: number picker thingie Pin
Joe Woodbury30-Oct-05 17:19
professionalJoe Woodbury30-Oct-05 17:19 
Questionsort structures Pin
kerrywes29-Oct-05 9:57
kerrywes29-Oct-05 9:57 
AnswerRe: sort structures Pin
Chris Losinger29-Oct-05 12:03
professionalChris Losinger29-Oct-05 12:03 
AnswerRe: sort structures Pin
Joe Woodbury29-Oct-05 13:11
professionalJoe Woodbury29-Oct-05 13:11 
AnswerRe: sort structures Pin
Ghasrfakhri29-Oct-05 19:21
Ghasrfakhri29-Oct-05 19:21 
Questioncant signin to homtmail using Pin
whatever8929-Oct-05 9:29
whatever8929-Oct-05 9:29 
Questionfile system type Pin
Chintoo72329-Oct-05 7:26
Chintoo72329-Oct-05 7:26 
AnswerRe: file system type Pin
Mircea Puiu29-Oct-05 7:45
Mircea Puiu29-Oct-05 7:45 
Questiontooltip for CDC drawing areas ?? Pin
tbrake29-Oct-05 6:15
tbrake29-Oct-05 6:15 
Questionmulti thread sinz Pin
jojojojoj29-Oct-05 3:51
jojojojoj29-Oct-05 3:51 
AnswerRe: multi thread sinz Pin
S. Senthil Kumar29-Oct-05 7:50
S. Senthil Kumar29-Oct-05 7:50 
GeneralRe: multi thread sinz Pin
jojojojoj29-Oct-05 11:00
jojojojoj29-Oct-05 11:00 
QuestionListCtrl problem Pin
shivditya29-Oct-05 2:00
shivditya29-Oct-05 2:00 
Questionfile transfer Pin
Orell29-Oct-05 1:28
Orell29-Oct-05 1:28 

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.