Virtual Developer Workshop: Containerized Development with Docker
How to use the QListCtrl?
Obviously before inserting in a project, the control needs to be registered. How? You can do this with regsrv32, or ActiveX Test Container in Visual C++. Visual Basic has already a module to add new ActiveX controls, by clicking right button in control toolbox and select then the Add component item menu.
Everybody knows how to insert a new ActiveX Component in his project. In Visual C++ user have to select Project \ Add to project \ Components and Controls \ Registered ActiveX Controls, and to choose the wished control from the list. After the QlistCtrl ActiveX Control has been inserted the wizard will insert new classes in your project: CQListCtrl and COleFont. In Visual Basic it is even more simple to add this component to your project.
_DQListCtrl – interface of this control. It contains all properties and members of QlistCtrl Control, such as Header, InitItemsCount, and so on. If user want to set a new header to his control at runtime he have to call the Header property. This property is a string property and it contains all names, width and justify of columns. How? Here a sample: Column 1:128:Right|Column 2:146:Center. What this means? The control will have two columns, one called Column 1, with width 128, and right justify, and another column Column 2, with 146 as width, and Center as justify. Few words about InitItemsCount. When user uses this control, he need to call this function, before to show the control. That function will generate a event ItemsCount. If your parent of control receive the event, he need to put in parameter passed the number of items that will be loaded.
_DQListCtrlEvents – events interface of this control. The control supports the following events:
void ItemsCount(long* nItemsCount); - override this event to put number of items into nItemsCount
void AllItemsLoaded(); - this events announce that the control has already loads all items.
void LoadLabel(long nIndex, BSTR* sText, long* lParam) – it asks owner to give the label of nIndex item, and the user data of this item in lParam parameter.
void LoadSubItem(long nIndex, long nSubIndex, BSTR* sText); - it asks owner to give nSubIndex subcolumn of item nIndex into sText.
CQListCtrlCtrl– implementation of interfaces _DQListCtrl and _DQListCtrlEvents. This class is derived from ColeControl, so can be view as a ole control, but the contained window is a SysListView32 window.
Property Page of QlistCtrl
Requirements of control to work.
Before to use the control user must call InitItemsCount() method, for sample in OnInitDialog (for dialog), or OnInitialUpdate( for CformView), or in FormLoad in Visual Basic. This function will generate the event: ItemsCount: User have to choise from wizard the event and override it. As parameter user will receive a pointer to a long value. He needs to put in the content of this value the number of lines that will be added to qlistcontrol. Another events that user must override is LoadLabel. As parameters user will receive the nIndex , pointer to a string where user must put the labet of item nIndex, and at lParam parameter content, user have to put a particular data of nIndex item. The last event that user must override is LoadSubItem. This has the same specification as LoadLabel, only that with this user can fill the subitem of a nIndex item.