Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
If the listcontrol display a background map it。
So write wrong?
 
 m_ListCtrl.SetBkImage("C:\Documents and Settings\zhanbiao\Desktop\Original Files\Mains.bmp");
 
    m_ListCtrl.SetTextBkColor(CLR_NONE);
 

Don't know why display does not come out images
 

 
help me solve once.
Posted 15-Jan-13 16:43pm
Edited 15-Jan-13 16:55pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

your mistake is with file path name:
 
\ is a escape character. to put back slash as input character you must have to use \\
 
 m_ListCtrl.SetBkImage("C:\\Documents and Settings\\zhanbiao\\Desktop\\Original Files\\Mains.bmp");
 
    m_ListCtrl.SetTextBkColor(CLR_NONE);
 
try above............
  Permalink  
Comments
shizhanbiao at 15-Jan-13 23:39pm
   
or no ,display does come out image
Mohibur Rashid at 15-Jan-13 23:53pm
   
this works fine in my computer,
 
by the way if you are using unicode character set
 
then try this
m_ListCtrl.SetBkImage(L"C:\\Documents and Settings\\zhanbiao\\Desktop\\Original Files\\Mains.bmp");
shizhanbiao at 16-Jan-13 0:57am
   
What I use is vc6. Version, how to solve this problem,.
Mohibur Rashid at 16-Jan-13 1:02am
   
make sure your control is getting created
shizhanbiao at 16-Jan-13 2:04am
   
Can you mail for me? I'll give you the code to send the past.
Mohibur Rashid at 16-Jan-13 19:48pm
   
no i wont mail you or give my mail on site to be seen by everyone, but you can update your question and add the code, so, we all will be able to examine this.
shizhanbiao at 16-Jan-13 21:40pm
   
BOOL CDemoListDlg::OnInitDialog()
{
CDialog::OnInitDialog();
 
// Add "About..." menu item to system menu.
 
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
 
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
 
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_ListCtrl.SetBkImage(_T("http://www.microsoft.com/library/images/gifs/homepage/microsoft.gif"),TRUE);
m_ListCtrl.SetTextBkColor(CLR_NONE);
// TODO: Add extra initialization here
//m_ListCtrl.SetColColor(0,RGB(10,150,20)); //ÉèÖÃÁб³¾°É«
//m_ListCtrl.SetColColor(2,RGB(30,100,90)); //ÉèÖÃÁб³¾°É«
m_ListCtrl.SetBkColor(RGB(40,47,54)); //ÉèÖñ³¾°É«
//m_ListCtrl.SetItemColor(2,1,RGB(100,100,10)); //ÉèÖÃÖ¸¶¨µ¥Ôª±³¾°É«
m_ListCtrl.SetRowHeigt(25); //ÉèÖÃÐи߶È
m_ListCtrl.SetHeaderHeight(1.5); //ÉèÖÃÍ·²¿¸ß¶È
m_ListCtrl.SetHeaderFontHW(16,0); //ÉèÖÃÍ·²¿×ÖÌå¸ß¶È,ºÍ¿í¶È,0±íʾȱʡ£¬×ÔÊÊÓ¦
m_ListCtrl.SetHeaderTextColor(RGB(255,255,255)); //ÉèÖÃÍ·²¿×ÖÌåÑÕÉ«
m_ListCtrl.SetTextColor(RGB(255,255,255)); //ÉèÖÃÎı¾ÑÕÉ«
m_ListCtrl.SetHeaderBKColor(75,136,219,4); //ÉèÖÃÍ·²¿±³¾°É«
m_ListCtrl.SetFontHW(15,0); //ÉèÖÃ×ÖÌå¸ß¶È£¬ºÍ¿í¶È,0±íʾȱʡ¿í¶È
m_ListCtrl.SetColTextColor(2,RGB(255,255,255)); //ÉèÖÃÁÐÎı¾ÑÕÉ«
m_ListCtrl.SetItemTextColor(3,1,RGB(255,255,255)); //ÉèÖõ¥Ôª¸ñ×ÖÌåÑÕÉ«
 
m_ListCtrl.InsertColumn(0,_T("Ãû×Ö"),LVCFMT_CENTER,55);
m_ListCtrl.InsertColumn(1,_T("Éí¸ß"),LVCFMT_CENTER,60);
m_ListCtrl.InsertColumn(2,_T("ÌåÖØ"),LVCFMT_CENTER,60);
m_ListCtrl.InsertColumn(3,_T("²âÁ¿Ê±¼ä"),LVCFMT_CENTER,180);
 
m_ListCtrl.InsertItem(0,"ÕÅÈý");
m_ListCtrl.SetItemText(0,1,"178CM");
m_ListCtrl.SetItemText(0,2,"70KG");
m_ListCtrl.SetItemText(0,3,"2009Äê1ÔÂ15ÈÕ23ʱ40·Ö");
 
m_ListCtrl.InsertItem(1,"ÍõÎå");
m_ListCtrl.SetItemText(1,1,"178cm");
m_ListCtrl.SetItemText(1,2,"70kg");
m_ListCtrl.SetItemText(1,3,"2009Äê1ÔÂ15ÈÕ23ʱ40·Ö");
 
m_ListCtrl.InsertItem(2,"°¢»¨");
m_ListCtrl.SetItemText(2,1,"168cm");
m_ListCtrl.SetItemText(2,2,"60kg");
m_ListCtrl.SetItemText(2,3,"2009Äê1ÔÂ15ÈÕ23ʱ40·Ö");
 
m_ListCtrl.SetBkImage(_T("E:\\ss\\Mains.bmp"));
m_ListCtrl.SetTextBkColor(CLR_NONE);
//SetWindowLong(m_ListCtrl.m_hWnd ,GWL_EXSTYLE,WS_EX_CLIENTEDGE);
//m_ListCtrl.SetExtendedStyle(LVS_EX_GRIDLINES); //ÉèÖÃÀ©Õ¹·ç¸ñΪÍø¸ñ
//::SendMessage(m_ListCtrl.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE,
// LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
return TRUE; // return TRUE unless you set the focus to a control
}
help me see where there is wrong?
Mohibur Rashid at 17-Jan-13 3:18am
   
