From bb448552973769217dbbdfd25806a462351d4ba5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 3 Jan 2000 23:38:57 +0000 Subject: [PATCH] 1. wxTreeCtrl::SetBackgroundColour() works (with new comctl32 anyhow) 2. wxToolTip should work with old comctl32 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5225 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/treectrl.h | 4 ++++ src/msw/tooltip.cpp | 19 ++++++++++++++++--- src/msw/treectrl.cpp | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index eef174b0c4..a3b3a95cf8 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -442,6 +442,10 @@ public: virtual bool MSWCommand(WXUINT param, WXWORD id); virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); + // override some base class virtuals + virtual bool SetBackgroundColour(const wxColour &colour); + virtual bool SetForegroundColour(const wxColour &colour); + // get/set the check state for the item (only for wxTR_MULTIPLE) bool IsItemChecked(const wxTreeItemId& item) const; void SetItemCheck(const wxTreeItemId& item, bool check = TRUE); diff --git a/src/msw/tooltip.cpp b/src/msw/tooltip.cpp index 0aa577b1aa..f594903e77 100644 --- a/src/msw/tooltip.cpp +++ b/src/msw/tooltip.cpp @@ -63,10 +63,11 @@ static WNDPROC gs_wndprocToolTip = (WNDPROC)NULL; // private classes // ---------------------------------------------------------------------------- -// a simple wrapper around TOOLINFO Win32 structure +// a wrapper around TOOLINFO Win32 structure #ifdef __VISUALC__ #pragma warning( disable : 4097 ) // we inherit from a typedef - so what? #endif + class wxToolInfo : public TOOLINFO { public: @@ -75,11 +76,24 @@ public: // initialize all members ::ZeroMemory(this, sizeof(TOOLINFO)); + // the structure TOOLINFO has been extended with a 4 byte field in + // version 4.70 of comctl32.dll and if we compile on a newer machine + // but run on one with the old version of comctl32, nothing will work + // because the library will detect that we rely on a more recent + // version of it. So we always use the old size - if we ever start + // using our lParam member, we'd have to check for comctl32 version + // during run-time +#if defined(_WIN32_IE) && (_WIN32_IE >= 0x0300) + cbSize = sizeof(TOOLINFO) - sizeof(LPARAM); +#else // old headers cbSize = sizeof(TOOLINFO); +#endif // compile-time comctl32.dll version + uFlags = TTF_IDISHWND; uId = (UINT)hwnd; } }; + #ifdef __VISUALC__ #pragma warning( default : 4097 ) #endif @@ -252,8 +266,7 @@ void wxToolTip::Add(WXHWND hWnd) if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) ) { - wxLogSysError(_("Failed to create the tooltip '%s'"), - m_text.c_str()); + wxLogDebug(_T("Failed to create the tooltip '%s'"), m_text.c_str()); } } diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index a470179ed7..b309b70702 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -62,6 +62,16 @@ #define TVIS_FOCUSED 0x0001 #endif +#ifndef TV_FIRST + #define TV_FIRST 0x1100 +#endif + +// old headers might miss these messages (comctl32.dll 4.71+ only) +#ifndef TVM_SETBKCOLOR + #define TVM_SETBKCOLOR (TV_FIRST + 29) + #define TVM_SETTEXTCOLOR (TV_FIRST + 30) +#endif + // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -484,6 +494,30 @@ size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, return counter.GetCount() - 1; } +// ---------------------------------------------------------------------------- +// control colours +// ---------------------------------------------------------------------------- + +bool wxTreeCtrl::SetBackgroundColour(const wxColour &colour) +{ + if ( !wxWindowBase::SetBackgroundColour(colour) ) + return FALSE; + + SendMessage(GetHwnd(), TVM_SETBKCOLOR, 0, colour.GetPixel()); + + return TRUE; +} + +bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) +{ + if ( !wxWindowBase::SetForegroundColour(colour) ) + return FALSE; + + SendMessage(GetHwnd(), TVM_SETTEXTCOLOR, 0, colour.GetPixel()); + + return TRUE; +} + // ---------------------------------------------------------------------------- // Item access // ---------------------------------------------------------------------------- -- 2.45.2