QListCtrl - a popup list box Control like that in Visual C++ 6.0

If you have seen VC++ 6.0 or Visual Basic 5.0 at any time you can call a list of all attributes, members of a context variable by pressing Ctrl+<Space>. The list contains many items (members) in some cases. The list cannot be filled with all the items at runtime, because it takes long time. So I designed a some kind of control as ActiveX .

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.

Few classes used in QlistCtrl Control

_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.

Download source - 34 KB

Download Demo - 2 KB



Comments

  • You mean like Intellisense

    Posted by Legacy on 10/09/2000 12:00am

    Originally posted by: Aykut

    This feature of Visual Studio is called IntelliSense. (before I learnt this I though that it was a hardware product of ms.)

    Reply
  • Error in VC ++ 6.0

    Posted by Legacy on 08/24/2000 12:00am

    Originally posted by: Vinh Nguyen

    error C2084: function 'unsigned short *__stdcall AtlA2WHelper(unsigned short *,const char *,int)' already has a body
    Please add information on your settings.

    Your sincerely
    Vinh Nguyen

    Reply
  • One more addition

    Posted by Legacy on 05/06/1999 12:00am

    Originally posted by: Yumiko Sankranti

    I had a modal dialog which in turn called our modeless (pretending to be modal) dialog. Although the parent was being enabled in the OnDestroy() method, it was somehow not being activated ie., another window would show up. To fix that, I added the following line to the OnDestroy() method:
    GetParent()->SetActiveWindow ( );

    Reply
  • QListCtrl - a popup list box Control like that in Visual C++ 6.0

    Posted by Legacy on 11/11/1998 12:00am

    Originally posted by: Jim Behm

    How about an example project that uses it in either VC or VB. 
    
    

    Can you put a screenshot on the webpage so we can see what it looks like in action?

    I had to make numerous changes to get it to build. Specifically regarding UNICODE.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • A modern mobile IT strategy is no longer an option, it is an absolute business necessity. Today's most productive employees are not tied to a desk, an office, or a location. They are mobile. And your company's IT strategy has to be ready to support them with easy, reliable, 24/7 access to the business information they need, from anywhere in the world, across a broad range of communication devices. Here's how some of the nation's most progressive corporations are meeting the many needs of their mobile workers …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds