#include <Windows.h>
#include <commctrl.h>
// 必须要进行前导声明
LRESULT CALLBACK WindowProc(
_In_ HWND hwnd,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
HINSTANCE ID_启动勾选项, ID_全部结束, ID_导入帐号,ID_添加帐号, ID_保持本窗口总在最前,ID_黑屏优化,ID_最小化游戏,ID_列表框;
HFONT hf;
HWND 句柄_启动勾选项, 句柄_全部结束, 句柄_导入帐号, 句柄_添加帐号, 句柄_保持本窗口总在最前, 句柄_黑屏优化, 句柄_最小化游戏,句柄_列表框;
LV_ITEM 项;
LV_COLUMN 列;
// 程序入口点
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
// 类名
WCHAR* cls_Name = L"My Class";
// 设计窗口类
WNDCLASS wc = { 0 };
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpfnWndProc = WindowProc;
wc.lpszClassName = cls_Name;
wc.hInstance = hInstance;
wc.style = CS_HREDRAW | CS_VREDRAW;
// 注册窗口类
RegisterClass(&wc);
InitCommonControls();
// 创建窗口
HWND hwnd = CreateWindow(
cls_Name, //类名,要和刚才注册的一致
L"2rijkirj3", //窗口标题文字
WS_OVERLAPPEDWINDOW, //窗口外观样式
0, //窗口相对于父级的X坐标
0, //窗口相对于父级的Y坐标
800, //窗口的宽度
600, //窗口的高度
NULL, //没有父窗口,为NULL
NULL, //没有菜单,为NULL
hInstance, //当前应用程序的实例句柄
NULL); //没有附加数据,为NULL
if (hwnd == NULL) //检查窗口是否创建成功
return 0;
//取得字体
hf = CreateFont(14, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
1, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
DEFAULT_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
TEXT("常规")); // lpszFacename
// 显示窗口
ShowWindow(hwnd, SW_SHOW);
// 更新窗口
UpdateWindow(hwnd);
//改变窗口字体
SendMessage(句柄_启动勾选项, WM_SETFONT, (WPARAM)hf, TRUE);
SendMessage(句柄_全部结束, WM_SETFONT, (WPARAM)hf, TRUE);
SendMessage(句柄_导入帐号, WM_SETFONT, (WPARAM)hf, TRUE);
SendMessage(句柄_添加帐号, WM_SETFONT, (WPARAM)hf, TRUE);
SendMessage(句柄_保持本窗口总在最前, WM_SETFONT, (WPARAM)hf, TRUE);
SendMessage(句柄_黑屏优化, WM_SETFONT, (WPARAM)hf, TRUE);
SendMessage(句柄_最小化游戏, WM_SETFONT, (WPARAM)hf, TRUE);
// 消息循环
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
// 在WinMain后实现
LRESULT CALLBACK WindowProc(
_In_ HWND hwnd,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
switch (uMsg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
case WM_CREATE:
{
//创建按钮
句柄_启动勾选项 = CreateWindow(L"Button", L"启动勾选项", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
10, 10, 80, 20, hwnd, NULL, ID_启动勾选项, NULL);
句柄_全部结束 = CreateWindow(L"Button", L"全部停止", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
100, 10, 80, 20, hwnd, NULL, ID_全部结束, NULL);
句柄_导入帐号 = CreateWindow(L"Button", L"导入帐号", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
190, 10, 80, 20, hwnd, NULL, ID_导入帐号, NULL);
句柄_添加帐号 = CreateWindow(L"Button", L"添加帐号", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
280, 10, 80, 20, hwnd, NULL, ID_添加帐号, NULL);
句柄_保持本窗口总在最前 = CreateWindow(
TEXT("button"), TEXT("保持本窗口总在最前"),
WS_CHILD | WS_VISIBLE | BS_LEFT | BS_AUTOCHECKBOX/*复选框*/,
370, 10, 160, 20,
hwnd, NULL, ID_保持本窗口总在最前, NULL
);
句柄_黑屏优化 = CreateWindow(
TEXT("button"), TEXT("黑屏优化"),
WS_CHILD | WS_VISIBLE | BS_LEFT | BS_AUTOCHECKBOX/*复选框*/,
550, 10, 80, 20,
hwnd, NULL, ID_黑屏优化, NULL
);
句柄_最小化游戏 = CreateWindow(
TEXT("button"), TEXT("最小化游戏"),
WS_CHILD | WS_VISIBLE | BS_LEFT | BS_AUTOCHECKBOX/*复选框*/,
650, 10, 100, 20,
hwnd, NULL, ID_最小化游戏, NULL
);
句柄_列表框=CreateWindow(TEXT("syslistview32"), TEXT("") ,
WS_VISIBLE | WS_CHILD | WS_BORDER |
LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EX_CHECKBOXES,
10, 60,
770,
280,
hwnd, NULL, ID_列表框, NULL);
ListView_SetExtendedListViewStyleEx(句柄_列表框, 0, //hwnd_list为list控件句柄
LVS_EX_GRIDLINES | //网格
LVS_EX_FULLROWSELECT | //选择全行
LVS_EX_TWOCLICKACTIVATE );
ZeroMemory(&项, sizeof(LV_ITEM));
ZeroMemory(&列, sizeof(LV_COLUMN));
//项.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; // 风格
//项.pszText = TEXT("进程名"); // 文字
//
//SendMessage(句柄_列表框, LVM_INSERTCOLUMN, 0, (LPARAM)&项);
列.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
列.pszText = L"";//列标题
列.cx = 20;//列宽
列.iSubItem = 0;//子项索引,第一列无子项
ListView_InsertColumn(句柄_列表框, 0, &列);
列.pszText = L"索引";//列标题
列.cx = 40;//列宽
列.iSubItem = 1;//子项索引,第一列无子项
ListView_InsertColumn(句柄_列表框, 1, &列);
列.pszText = L"帐号";
列.cx = 80;
列.iSubItem = 2;//子项索引
ListView_InsertColumn(句柄_列表框, 2, &列);
列.pszText = L"角色位置";
列.cx = 60;
列.iSubItem = 3;//子项索引
ListView_InsertColumn(句柄_列表框, 3, &列);
列.pszText = L"执行脚本";
列.cx = 60;
列.iSubItem = 4;//子项索引
ListView_InsertColumn(句柄_列表框, 4, &列);
列.pszText = L"运行状态";
列.cx = 60;
列.iSubItem = 5;//子项索引
ListView_InsertColumn(句柄_列表框, 5, &列);
列.pszText = L"角色名称";
列.cx = 60;
列.iSubItem = 6;//子项索引
ListView_InsertColumn(句柄_列表框, 6, &列);
列.pszText = L"职业";
列.cx = 40;
列.iSubItem = 7;//子项索引
ListView_InsertColumn(句柄_列表框, 7, &列);
列.pszText = L"等级";
列.cx = 40;
列.iSubItem = 8;//子项索引
ListView_InsertColumn(句柄_列表框, 8, &列);
列.pszText = L"经验";
列.cx = 40;
列.iSubItem = 9;//子项索引
ListView_InsertColumn(句柄_列表框, 9, &列);
列.pszText = L"地图&座标";
列.cx = 100;
列.iSubItem = 10;//子项索引
ListView_InsertColumn(句柄_列表框, 10, &列);
列.pszText = L"金币&物品";
列.cx = 100;
列.iSubItem = 11;//子项索引
ListView_InsertColumn(句柄_列表框, 11, &列);
列.pszText = L"游戏状态";
列.cx = 70;
列.iSubItem = 12;//子项索引
ListView_InsertColumn(句柄_列表框, 12, &列);
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
问题:为什麽我的listview加不上checkbox,
句柄_列表框=CreateWindow(TEXT("syslistview32"), TEXT("") ,
WS_VISIBLE | WS_CHILD | WS_BORDER |
LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EX_CHECKBOXES,
10, 60,
770,
280,
hwnd, NULL, ID_列表框, NULL);
我明明加了 LVS_EX_CHECKBOXES
照道理来说是要有前面有个复选框的效果额
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课