I executed your code, it work fine in my computer. except you mixed up wchar_t and char, methods, will accept either wchar_t or char in same project without proper function both wont be acceptable, as well as your weblink, that works too.
 
by the way how about your control styles and extended styles that you applied?
shizhanbiao at 21-Feb-13 2:05am
   
void TextMiult::DrawItem(LPDRAWITEMSTRUCT lp)
{
CDC *pDC=CDC::FromHandle(lp->hDC);
CRect rc;
GetClientRect(&rc);
CFont font;
font.CreatePointFont(90,"Arial Unicode MS");
pDC->SetBkMode(TRANSPARENT);
//pDC->SelectObject(font);//½«ËûÑ¡Ôñµ½É豸ÖÐ
pDC->SetTextColor(RGB(255,255,255));
CString str;
GetWindowText(str);
CRect boundary(0,0,40,20);
//
CRect rect;
rect.left = rect.top = 0;
rect.right = 200;
rect.bottom = rc.bottom;
//rect(0,0,boundary.Width(),boundary.Height());
 
int height=pDC->DrawText(str,rc,DT_CALCRECT|DT_CENTER|DT_EDITCONTROL|DT_WORDBREAK);
rect=boundary;
if (boundary.Height()>height)
{
rc.top+=(boundary.Height()-height)/2;
}
pDC->DrawText(str,rc,DT_CENTER|DT_EDITCONTROL|DT_WORDBREAK);
}
 

no words how to wrap?
shizhanbiao at 21-Feb-13 2:06am
   
newLine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 483
1 Sergey Alexandrovich Kryukov 207
2 RyanDev 165
3 PhilLenoir 160
4 RajeeshMenoth 110
0 Sergey Alexandrovich Kryukov 6,415
1 OriginalGriff 5,856
2 CPallini 2,473
3 Richard MacCutchan 1,667
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100