读书人

code:blocks里用listview的有关问题

发布时间: 2012-06-14 16:00:31 作者: rapoo

code::blocks里用listview的问题

C/C++ code
#define WIN32_LEAN_AND_MEAN#include <windows.h>#include <CommCtrl.h>#include "resource.h"#include "rsrc.inc"HINSTANCE hInst;BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam){    HWND lsv;    switch(uMsg)    {        case WM_INITDIALOG:            /*             * TODO: Add code to initialize the dialog.             */             InitCommonControls();             lsv = GetDlgItem(hwndDlg,IDC_LSV1);             ListView_SetExtendedListViewStyle(lsv,LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);            return TRUE;        case WM_CLOSE:            EndDialog(hwndDlg, 0);            return TRUE;        case WM_COMMAND:            switch(LOWORD(wParam))            {                /*                 * TODO: Add more control ID's, when needed.                 */                case IDC_BTN_QUIT:                    EndDialog(hwndDlg, 0);                    return TRUE;                case IDC_BTN_TEST:                    MessageBox(hwndDlg, "You clicked \"Test\" button!", "Information", MB_ICONINFORMATION);                    return TRUE;            }    }    return FALSE;}int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){    hInst = hInstance;    // The user interface is a modal dialog box    return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DialogProc);}


刚开始用CB就碰到难题了。。。来求助于各位大侠了
以上这段代码,一编译就出现如下错误,请问是怎么回事?
error: 'LVS_EX_GRIDLINES' was not declared in this scope
error: 'LVS_EX_FULLROWSELECT' was not declared in this scope
error: 'ListView_SetExtendedListViewStyle' was not declared in this scope

Link里也把comctl32.lib加上了,为什么会出现这种错误啊

[解决办法]
不知道你用的什么编译器
前面像说的用的gcc

后边又说把comctl32.lib加上了,那么这是vc的说法

这里假设你用的是mingw gcc系列

CommCtrl.h
改为小写的
commctrl.h

如果不行就是你的mingw gcc头文件缺少部分声明

自行加入
C/C++ code
#define LVS_EX_GRIDLINES 0x1#define LVS_EX_FULLROWSELECT 0x20#define ListView_SetExtendedListViewStyle(hwndLV,dw) (DWORD)SNDMSG((hwndLV),LVM_SETEXTENDEDLISTVIEWSTYLE,0,dw) 

读书人网 >C++

热点推荐