TVM_SETBKCOLOR和TREEVIEW_SETBKCOLOR在此范围中未声明

TVM_SETBKCOLOR and TreeView_SetBkColor not declared in this scope?

本文关键字:SETBKCOLOR 范围 未声明 TREEVIEW TVM      更新时间:2023-10-16

我会得到奇怪的范围错误:'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));

但是我遇到了相同的错误。发生了什么事?

(环境:code :: blocks,mingw,win7 x64)

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

> > > >

换句话说,_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) */