#1897 Listview title info struct missing from commctrl.h

WSL
pending
Feature
later
Feature_in_WSL_4.1
False
2015-01-04
2010-10-20
Aaron
No

Installed from mingw-get-inst-20100909.exe on (10/20/2010)

I've just noticed that LVTILEVIEWINFO and associated constants are missing from commctrl.h. Not a big deal to workaround though.

typedef struct LVTILEVIEWINFO {
UINT cbSize;
DWORD dwMask;
DWORD dwFlags;
SIZE sizeTile;
int cLines;
RECT rcLabelMargin;
} LVTILEVIEWINFO, *PLVTILEVIEWINFO;

#define LVTVIF_AUTOSIZE 0x00000000
#define LVTVIF_FIXEDWIDTH 0x00000001
#define LVTVIF_FIXEDHEIGHT 0x00000002
#define LVTVIF_FIXEDSIZE 0x00000003

#define LVTVIM_TILESIZE 0x00000001
#define LVTVIM_COLUMNS 0x00000002
#define LVTVIM_LABELMARGIN 0x00000004

#define LV_VIEW_TILE 0x0004

For example :-

bool InitListView()
{
int num_icons, i;
HICON hIcon;
LVCOLUMN lvc;
LVITEM lvi = {0};

// Get handle to the list view control
hListview = ::GetDlgItem(hDlg,IDL_DLG1);

// Image list handles
hImageNormal = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CXICON), ILC_COLOR32 | ILC_MASK,1,1);
hImageSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1);

if (!hImageNormal || !hImageSmall)
return false;

// Use the standard windows shell icons
num_icons = static_cast<int>(reinterpret_cast<INT_PTR>(ExtractIcon(0,"shell32.dll",static_cast<UINT>(-1))));

for (i = 0; i < num_icons; ++i)
{
hIcon = ExtractIcon(0,"shell32.dll",i);

// Add to img list
ImageList_AddIcon(hImageNormal,hIcon);
ImageList_AddIcon(hImageSmall, hIcon);

DestroyIcon(hIcon);
}

// Add Icon to our view
ListView_SetImageList(hListview,hImageNormal,LVSIL_NORMAL);
ListView_SetImageList(hListview,hImageSmall,LVSIL_SMALL);

// Two cols
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;

char *headers[] = { "Col 1", "Col 2" };

for (i = 0; i < 2; i++)
{
lvc.iSubItem = i;
lvc.pszText = headers[i];
lvc.cx = 100;

if (!i)
lvc.fmt = LVCFMT_LEFT;
else
lvc.fmt = LVCFMT_RIGHT;

if (ListView_InsertColumn(hListview, i, &lvc) == -1)
return false;
}

// Title info
LVTILEVIEWINFO tvi = {0};

tvi.cbSize = sizeof(tvi);
tvi.dwMask = LVTVIM_COLUMNS;
tvi.cLines = 2;

ListView_SetTileViewInfo(hListview, &tvi);

lvi.mask = LVIF_TEXT | LVIF_IMAGE |LVIF_STATE;
lvi.iSubItem = 0;
lvi.state = 0;
lvi.stateMask = 0;
lvi.pszText = LPSTR_TEXTCALLBACK; // sends an LVN_GETDISPINFO message

for (i= 0; i < num_icons; i++)
{
lvi.iImage = i;

SendMessage(hListview,LVM_INSERTITEM,0,reinterpret_cast<LPARAM>(&lvi));

}

// Full row select
DWORD dwStyle = SendMessage(hListview,LVM_GETEXTENDEDLISTVIEWSTYLE,0,0); // get
dwStyle |= LVS_EX_FULLROWSELECT; // Add to current
SendMessage(hListview,LVM_SETEXTENDEDLISTVIEWSTYLE,0,dwStyle); // Send new

// Show the control
ShowWindow(hListview, SW_SHOW);
UpdateWindow(hListview);

return true;
}

Discussion

  • Keith Marshall

    Keith Marshall - 2010-10-25
    • labels: 103945 -->
     
  • Keith Marshall

    Keith Marshall - 2010-10-25

    Omitted support for a (possibly inadequately documented) feature isn't a bug; reclassifying as a feature request.

    How have you determined the appropriate values for the manifest constants? I don't see them enumerated on MSDN. Lack of legitimately accessible documentation is a valid reason for omission.

     
  • Aaron

    Aaron - 2010-10-25

    Hi Keith,

    I only noticed when porting a project from VS to gcc. The official docs on these structs are here - http://msdn.microsoft.com/en-us/library/bb774768%28VS.85%29.aspx

    Or more specifically for this issue here on msdn. http://msdn.microsoft.com/en-us/library/bb774768%28VS.85%29.aspx

    The values were taken from the header included in VS2005 commctrl.h. Here's what I stuck in the header.

    #ifndef MISSING_GCC_H_INCLUDED
    #define MISSING_GCC_H_INCLUDED

    /*
    mingw - missing
    */

    typedef struct LVTILEVIEWINFO {
    UINT cbSize;
    DWORD dwMask;
    DWORD dwFlags;
    SIZE sizeTile;
    int cLines;
    RECT rcLabelMargin;
    } LVTILEVIEWINFO, *PLVTILEVIEWINFO;

    #define LVTVIF_AUTOSIZE 0x00000000
    #define LVTVIF_FIXEDWIDTH 0x00000001
    #define LVTVIF_FIXEDHEIGHT 0x00000002
    #define LVTVIF_FIXEDSIZE 0x00000003

    #define LVTVIM_TILESIZE 0x00000001
    #define LVTVIM_COLUMNS 0x00000002
    #define LVTVIM_LABELMARGIN 0x00000004

    #define LV_VIEW_TILE 0x0004

    #endif // MISSING_GCC_H_INCLUDED

    Thanks
    Aaron

     
  • Earnie Boyd

    Earnie Boyd - 2013-02-15

    Ticket moved from /p/mingw/feature-requests/83/

     
  • Earnie Boyd

    Earnie Boyd - 2013-02-15
    • status: open --> pending
    • assigned_to: Earnie Boyd
    • milestone: --> WSL
    • type: --> Feature
    • resolution: --> later
    • category: --> Unknown
    • patch_attached: --> False
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-21
    • labels: --> needs review, needs test
    • category: Unknown --> Feature_in_WSL_4.1
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks