Remove checks GetComCtl32Version() aimed prior WinXP.

Windows XP always has ComCtl32Version 582 available. If the executable includes a manifest version 600 is available.
This commit is contained in:
Tobias Taschner
2015-08-28 10:22:37 +02:00
parent 4acb4cf476
commit 03b243da21
8 changed files with 176 additions and 264 deletions

View File

@@ -54,13 +54,6 @@ bool wxMSWDateControls::CheckInitialization()
// it's enough to give the error only once // it's enough to give the error only once
s_initResult = false; s_initResult = false;
if ( wxApp::GetComCtl32Version() < 470 )
{
wxLogError(_("This system doesn't support date controls, please upgrade your version of comctl32.dll"));
return false;
}
#if wxUSE_DYNLIB_CLASS #if wxUSE_DYNLIB_CLASS
INITCOMMONCONTROLSEX icex; INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(icex); icex.dwSize = sizeof(icex);

View File

@@ -70,9 +70,7 @@ WXDWORD wxDatePickerCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
{ {
WXDWORD styleMSW = wxDatePickerCtrlBase::MSWGetStyle(style, exstyle); WXDWORD styleMSW = wxDatePickerCtrlBase::MSWGetStyle(style, exstyle);
// although MSDN doesn't mention it, DTS_UPDOWN doesn't work with if ( style & wxDP_SPIN )
// comctl32.dll 4.72
if ( wxApp::GetComCtl32Version() > 472 && (style & wxDP_SPIN) )
styleMSW |= DTS_UPDOWN; styleMSW |= DTS_UPDOWN;
//else: drop down by default //else: drop down by default

View File

@@ -267,19 +267,14 @@ int wxDirDialog::ShowSHBrowseForFolder(WXHWND owner)
static const int verComCtl32 = wxApp::GetComCtl32Version(); static const int verComCtl32 = wxApp::GetComCtl32Version();
// we always add the edit box (it doesn't hurt anybody, does it?) if it is // we always add the edit box (it doesn't hurt anybody, does it?)
// supported by the system bi.ulFlags |= BIF_EDITBOX;
if ( verComCtl32 >= 471 )
{
bi.ulFlags |= BIF_EDITBOX;
}
// to have the "New Folder" button we must use the "new" dialog style which // to have the "New Folder" button we must use the "new" dialog style which
// is also the only way to have a resizable dialog // is also the only way to have a resizable dialog
// //
// "new" style is only available in the version 5.0+ of comctl32.dll
const bool needNewDir = !HasFlag(wxDD_DIR_MUST_EXIST); const bool needNewDir = !HasFlag(wxDD_DIR_MUST_EXIST);
if ( (needNewDir || HasFlag(wxRESIZE_BORDER)) && (verComCtl32 >= 500) ) if ( needNewDir || HasFlag(wxRESIZE_BORDER) )
{ {
if (needNewDir) if (needNewDir)
{ {

View File

@@ -277,26 +277,23 @@ bool wxListCtrl::Create(wxWindow *parent,
void wxListCtrl::MSWSetExListStyles() void wxListCtrl::MSWSetExListStyles()
{ {
// for comctl32.dll v 4.70+ we want to have some non default extended // we want to have some non default extended
// styles because it's prettier (and also because wxGTK does it like this) // styles because it's prettier (and also because wxGTK does it like this)
if ( wxApp::GetComCtl32Version() >= 470 ) ::SendMessage
{ (
::SendMessage GetHwnd(), LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
( // LVS_EX_LABELTIP shouldn't be used under Windows CE where it's
GetHwnd(), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, // not defined in the SDK headers
// LVS_EX_LABELTIP shouldn't be used under Windows CE where it's
// not defined in the SDK headers
#ifdef LVS_EX_LABELTIP #ifdef LVS_EX_LABELTIP
LVS_EX_LABELTIP | LVS_EX_LABELTIP |
#endif #endif
LVS_EX_FULLROWSELECT | LVS_EX_FULLROWSELECT |
LVS_EX_SUBITEMIMAGES | LVS_EX_SUBITEMIMAGES |
// normally this should be governed by a style as it's probably not // normally this should be governed by a style as it's probably not
// always appropriate, but we don't have any free styles left and // always appropriate, but we don't have any free styles left and
// it seems better to enable it by default than disable // it seems better to enable it by default than disable
LVS_EX_HEADERDRAGDROP LVS_EX_HEADERDRAGDROP
); );
}
} }
WXDWORD wxListCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const WXDWORD wxListCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
@@ -359,13 +356,6 @@ WXDWORD wxListCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
#if !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) ) #if !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) )
if ( style & wxLC_VIRTUAL ) if ( style & wxLC_VIRTUAL )
{ {
int ver = wxApp::GetComCtl32Version();
if ( ver < 470 )
{
wxLogWarning(_("Please install a newer version of comctl32.dll\n(at least version 4.70 is required but you have %d.%02d)\nor this program won't operate correctly."),
ver / 100, ver % 100);
}
wstyle |= LVS_OWNERDATA; wstyle |= LVS_OWNERDATA;
} }
#endif // ancient cygwin #endif // ancient cygwin
@@ -1622,7 +1612,7 @@ wxListCtrl::HitTest(const wxPoint& point, int& flags, long *ptrSubItem) const
long item; long item;
#ifdef LVM_SUBITEMHITTEST #ifdef LVM_SUBITEMHITTEST
if ( ptrSubItem && wxApp::GetComCtl32Version() >= 470 ) if ( ptrSubItem )
{ {
item = ListView_SubItemHitTest(GetHwnd(), &hitTestInfo); item = ListView_SubItemHitTest(GetHwnd(), &hitTestInfo);
*ptrSubItem = hitTestInfo.iSubItem; *ptrSubItem = hitTestInfo.iSubItem;
@@ -3280,40 +3270,36 @@ static void wxConvertToMSWListCol(HWND hwndList,
#ifdef NM_CUSTOMDRAW // _WIN32_IE >= 0x0300 #ifdef NM_CUSTOMDRAW // _WIN32_IE >= 0x0300
if ( item.m_mask & wxLIST_MASK_IMAGE ) if ( item.m_mask & wxLIST_MASK_IMAGE )
{ {
if ( wxApp::GetComCtl32Version() >= 470 ) lvCol.mask |= LVCF_IMAGE;
// we use LVCFMT_BITMAP_ON_RIGHT because the images on the right
// seem to be generally nicer than on the left and the generic
// version only draws them on the right (we don't have a flag to
// specify the image location anyhow)
//
// we don't use LVCFMT_COL_HAS_IMAGES because it doesn't seem to
// make any difference in my tests -- but maybe we should?
if ( item.m_image != -1 )
{ {
lvCol.mask |= LVCF_IMAGE; // as we're going to overwrite the format field, get its
// current value first -- unless we want to overwrite it anyhow
// we use LVCFMT_BITMAP_ON_RIGHT because the images on the right if ( !(lvCol.mask & LVCF_FMT) )
// seem to be generally nicer than on the left and the generic
// version only draws them on the right (we don't have a flag to
// specify the image location anyhow)
//
// we don't use LVCFMT_COL_HAS_IMAGES because it doesn't seem to
// make any difference in my tests -- but maybe we should?
if ( item.m_image != -1 )
{ {
// as we're going to overwrite the format field, get its LV_COLUMN lvColOld;
// current value first -- unless we want to overwrite it anyhow wxZeroMemory(lvColOld);
if ( !(lvCol.mask & LVCF_FMT) ) lvColOld.mask = LVCF_FMT;
if ( ListView_GetColumn(hwndList, col, &lvColOld) )
{ {
LV_COLUMN lvColOld; lvCol.fmt = lvColOld.fmt;
wxZeroMemory(lvColOld);
lvColOld.mask = LVCF_FMT;
if ( ListView_GetColumn(hwndList, col, &lvColOld) )
{
lvCol.fmt = lvColOld.fmt;
}
lvCol.mask |= LVCF_FMT;
} }
lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_IMAGE; lvCol.mask |= LVCF_FMT;
} }
lvCol.iImage = item.m_image; lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_IMAGE;
} }
//else: it doesn't support item images anyhow
lvCol.iImage = item.m_image;
} }
#endif // _WIN32_IE >= 0x0300 #endif // _WIN32_IE >= 0x0300
} }

View File

@@ -168,17 +168,12 @@ int wxSpinButton::GetValue() const
{ {
int n; int n;
#ifdef UDM_GETPOS32 #ifdef UDM_GETPOS32
if ( wxApp::GetComCtl32Version() >= 580 ) // use the full 32 bit range if available
{ n = ::SendMessage(GetHwnd(), UDM_GETPOS32, 0, 0);
// use the full 32 bit range if available #else
n = ::SendMessage(GetHwnd(), UDM_GETPOS32, 0, 0); // we're limited to 16 bit
} n = (short)LOWORD(::SendMessage(GetHwnd(), UDM_GETPOS, 0, 0));
else
#endif // UDM_GETPOS32 #endif // UDM_GETPOS32
{
// we're limited to 16 bit
n = (short)LOWORD(::SendMessage(GetHwnd(), UDM_GETPOS, 0, 0));
}
if (n < m_min) n = m_min; if (n < m_min) n = m_min;
if (n > m_max) n = m_max; if (n > m_max) n = m_max;
@@ -191,16 +186,11 @@ void wxSpinButton::SetValue(int val)
// wxSpinButtonBase::SetValue(val); -- no, it is pure virtual // wxSpinButtonBase::SetValue(val); -- no, it is pure virtual
#ifdef UDM_SETPOS32 #ifdef UDM_SETPOS32
if ( wxApp::GetComCtl32Version() >= 580 ) // use the full 32 bit range if available
{ ::SendMessage(GetHwnd(), UDM_SETPOS32, 0, val);
// use the full 32 bit range if available #else
::SendMessage(GetHwnd(), UDM_SETPOS32, 0, val); ::SendMessage(GetHwnd(), UDM_SETPOS, 0, MAKELONG((short) val, 0));
}
else // we're limited to 16 bit
#endif // UDM_SETPOS32 #endif // UDM_SETPOS32
{
::SendMessage(GetHwnd(), UDM_SETPOS, 0, MAKELONG((short) val, 0));
}
} }
void wxSpinButton::NormalizeValue() void wxSpinButton::NormalizeValue()
@@ -215,17 +205,13 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
wxSpinButtonBase::SetRange(minVal, maxVal); wxSpinButtonBase::SetRange(minVal, maxVal);
#ifdef UDM_SETRANGE32 #ifdef UDM_SETRANGE32
if ( wxApp::GetComCtl32Version() >= 471 ) // use the full 32 bit range if available
{ ::SendMessage(GetHwnd(), UDM_SETRANGE32, minVal, maxVal);
// use the full 32 bit range if available #else
::SendMessage(GetHwnd(), UDM_SETRANGE32, minVal, maxVal); // we're limited to 16 bit
} ::SendMessage(GetHwnd(), UDM_SETRANGE, 0,
else // we're limited to 16 bit (LPARAM) MAKELONG((short)maxVal, (short)minVal));
#endif // UDM_SETRANGE32 #endif // UDM_SETRANGE32
{
::SendMessage(GetHwnd(), UDM_SETRANGE, 0,
(LPARAM) MAKELONG((short)maxVal, (short)minVal));
}
// the current value might be out of the new range, force it to be in it // the current value might be out of the new range, force it to be in it
NormalizeValue(); NormalizeValue();

View File

@@ -386,8 +386,7 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size)
::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
#ifdef TB_SETEXTENDEDSTYLE #ifdef TB_SETEXTENDEDSTYLE
if ( wxApp::GetComCtl32Version() >= 471 ) ::SendMessage(GetHwnd(), TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
::SendMessage(GetHwnd(), TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
#endif #endif
return true; return true;
@@ -523,10 +522,10 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const
if ( !(style & wxTB_NO_TOOLTIPS) ) if ( !(style & wxTB_NO_TOOLTIPS) )
msStyle |= TBSTYLE_TOOLTIPS; msStyle |= TBSTYLE_TOOLTIPS;
if ( style & wxTB_FLAT && wxApp::GetComCtl32Version() > 400 ) if ( style & wxTB_FLAT )
msStyle |= TBSTYLE_FLAT; msStyle |= TBSTYLE_FLAT;
if ( style & wxTB_HORZ_LAYOUT && wxApp::GetComCtl32Version() >= 470 ) if ( style & wxTB_HORZ_LAYOUT )
msStyle |= TBSTYLE_LIST; msStyle |= TBSTYLE_LIST;
if ( style & wxTB_NODIVIDER ) if ( style & wxTB_NODIVIDER )
@@ -607,34 +606,27 @@ void wxToolBar::CreateDisabledImageList()
{ {
wxDELETE(m_disabledImgList); wxDELETE(m_disabledImgList);
// as we can't use disabled image list with older versions of comctl32.dll, // search for the first disabled button img in the toolbar, if any
// don't even bother creating it for ( wxToolBarToolsList::compatibility_iterator
if ( wxApp::GetComCtl32Version() >= 470 ) node = m_tools.GetFirst(); node; node = node->GetNext() )
{ {
// search for the first disabled button img in the toolbar, if any wxToolBarToolBase *tool = node->GetData();
for ( wxToolBarToolsList::compatibility_iterator wxBitmap bmpDisabled = tool->GetDisabledBitmap();
node = m_tools.GetFirst(); node; node = node->GetNext() ) if ( bmpDisabled.IsOk() )
{ {
wxToolBarToolBase *tool = node->GetData(); const wxSize sizeBitmap = bmpDisabled.GetSize();
wxBitmap bmpDisabled = tool->GetDisabledBitmap(); m_disabledImgList = new wxImageList
if ( bmpDisabled.IsOk() ) (
{ sizeBitmap.x,
const wxSize sizeBitmap = bmpDisabled.GetSize(); sizeBitmap.y,
m_disabledImgList = new wxImageList // Don't use mask if we have alpha
( // (wxImageList will fall back to
sizeBitmap.x, // mask if alpha not supported)
sizeBitmap.y, !bmpDisabled.HasAlpha(),
// Don't use mask if we have alpha GetToolsCount()
// (wxImageList will fall back to );
// mask if alpha not supported) break;
!bmpDisabled.HasAlpha(),
GetToolsCount()
);
break;
}
} }
// we don't have any disabled bitmaps
} }
} }
@@ -824,35 +816,30 @@ bool wxToolBar::Realize()
if ( oldToolBarBitmap ) if ( oldToolBarBitmap )
{ {
#ifdef TB_REPLACEBITMAP #ifdef TB_REPLACEBITMAP
if ( wxApp::GetComCtl32Version() >= 400 ) TBREPLACEBITMAP replaceBitmap;
replaceBitmap.hInstOld = NULL;
replaceBitmap.hInstNew = NULL;
replaceBitmap.nIDOld = (UINT_PTR)oldToolBarBitmap;
replaceBitmap.nIDNew = (UINT_PTR)hBitmap;
replaceBitmap.nButtons = nButtons;
if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP,
0, (LPARAM) &replaceBitmap) )
{ {
TBREPLACEBITMAP replaceBitmap; wxFAIL_MSG(wxT("Could not replace the old bitmap"));
replaceBitmap.hInstOld = NULL;
replaceBitmap.hInstNew = NULL;
replaceBitmap.nIDOld = (UINT_PTR)oldToolBarBitmap;
replaceBitmap.nIDNew = (UINT_PTR)hBitmap;
replaceBitmap.nButtons = nButtons;
if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP,
0, (LPARAM) &replaceBitmap) )
{
wxFAIL_MSG(wxT("Could not replace the old bitmap"));
}
::DeleteObject(oldToolBarBitmap);
// already done
addBitmap = false;
} }
else
::DeleteObject(oldToolBarBitmap);
// already done
addBitmap = false;
#else
// we can't replace the old bitmap, so we will add another one
// (awfully inefficient, but what else to do?) and shift the bitmap
// indices accordingly
addBitmap = true;
bitmapId = m_nButtons;
#endif // TB_REPLACEBITMAP #endif // TB_REPLACEBITMAP
{
// we can't replace the old bitmap, so we will add another one
// (awfully inefficient, but what else to do?) and shift the bitmap
// indices accordingly
addBitmap = true;
bitmapId = m_nButtons;
}
} }
if ( addBitmap ) // no old bitmap or we can't replace it if ( addBitmap ) // no old bitmap or we can't replace it
@@ -867,22 +854,18 @@ bool wxToolBar::Realize()
} }
} }
// disable image lists are only supported in comctl32.dll 4.70+ HIMAGELIST hil = m_disabledImgList
if ( wxApp::GetComCtl32Version() >= 470 ) ? GetHimagelistOf(m_disabledImgList)
{ : 0;
HIMAGELIST hil = m_disabledImgList
? GetHimagelistOf(m_disabledImgList)
: 0;
// notice that we set the image list even if don't have one right // notice that we set the image list even if don't have one right
// now as we could have it before and need to reset it in this case // now as we could have it before and need to reset it in this case
HIMAGELIST oldImageList = (HIMAGELIST) HIMAGELIST oldImageList = (HIMAGELIST)
::SendMessage(GetHwnd(), TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hil); ::SendMessage(GetHwnd(), TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hil);
// delete previous image list if any // delete previous image list if any
if ( oldImageList ) if ( oldImageList )
::DeleteObject(oldImageList); ::DeleteObject(oldImageList);
}
} }
@@ -900,14 +883,6 @@ bool wxToolBar::Realize()
{ {
wxToolBarTool *tool = static_cast<wxToolBarTool *>(node->GetData()); wxToolBarTool *tool = static_cast<wxToolBarTool *>(node->GetData());
// don't add separators to the vertical toolbar with old comctl32.dll
// versions as they didn't handle this properly
if ( IsVertical() && tool->IsSeparator() &&
wxApp::GetComCtl32Version() <= 472 )
{
continue;
}
TBBUTTON& button = buttons[i]; TBBUTTON& button = buttons[i];
wxZeroMemory(button); wxZeroMemory(button);
@@ -1492,21 +1467,9 @@ void wxToolBar::SetRows(int nRows)
// The button size is bigger than the bitmap size // The button size is bigger than the bitmap size
wxSize wxToolBar::GetToolSize() const wxSize wxToolBar::GetToolSize() const
{ {
// TB_GETBUTTONSIZE is supported from version 4.70 DWORD dw = ::SendMessage(GetHwnd(), TB_GETBUTTONSIZE, 0, 0);
#if defined(_WIN32_IE) && (_WIN32_IE >= 0x300 ) \
&& !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) )
if ( wxApp::GetComCtl32Version() >= 470 )
{
DWORD dw = ::SendMessage(GetHwnd(), TB_GETBUTTONSIZE, 0, 0);
return wxSize(LOWORD(dw), HIWORD(dw)); return wxSize(LOWORD(dw), HIWORD(dw));
}
else
#endif // comctl32.dll 4.70+
{
// defaults
return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
}
} }
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const

