diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp
index 9596725..b99b7d8 100644
a
|
b
|
class wxToolBarTool : public wxToolBarToolBase |
244 | 244 | // helper functions |
245 | 245 | // ---------------------------------------------------------------------------- |
246 | 246 | |
247 | | // return the rectangle of the item at the given index |
| 247 | // Return the rectangle of the item at the given index and, if specified, with |
| 248 | // the given id. |
248 | 249 | // |
249 | | // returns an empty (0, 0, 0, 0) rectangle if fails so the caller may compare |
250 | | // r.right or r.bottom with 0 to check for this |
251 | | static RECT wxGetTBItemRect(HWND hwnd, int index) |
| 250 | // Returns an empty (0, 0, 0, 0) rectangle if fails so the caller may compare |
| 251 | // r.right or r.bottom with 0 to check for this. |
| 252 | static RECT wxGetTBItemRect(HWND hwnd, int index, int id = wxID_NONE) |
252 | 253 | { |
253 | 254 | RECT r; |
254 | 255 | |
… |
… |
static RECT wxGetTBItemRect(HWND hwnd, int index) |
256 | 257 | // only appeared in v4.70 of comctl32.dll |
257 | 258 | if ( !::SendMessage(hwnd, TB_GETITEMRECT, index, (LPARAM)&r) ) |
258 | 259 | { |
259 | | wxLogLastError(wxT("TB_GETITEMRECT")); |
| 260 | // This call can return false status even when there is no real error, |
| 261 | // e.g. for a hidden button, so check for this to avoid spurious logs. |
| 262 | const DWORD err = ::GetLastError(); |
| 263 | if ( err != ERROR_SUCCESS ) |
| 264 | { |
| 265 | bool reportError = true; |
| 266 | |
| 267 | if ( id != wxID_NONE ) |
| 268 | { |
| 269 | const LRESULT state = ::SendMessage(hwnd, TB_GETSTATE, id, 0); |
| 270 | if ( state != -1 && (state & TBSTATE_HIDDEN) ) |
| 271 | { |
| 272 | // There is no real error to report after all. |
| 273 | reportError = false; |
| 274 | } |
| 275 | else // It is not hidden. |
| 276 | { |
| 277 | // So it must have been a real error, report it with the |
| 278 | // original error code and not the one from TB_GETSTATE. |
| 279 | ::SetLastError(err); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | if ( reportError ) |
| 284 | wxLogLastError(wxT("TB_GETITEMRECT")); |
| 285 | } |
260 | 286 | |
261 | | r.top = |
262 | | r.left = |
263 | | r.right = |
264 | | r.bottom = 0; |
| 287 | ::SetRectEmpty(&r); |
265 | 288 | } |
266 | 289 | |
267 | 290 | return r; |
… |
… |
bool wxToolBar::Realize() |
998 | 1021 | } |
999 | 1022 | |
1000 | 1023 | button.idCommand = tool->GetId(); |
1001 | | button.fsState = TBSTATE_ENABLED; |
| 1024 | |
| 1025 | // We don't embed controls in the vertical toolbar but for |
| 1026 | // every control there must exist a corresponding button to |
| 1027 | // keep indexes the same as in the horizontal case. |
| 1028 | if ( IsVertical() && tool->IsControl() ) |
| 1029 | button.fsState = TBSTATE_HIDDEN; |
| 1030 | else |
| 1031 | button.fsState = TBSTATE_ENABLED; |
1002 | 1032 | button.fsStyle = TBSTYLE_SEP; |
1003 | 1033 | break; |
1004 | 1034 | |
… |
… |
bool wxToolBar::Realize() |
1112 | 1142 | { |
1113 | 1143 | wxToolBarTool * const tool = (wxToolBarTool*)node->GetData(); |
1114 | 1144 | |
1115 | | const RECT r = wxGetTBItemRect(GetHwnd(), toolIndex); |
| 1145 | const RECT r = wxGetTBItemRect(GetHwnd(), toolIndex, tool->GetId()); |
1116 | 1146 | |
1117 | 1147 | if ( !tool->IsControl() ) |
1118 | 1148 | { |
… |
… |
bool wxToolBar::Realize() |
1124 | 1154 | continue; |
1125 | 1155 | } |
1126 | 1156 | |
| 1157 | wxControl * const control = tool->GetControl(); |
1127 | 1158 | if ( IsVertical() ) |
1128 | 1159 | { |
1129 | 1160 | // don't embed controls in the vertical toolbar, this doesn't look |
1130 | 1161 | // good and wxGTK doesn't do it neither (and the code below can't |
1131 | 1162 | // deal with this case) |
| 1163 | control->Hide(); |
1132 | 1164 | continue; |
1133 | 1165 | } |
1134 | 1166 | |
1135 | | wxControl * const control = tool->GetControl(); |
| 1167 | control->Show(); |
1136 | 1168 | wxStaticText * const staticText = tool->GetStaticText(); |
1137 | 1169 | |
1138 | 1170 | wxSize size = control->GetSize(); |