首先看下MSDN上对CListCtrl::SetBkImage的描述?
BOOL SetBkImage( LPTSTR pszUrl, BOOL fTile = TRUE, int xOffsetPercent = 0, int yOffsetPercent = 0 );
Return Value
Returns nonzero if successful, or zero otherwise.
Parameters
pszUrl 以‘\0’结尾的字符串(包含背景图片的绝对路径)
fTile 如果图片平铺在当前list view control的背景上,fTile=非零值(缺省值),否则fTile=0
xOffsetPercent
The offset, in pixels, of the image’s left edge, from origin of the list view control.
yOffsetPercent
The offset, in pixels, of the image’s top edge, from origin of the list view control.
但是调用时,发现SetBkImage的绝对路径的名称写错了,其返回值还是真!!!
为了这个浪费了我几天一直怀疑是控件的设置错了。汗!!!!!
测试代码如下:
BOOL ret = m_wndList.SetBkImage("F:/MFC/ListCtrl/33bk.bmp"/*图片绝对路径*/);
if(ret){
HANDLE HConsole;
AllocConsole();
HConsole=GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dw;
CString str("SetBkImage successfully!");
WriteConsole(HConsole,str.GetBuffer(),str.GetLength(),&dw,NULL);
WriteConsole(HConsole,"\n",strlen("\n"),&dw,NULL);
}
ps:
1. 平铺:就是把图片铺满桌面 ,因为一张图片可能不能占满整个桌面,就用几张图片铺满桌面。2. 拉伸:就是把图片放大 ,让一张图片就占满桌面。
3. 居中:把图片放在桌面中间。