Click here to Skip to main content
15,896,529 members

Comments by BiggiSmalls (Top 7 by date)

BiggiSmalls 28-Nov-14 13:41pm View    
Thank you very much :) i figured it out. Have a nice day
BiggiSmalls 28-Nov-14 7:02am View    
This is the code for dynamically generating user controls:

//Message is the class with properties and List<> listofMessages
foreach (Message item in Message.listofMessages)
{
UserCKocka novUc = new UserCKocka();
novUc.Margin = new Thickness(5);
novUc.Width = 180;
novUc.Height = 180;

//Increase tag number
stTaga++;
//Tag user control with the number stTaga
novUc.Tag = stTaga;


//Adding the datas and image for the newly created user control
Uri slikaPot = new Uri(item.Slika, UriKind.RelativeOrAbsolute);
BitmapImage slika = new BitmapImage(slikaPot);
novUc.slikaKocka.Source = slika;

//Textblock pošiljatelj
novUc.txtPosiljateljKocka.Text = item.Od;
novUc.txtZadevaKocka.Text = item.Zadeva;
novUc.SporociloKocka.Text = item.Vsebina;


wrap.Children.Add(novUc);
}

Thank you for helping me :)

Can you help me little more? How do check which user control is clicked by its Tag, in case if i wanted to delete it??
BiggiSmalls 4-Sep-14 7:26am View    
OK thanks a lot. I found this code on net, what do you think about this:

void CDialg::ShowImages(CString DirPath)
{
CWaitCursor waitCur;

//m_ctlListCtrl.SetRedraw(FALSE);
if(!DirPath.IsEmpty())
{
//m_ctlListCtrl.SetCurDirectory(DirPath);
//m_ctlListCtrl.ClearImageFileArray();
//jpg,bmp,png,tiff,jpeg,gif

CFileFind find;
CString strFile;
if(DirPath.Right(1) != _T("\\"))
strFile = DirPath + _T("\\*.*");
else
strFile = DirPath + _T("*.*");
UINT nCountImages=0;
BOOL bFound = find.FindFile(strFile);
while(bFound)
{
bFound = find.FindNextFile();
CString strFileName;
if(find.IsDirectory())
continue;
strFileName = find.GetFileName();
CString ext3=strFileName.Right(3);
CString ext4=strFileName.Right(4);

if(!strFileName.IsEmpty() && (strFileName.GetLength()>4))
{ if(ext3.CompareNoCase("bmp")==0 || ext3.CompareNoCase("dib")==0 ||
ext3.CompareNoCase("jpg")==0 || ext3.CompareNoCase("tif")==0 ||
ext3.CompareNoCase("png")==0 || ext4.CompareNoCase("jpeg")==0 ||
ext4.CompareNoCase("tiff")==0 ) //If Condition true add filename to list control
//m_ctlListCtrl.AddImageFile(strFileName);
}
}
//m_ctlListCtrl.LoadThumbImages();

}
//m_ctlListCtrl.SetRedraw(TRUE);
Invalidate();
}
BiggiSmalls 4-Sep-14 7:02am View    
Yes i already created the ListControl, when i select an item from the TreeControl, it saves the path of the folder in a edit control box. Now i need like you said from this selected path to show all the files in the ListControl, but i totaly lost right now, can you help me little bit more with this?
BiggiSmalls 4-Sep-14 6:44am View    
When i click on tree item (folder) i want to show all files in that folder and subfolder to a list control. I need a explanation of the code what to do when i click ONSELELECTION_CHANGED_TREE.