| |
239 |
239 |
|
| |
240 |
240 |
return S_OK; |
| |
241 |
241 |
} |
| |
242 |
242 |
catch(const std::exception& e) |
| |
243 |
243 |
{ |
| |
244 |
244 |
LOG_CRITICAL(m_spLog) << L"Unexpected std exception encountered in " << __FUNCTION__ << L": " << e.what(); |
| |
245 |
245 |
return E_FAIL; |
| |
246 |
246 |
} |
| |
247 |
247 |
catch(...) |
| |
248 |
248 |
{ |
| |
249 |
249 |
LOG_CRITICAL(m_spLog) << L"Unexpected other exception encountered in " << __FUNCTION__ << L"."; |
| |
250 |
250 |
return E_FAIL; |
| |
251 |
251 |
} |
| |
252 |
252 |
} |
| |
253 |
253 |
|
| |
254 |
254 |
HRESULT CMenuExt::HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) |
| |
255 |
255 |
{ |
| |
256 |
256 |
return HandleMenuMsg2(uMsg, wParam, lParam, nullptr); |
| |
257 |
257 |
} |
| |
258 |
258 |
|
| |
259 |
|
HRESULT CMenuExt::HandleMenuMsg2(UINT uMsg, WPARAM , LPARAM lParam, LRESULT* ) |
| |
|
259 |
HRESULT CMenuExt::HandleMenuMsg2(UINT uMsg, WPARAM , LPARAM lParam, LRESULT* plResult) |
| |
260 |
260 |
{ |
| |
261 |
261 |
try |
| |
262 |
262 |
{ |
| |
263 |
263 |
LOG_DEBUG(m_spLog) << L"Handle menu message (2)"; |
| |
264 |
264 |
|
| |
265 |
265 |
switch(uMsg) |
| |
266 |
266 |
{ |
| |
267 |
267 |
case WM_INITMENUPOPUP: |
| |
268 |
268 |
break; |
| |
269 |
269 |
|
| |
270 |
270 |
case WM_DRAWITEM: |
| |
271 |
271 |
return DrawMenuItem((LPDRAWITEMSTRUCT)lParam); |
| |
272 |
272 |
|
| |
273 |
273 |
case WM_MEASUREITEM: |
| |
274 |
274 |
{ |
| |
275 |
275 |
LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; |
| |
276 |
276 |
if(!lpmis) |
| |
277 |
277 |
return E_FAIL; |
| |
278 |
278 |
|
| |
279 |
279 |
|
|
| |
291 |
291 |
return E_FAIL; |
| |
292 |
292 |
|
| |
293 |
293 |
|
| |
294 |
294 |
HWND hDesktop = GetDesktopWindow(); |
| |
295 |
295 |
HDC hDC = GetDC(hDesktop); |
| |
296 |
296 |
|
| |
297 |
297 |
HFONT hOldFont = (HFONT)SelectObject(hDC, hFont); |
| |
298 |
298 |
|
| |
299 |
299 |
SIZE size = { 0 }; |
| |
300 |
300 |
GetTextExtentPoint32(hDC, spSelectedItem->GetLocalName().c_str(), boost::numeric_cast<int>(spSelectedItem->GetLocalName().GetLength()), &size); |
| |
301 |
301 |
|
| |
302 |
302 |
|
| |
303 |
303 |
SelectObject(hDC, hOldFont); |
| |
304 |
304 |
ReleaseDC(hDesktop, hDC); |
| |
305 |
305 |
DeleteObject(hFont); |
| |
306 |
306 |
|
| |
307 |
307 |
|
| |
308 |
308 |
lpmis->itemWidth = size.cx + GetSystemMetrics(SM_CXMENUCHECK) + 2 * GetSystemMetrics(SM_CXSMICON); |
| |
309 |
309 |
lpmis->itemHeight = std::max<int>(size.cy + 3, GetSystemMetrics(SM_CYMENU) + 3); |
| |
310 |
310 |
|
| |
|
311 |
if (plResult) |
| |
|
312 |
*plResult = TRUE; |
| |
311 |
313 |
break; |
| |
312 |
314 |
} |
| |
313 |
315 |
} |
| |
314 |
316 |
|
| |
315 |
317 |
return S_OK; |
| |
316 |
318 |
} |
| |
317 |
319 |
catch(const std::exception& e) |
| |
318 |
320 |
{ |
| |
319 |
321 |
LOG_CRITICAL(m_spLog) << L"Unexpected std exception encountered in " << __FUNCTION__ << L": " << e.what(); |
| |
320 |
322 |
return E_FAIL; |
| |
321 |
323 |
} |
| |
322 |
324 |
catch(...) |
| |
323 |
325 |
{ |
| |
324 |
326 |
LOG_CRITICAL(m_spLog) << L"Unexpected other exception encountered in " << __FUNCTION__ << L"."; |
| |
325 |
327 |
return E_FAIL; |
| |
326 |
328 |
} |
| |
327 |
329 |
} |
| |
328 |
330 |
|
| |
329 |
331 |
HRESULT CMenuExt::DrawMenuItem(LPDRAWITEMSTRUCT lpdis) |
| |
330 |
332 |
{ |