Use of general controls for C language SDK programming -- listview

Source: Internet
Author: User

1. The listview control is one of the general controls. You must use the general controls in SDK programming.

Comctl32.dll must be included, so the header file commctrl. h must be included in the Code: comctl32.lib

Before using a universal control, call initcommoncontrols ();

Take the listview control as an example:

Initcommoncontrols ();

 

// Use listview as a subwindow

Createmediawex (0,
// Extended Style

Wc_listview,
// This is the macro defined by the system. It corresponds to wc_listview.
"Syslistview32"


"123 ",
// Window title

Ws_child | ws_visible | ws_clipsiblings | ws_clipchildren

| Lvs_report | lvs_autoarrange | lvs_showselalways


| Lvs_shareimagelists | lvs_singlesel,
// Window style
(The general control style is set here, and the extension style must be set separately)
0,


0,
// Window size

420,
// The width must be equal to the sum of the width of all columns. Otherwise, the empty column appears.

600,


Hwnd,
// Parent window handle

Null,
// Menu handle

Hinstance,
// Instance handle

Null
// Create parameters

);


// You can also use the subcontrol in the resource file of the dialog box.

Control "", idc_listview, "syslistview32", ws_border | ws_tabstop
| Lvs_report | lvs_autoarrange | lvs_showselalways | lvs_#imagelists | lvs_singlesel,
7,110,300,133

 

Ii. Related Function operations

Because it is SDK programming, the control operation is implemented by sending sendmessage () to the control.

Related Messages in listview are:

1. Set the foreground and background color of text in lvm_settextcolor and lvm_settextbkcolor messages.

2. lvm_getnextitem finds the selected row. corresponding to the listview_getnextitem macro, sendmessage is packaged as a function operation.

3. lvm_setcolumnwidth sets the column width, which corresponds to listview_setcolumnwidth.

4. lvm_setextendedlistviewstyle: lvs_ex_fullrowselect (select an entire line), lvs_ex_gridlines (network line), lvs_ex_checkboxes (select button), corresponding to listview_setextendedlistviewstyle

5. lvm_insertcolumn inserts a new column, corresponding to listview_insertcolumn

6. lvm_insertitem inserts a project (ROW), corresponding to listview_insertitem

7. Set the subitem lvm_setitem (each column in the row), corresponding to listview_setitem

8. The number of items obtained by lvm_getitemcount corresponds to listview_getitemcount.

9. The lvm_deleteitem is deleted, corresponding to listview_deleteitem.

There are still a lot of messages about the selected response that will not be listed. You can find them in the corresponding header file.

C:/program files/Microsoft sdks/Windows/v6.0a/include/commctrl. h

 

Iii. Related Structure

//
// Configure column attributes
//
Typedef struct _ lvcolumn
{

// Indicates which Members in the structure are valid, and lvcf_fmt = FMT is valid,
// Lvcf_subitem = isubitem valid, lvcf_text = psztext valid, lvcf_width = Lx valid
Uint mask;

// Column alignment
Int FMT;

// The initial width of the column. You can send the message lvm_setcolumnwidth later to change the column width.
Int CX;

// Column Title
Lptstr psztext;

// The size of the buffer to which psztext points
Int cchtextmax;

// The index value of the subitem associated with the column, starting from 0. You can send the lvm_getcolumn message when you want to query the column attributes,
// Specify the lvcf_subitem flag in the member variable imask,
// The list control returns the isubitem value set during insertion in isubitem.
Int isubitem;

// Specify the image index value in the image list associated with the column
Int iimage;

// Column number. 0 indicates the leftmost column.
Int iorder;

} Lvcolumn, far * lplvcolumn;

 

 

//
// Configuration item, add a project to it by sending the lvm_insertitem message to the List View
//
Typedef struct _ lvitem

{

// Describe which members are valid in the lvitem Structure
Uint mask;

// The index value of the project (which can be regarded as the row number) starts from 0.
Int iItem;

// The index value of the subitem (which can be regarded as the column number) starts from 0.
Int isubitem;

// Subitem status, whether there are focal points/High Brightness Display/selected (due to cut)/selected
// The index based on 1 is also included to indicate whether to use overlapping or status icons.
Uint state;

// Valid shielding bits in the status
Uint statemask;

// Name of the primary or subitem
Lptstr psztext;

// The buffer size pointed to by psztext
Int cchtextmax;

// Associate the index value of the specified image in the image list
Int iimage;

// The 32-bit parameter defined by the program, which is used when you sort projects.
// When you tell the List View to sort items, the List View compares items in pairs.
// It will pass the lparam value of the two projects to you, so that you can first list the two projects by comparing them.
Lparam;

// The unit that indicates the indent of the Image Position
Int iindent;

} Lvitem, far * lplvitem;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.