BarClick Event Fired When Control Width is Changed

Summary

Id: 3911.2
Type: Bug Bug
Current Status: Resolved

Detail

16 Aug 2002 Open Billy Propes

I believe that I have found a bug in the vbAccelerator ListBar control. Whenever the control’s width is resized, the BarClick event is raised. I think that this is because in the pSetupBar function, it is not saving the last bar that was clicked in the static variable s_iLastBar. I stepped through the program, and this variable always seems to be 0 (Please see the code listing below to see what I mean). I have modified this in my own version. So, if you have any reason why I should not fix it this way, I would appreciate an e-mail. Thanks for your time and thanks for creating such a great control. I have yet to find anything like it on the net that doesn’t cost hundreds of dollars.

Private Sub pSetUpBar(ByVal iBar As Long)Dim i As LongDim tR As RECTDim lS As LongStatic s_iLastBar As Long If Len(m_sBackgroundPicture) > 0 Then 'lvw.ForeColor = CLR_NONE Else lvw.BackColor = m_tBars(iBar).oBackColor lvw.ForeColor = m_tBars(iBar).oForeColor End If lvw.Clear With m_tBars(iBar) For i = 1 To .lItemCount With .tItems(i) lvw.Add .sCaption, .lIconIndex, , .iItemID End With Next i End With If m_tBars(iBar).eIconSize = evlbLargeIcon Then lvw.View = &H0 'evballvViewIcon Else lvw.View = &H2 'evballvViewSmallIcon End If lvw.Update pAlignLVItems tR lS = GetWindowLong(lvw.hWndLV, GWL_STYLE) lS = lS And Not WS_HSCROLL SetWindowLong lvw.hWndLV, GWL_STYLE, lS If Not iBar = s_iLastBar Then Dim cB As New cListBar cB.fInit m_hWndCtl, m_tBars(iBar).iID RaiseEvent BarClick(cB) 'Date: 08/16/02 'Fix By: Billy Propes ' bpropes@columbus.rr.com 'Problem: BarClick event was being raised every time the control's ' width was resized. 'Fix: I think this was because the control was not properly ' recording the last bar in this subroutine. Anyway, this ' seems to work. s_iLastBar = iBar End IfEnd Sub
28 Jul 2003 Resolved Steve McMahon

Resolved as suggested.