gpt4 book ai didi

c++ - TVM_SETBKCOLOR 和 TreeView_SetBkColor 未在此范围内声明?

转载 作者:行者123 更新时间:2023-11-30 04:23:38 24 4
gpt4 key购买 nike

我收到奇怪的范围错误:'TVM_SETBKCOLOR' 未在此范围内声明 并且类似的 'TreeView_SetBkColor' 未在此范围内声明。我不明白为什么会这样:

  • 我已经包含了 commctrl.h
  • 其他 treeview 宏工作正常(如 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));

但是我得到了同样的错误。怎么回事?

(环境:Code::Blocks、MinGW、Win7 x64)

最佳答案

TVM_SETBKCOLOR消息及其相关 TreeView_SetBkColor()仅当应用程序指定目标系统上必须安装 Internet Explorer 4 或更高版本时才定义宏。

换句话说,_WIN32_IE 预处理器符号必须设置为 0x0400 或更高。

头文件的相关部分(Windows SDK 7.0A版CommCtrl.h的5752行到5792行)是:

#if (_WIN32_IE >= 0x0400)

/* [get/set item height...] */

#define TVM_SETBKCOLOR (TV_FIRST + 29)
#define TreeView_SetBkColor(hwnd, clr) \
(COLORREF)SNDMSG((hwnd), TVM_SETBKCOLOR, 0, (LPARAM)(clr))

#define TVM_SETTEXTCOLOR (TV_FIRST + 30)
#define TreeView_SetTextColor(hwnd, clr) \
(COLORREF)SNDMSG((hwnd), TVM_SETTEXTCOLOR, 0, (LPARAM)(clr))

#define TVM_GETBKCOLOR (TV_FIRST + 31)
#define TreeView_GetBkColor(hwnd) \
(COLORREF)SNDMSG((hwnd), TVM_GETBKCOLOR, 0, 0)

#define TVM_GETTEXTCOLOR (TV_FIRST + 32)
#define TreeView_GetTextColor(hwnd) \
(COLORREF)SNDMSG((hwnd), TVM_GETTEXTCOLOR, 0, 0)

/* [get/set scroll time...] */

/* [get/set insert mark color...] */

#endif /* (_WIN32_IE >= 0x0400) */

关于c++ - TVM_SETBKCOLOR 和 TreeView_SetBkColor 未在此范围内声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13264378/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com