Advertisement

[Win32 API] Adding tree view nodes

Started by May 29, 2001 09:33 AM
-1 comments, last by Clash Rocker 23 years, 8 months ago
Ok, I''m trying to read some text in from a file, and adding that text as a child node to to my tree view. So my code snipped:
  
	i = 448;
	for(k = 0; k < max; k++)
	{		
		if((k > maxr) && (maxu > 0))
		{
			tvItem.pszText = GetPilotName(i + iJump * k);
			tvIns.hParent  = hu;
			tvItem.lParam  = x++;
			tvIns.item     = tvItem;
			TreeView_InsertItem(hWndTree, &tvIns);	
		}
		else if(k < maxr)
		{		
			tvItem.pszText = GetPilotName(i + iJump * k);
			tvIns.hParent  = hr; 
			tvItem.lParam  = x++;
			tvIns.item     = tvItem;
			TreeView_InsertItem(hWndTree, &tvIns);	
		}
	}
  
OK, max is the number of text strings to read, there''s two types. maxr + maxu will equal max. maxr is always stored in the file before maxu strings
  
char* GetPilotName(int iOffset)
{
	DWORD     dwBytesRead;	
	const int iBuffSize   = 20;
	char*     pPilotName  = "";
	
	SetFilePointer(g_hTemporaryFile, iOffset, 0, FILE_BEGIN);		
	ReadFile(g_hTemporaryFile, pPilotName, iBuffSize, &dwBytesRead, 0);	
	return pPilotName;
}
  
This fucntion will read the file from the giving offset/value from my tree view function...the snippet way above there. The strings are stored as 20 bytes long inside a data struct 68 bytes big. now mu problem is that when ever I load up a file to read the strings, it never adds the last two strings which would be part of maxu....i''ve manualy checked the file and my maxr + maxu and everything checks up Oh, iJump is 68. Can you please help me?

This topic is closed to new replies.

Advertisement