|
From: PaulH on 22 Mar 2005 18:45 How do you make a clistctrl (or a subclassed derivative of one) not scroll its background image? I've been using something similiar to this to load the image: LVBKIMAGE image; // If no background image is set for the list view control if (m_list.GetBkImage(&image) && (bki.ulFlags == LVBKIF_SOURCE_NONE)) { m_list.SetBkImage(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)), FALSE); } Thanks for your assistance!
From: PaulH on 23 Mar 2005 14:37 I've had a little luck with this now... It's not perfect, though. The image jitters slightly, but it stays in place relatively well... My "solution" (if you can call it that) is below. I overrode the "onscroll" handler for the CListCtrl, and told it to reposition the image. Unfortunately, there's some funniness in that the distance to the origin is a float, and I can only give an integer value to SetBkImage(). So, I made up for it by alternatly moving 1 less than the distance. This causes the slight jitter effect. If anybody has a way to fix this, or a better solution, in general. Please, let me know. void CMyDlg::OnLvnBeginScrollList1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLVSCROLL pStateChanged = reinterpret_cast<LPNMLVSCROLL>(pNMHDR); static bool bAlt = false; LVBKIMAGE image; CRect rcItem; m_list.GetItemRect(m_list.GetTopIndex(), &rcItem, LVIR_BOUNDS); m_list.GetBkImage(&image); int yOffset = pStateChanged->dy * (bAlt ? rcItem.Height() : (rcItem.Height() - 1)); int xOffset = pStateChanged->dx * (bAlt ? rcItem.Width() : (rcItem.Width() - 1)); m_list.SetBkImage(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)), FALSE, image.xOffsetPercent + xOffset, image.yOffsetPercent + yOffset); bAlt = !bAlt; *pResult = 0; }
|
Pages: 1 Prev: IMPLEMENT_SERIAL_T and the like Next: CFtpFileFind messes with CFtpConnection; Error 12003 |