View File

@@ -130,10 +130,7 @@ public:
// then as the control gets "focus lost" events and dismisses the // then as the control gets "focus lost" events and dismisses the
// tooltip which then reappears because mouse remains hovering over the // tooltip which then reappears because mouse remains hovering over the
// control, see SF patch 1821229 // control, see SF patch 1821229
if ( wxApp::GetComCtl32Version() >= 470 ) uFlags |= TTF_TRANSPARENT;
{
uFlags |= TTF_TRANSPARENT;
}
} }
}; };
@@ -539,81 +536,76 @@ void wxToolTip::DoSetTip(WXHWND hWnd)
bool wxToolTip::AdjustMaxWidth() bool wxToolTip::AdjustMaxWidth()
{ {
if ( wxApp::GetComCtl32Version() >= 470 ) // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the
{ // extent of its first line as max value
// use TTM_SETMAXTIPWIDTH to make tooltip multiline using the HFONT hfont = (HFONT)
// extent of its first line as max value SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0);
HFONT hfont = (HFONT)
SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0);
if ( !hfont )
{
hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if ( !hfont ) if ( !hfont )
{ {
hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)"));
if ( !hfont )
{
wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)"));
}
} }
MemoryHDC hdc;
if ( !hdc )
{
wxLogLastError(wxT("CreateCompatibleDC(NULL)"));
}
if ( !SelectObject(hdc, hfont) )
{
wxLogLastError(wxT("SelectObject(hfont)"));
}
// find the width of the widest line
int maxWidth = 0;
wxStringTokenizer tokenizer(m_text, wxT("\n"));
while ( tokenizer.HasMoreTokens() )
{
const wxString token = tokenizer.GetNextToken();
SIZE sz;
if ( !::GetTextExtentPoint32(hdc, token.t_str(),
token.length(), &sz) )
{
wxLogLastError(wxT("GetTextExtentPoint32"));
}
if ( sz.cx > maxWidth )
maxWidth = sz.cx;
}
// limit size to ms_maxWidth, if set
if ( ms_maxWidth == 0 )
{
// this is more or less arbitrary but seems to work well
static const int DEFAULT_MAX_WIDTH = 400;
ms_maxWidth = wxGetClientDisplayRect().width / 2;
if ( ms_maxWidth > DEFAULT_MAX_WIDTH )
ms_maxWidth = DEFAULT_MAX_WIDTH;
}
if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth )
maxWidth = ms_maxWidth;
// only set a new width if it is bigger than the current setting:
// otherwise adding a tooltip with shorter line(s) than a previous
// one would result in breaking the longer lines unnecessarily as
// all our tooltips share the same maximal width
if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(),
TTM_GETMAXTIPWIDTH, 0) )
{
SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,
wxUIntToPtr(maxWidth));
}
return true;
} }
return false; MemoryHDC hdc;
if ( !hdc )
{
wxLogLastError(wxT("CreateCompatibleDC(NULL)"));
}
if ( !SelectObject(hdc, hfont) )
{
wxLogLastError(wxT("SelectObject(hfont)"));
}
// find the width of the widest line
int maxWidth = 0;
wxStringTokenizer tokenizer(m_text, wxT("\n"));
while ( tokenizer.HasMoreTokens() )
{
const wxString token = tokenizer.GetNextToken();
SIZE sz;
if ( !::GetTextExtentPoint32(hdc, token.t_str(),
token.length(), &sz) )
{
wxLogLastError(wxT("GetTextExtentPoint32"));
}
if ( sz.cx > maxWidth )
maxWidth = sz.cx;
}
// limit size to ms_maxWidth, if set
if ( ms_maxWidth == 0 )
{
// this is more or less arbitrary but seems to work well
static const int DEFAULT_MAX_WIDTH = 400;
ms_maxWidth = wxGetClientDisplayRect().width / 2;
if ( ms_maxWidth > DEFAULT_MAX_WIDTH )
ms_maxWidth = DEFAULT_MAX_WIDTH;
}
if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth )
maxWidth = ms_maxWidth;
// only set a new width if it is bigger than the current setting:
// otherwise adding a tooltip with shorter line(s) than a previous
// one would result in breaking the longer lines unnecessarily as
// all our tooltips share the same maximal width
if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(),
TTM_GETMAXTIPWIDTH, 0) )
{
SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,
wxUIntToPtr(maxWidth));
}
return true;
} }
void wxToolTip::DoForAllWindows(void (wxToolTip::*func)(WXHWND)) void wxToolTip::DoForAllWindows(void (wxToolTip::*func)(WXHWND))

View File

@@ -763,8 +763,7 @@ bool wxTreeCtrl::Create(wxWindow *parent,
if ( m_windowStyle & wxTR_FULL_ROW_HIGHLIGHT ) if ( m_windowStyle & wxTR_FULL_ROW_HIGHLIGHT )
{ {
if ( wxApp::GetComCtl32Version() >= 471 ) wstyle |= TVS_FULLROWSELECT;
wstyle |= TVS_FULLROWSELECT;
} }
#if defined(TVS_INFOTIP) #if defined(TVS_INFOTIP)