c++ - Win32 API ListView 创建 (C++)

标签 c++ winapi mingw win32gui

我想用 C++ 创建一个 ListView。 到目前为止我的代码:

InitCommonControls(); // Force the common controls DLL to be loaded.
HWND list;

// window is a handle to my window that is already created.
list = CreateWindowEx(0, (LPCSTR) WC_LISTVIEWW, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_SHOWSELALWAYS | LVS_REPORT, 0, 0, 250, 400, window, NULL, NULL, NULL);

LVCOLUMN lvc; 
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.iSubItem = 0;
lvc.pszText = "Title";
lvc.cx = 50;
lvc.fmt = LVCFMT_LEFT;
ListView_InsertColumn(list, 0, &lvc);

但是如果我编译并执行代码,只会显示一个空白窗口。编译器:Windows 7 (x86) 上的 MinGW。

谁能帮我正确显示 ListView ?

最佳答案

这里是原始 MSDN 示例代码的链接 ListView control用 Windows API 和 C 编写。 它在 VC++ 2010 中编译。

关于c++ - Win32 API ListView 创建 (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13979371/

相关文章:

php - 使用 PHP 和 C 从 svn diff 文件获取文件路径

c# - 不同程序中的鼠标模拟

c++ - Gtkmm 程序编译正常但崩溃 - Windows XP

c++ - 从基调用派生类的隐藏(非虚拟)方法

c++ - 使用 repeat 将 Boost Spirit Qi 存储到 std::vector 中会导致模棱两可的类模板实例化

c++ - 使用普通指针和 shared_ptr 的行为差异

winapi - TightVNC Viewer 通过 Autohotkey 脚本无缝窗口(或镜像 Windows 应用程序窗口)

c - DllMain 中没有中断的开关/大小写

c++ - 对齐、总大小和 SSE

c++ - 错误 : Invalid Use of Incomplete Type 'Class Stack<int>' [enabled by default]