transparent Listbox
-
i subclassed the CListBox and override this two functions BOOL CListBoxTrans::OnEraseBkgnd(CDC* pDC) { // TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen return true; //return CListBox::OnEraseBkgnd(pDC); } HBRUSH CListBoxTrans::CtlColor(CDC* pDC, UINT nCtlColor) { // TODO: Attribute des Gerätekontexts hier ändern // TODO: Pinsel ungleich NULL zurückgeben, falls die Behandlungsroutine des übergeordneten nicht aufgerufen werden soll pDC->SetBkMode(TRANSPARENT); return (HBRUSH)::GetStockObject(NULL_BRUSH); //return NULL; } So now my ListBox is transparent , but if i have to scroll the box or i select an item in the box the transparent effect is damaged . There is a really missmatch on the listbox . What do i have to do , that selecting items and scrolling will work in my transparent ListBox ?
-
i subclassed the CListBox and override this two functions BOOL CListBoxTrans::OnEraseBkgnd(CDC* pDC) { // TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen return true; //return CListBox::OnEraseBkgnd(pDC); } HBRUSH CListBoxTrans::CtlColor(CDC* pDC, UINT nCtlColor) { // TODO: Attribute des Gerätekontexts hier ändern // TODO: Pinsel ungleich NULL zurückgeben, falls die Behandlungsroutine des übergeordneten nicht aufgerufen werden soll pDC->SetBkMode(TRANSPARENT); return (HBRUSH)::GetStockObject(NULL_BRUSH); //return NULL; } So now my ListBox is transparent , but if i have to scroll the box or i select an item in the box the transparent effect is damaged . There is a really missmatch on the listbox . What do i have to do , that selecting items and scrolling will work in my transparent ListBox ?
If your listbox is transparent then you should be telling the parent to repaint in the way that you require. Invalidate the rectangle in the parent where the transparent control is. Though there is another way, rather than have your listbox transparent, which can cause you extra typing because of z order painting problems, pass the background rectangle (on move or resize of the parent) to the child (your control) and stick the background in. Then of cause you are back in a world where the listbox can take care of itself. We do it for the joy of seeing the users struggle.