jwcolby
jwcolby at colbyconsulting.com
Sat Mar 7 06:45:06 CST 2009
Phillippe, I am betting that you are talking about a treeview, not a list view. I was discussing MSComCtl.Treeview with William. If that is the case, the code will look like the following: Public WithEvents mctlTreeView As TreeView Function mInit(lctlTreeView As TreeView) ' stores a pointer to the control Set mctlTreeView = lctlTreeView End Function Private Sub mctlTreeView_Click() ' End Sub John W. Colby www.ColbyConsulting.com philippe pons wrote: > John, > > I did what you told me. > > But there is another problem I have to solve. > > So my class is like that: > > <start code> > Public WithEvents mctlListView As MSComctlLib.Listview > > Function mInit(lctlListView) ' I tried lctlListView As Object, lctlListView > as ListView and lctlListView as MSComctlLib.Listview > ' stores a pointer to the control > Set mctlListView = lctlListView > End Function > <endcode> > > In the Form_Load, I have the following: > <start code> > Dim lclsListView As clsListView > Set lclsListView = New clsListView > > lclsListView.mInit Me.VueListe ' Me.VueListe is the listview control > <end code> > > The mInit function gets executed but Set mctlListView = lctlListView gives > an err.number=13 > Type mismatch. > > Then the control in not stored within the mctlListView variable, and the no > events are sunk. > > Do you a have any idee what I did wronh? > > TIA, > > Philippe > > > > 2009/3/5 jwcolby <jwcolby at colbyconsulting.com> > >> philippe >> >> My guess is that you don't need to set the OnClick event property to [Event >> Procedure] the way that >> you do in Access. >> >> Comment out that line. It should then compile. If it lets you dimension >> the variable WithEvents, >> and you can compile, then you will probably be able to sink the events. >> >> If it does in fact compile then instantiate the class and cause an event to >> fire (that you are >> sinking) and blace a breakpoint in the event sink in your class. See if >> you get control. >> >> I seem to remember building a class for the serial port of that same >> control ocx, and it worked just >> fine. Of course that was back in the early 80s and I have since lost my >> copy of the control. That >> is the one that came with VB6, and that you have to have a license to use? >> >> John W. Colby >> www.ColbyConsulting.com >> >> >> philippe pons wrote: >>> Hi all, >>> >>> Following John W. Colby lectures on classes (thank's to him once again), >> I >>> tried to build one for a ListView control. >>> It's an ActiveX that resides within the mscomctl.ocx. >>> >>> I déclared a clsListView. >>> In the header of the class I declared: >>> >>> Private WithEvents mctlListView As MSComctlLib.Listview >>> Private Const cstrEvProc As String = "[Event Procedure]" >>> >>> NB: omitting the name of the class:MSComctlLib leads to an error msg when >>> compiling. >>> >>> Then the init function: >>> >>> Function mInit(lctlListView As ComboBox) >>> ' stores a pointer to the control >>> Set mctlListView = lctlListView >>> ' affecte la chaine [Event Procedure] aux propriétés événementielles >>> mctlListView.OnClick = cstrEvProc >>> ' mctlListView.ondbkclick = cstrEvProc >>> End Function >>> >>> The problem is that the OnClick property gives a compile error! >>> The ListView control has an Click event, but no OnClick property. >>> >>> If you look at the ListView control in the object brower, it appears that >> it >>> has no event property, just events! >>> >>> I'm afraid it will not be easy to use a class control for this control >> and >>> be able to sink events, what is what I need to do. >>> >>> Any tricks, brothers? >>> >>> Regards, >>> >>> Philippe >> -- >> AccessD mailing list >> AccessD at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/accessd >> Website: http://www.databaseadvisors.com >>