我收到了奇怪的范围错误:'TVM_SETBKCOLOR' was not declared in this scope
和类似'TreeView_SetBkColor' was not declared in this scope
的 . 我不知道为什么会这样:
- 我已经包括
commctrl.h
- 其他树视图宏工作正常(如
TreeView_DeleteItem
) - 自动完成识别并完成
TreeView_SetBkColor
,所以这不是拼写问题 - 我很好地阅读了文档
这是适用窗口的片段。一切正常,直到我尝试更改tvw_filelist_
变量的背景。
void PnlTree::Init(HWND hwnd0, const char * superclassname0) {
tvw_filelist_ = CreateWindowEx (0,
superclassname0, NULL,
TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CHILD | WS_VISIBLE,
0, 0, 0, 0,
hwnd0, (HMENU) IDC_TVWFILELIST, NULL, NULL
);
txt_blurb0_ = CreateWindowEx (0,
TEXT("STATIC"), "Drag files and folders into this pane.",
SS_CENTER | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE,
0, 0, 0, 0,
hwnd0, NULL, NULL, NULL
);
txt_blurb1_ = CreateWindowEx (0,
TEXT("STATIC"), "Press DELETE to remove an entry.",
SS_CENTER | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE,
0, 0, 0, 0,
hwnd0, NULL, NULL, NULL
);
HFONT hFont = CreateFont(15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Segoe UI");
::SendMessage(txt_blurb0_, WM_SETFONT, (WPARAM) hFont, 0);
::SendMessage(txt_blurb1_, WM_SETFONT, (WPARAM) hFont, 0);
// Everything works perfectly, if this line is commented out.
TreeView_SetBkColor(tvw_filelist_, RGB(235, 235, 235));
}
//
//
//
void PnlTree::RemoveItem(WPARAM wParam) {
if (wParam == VK_DELETE) {
TreeView_DeleteItem(tvw_filelist_, TreeView_GetSelection(tvw_filelist_));
}
}
我也试过
::SendMessage(tvw_filelist_, TVM_SETBKCOLOR, 0, RGB(235, 235, 235));
但我得到同样的错误。这是怎么回事?
(环境:代码::块,MinGW,Win7 x64)