Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/plugin/PluginClass.cpp

Issue 4937147073167360: Issue 1672 - Subscribe and listen COM events using ATL::IDispEventImpl and BEGIN_SINK_MAP (Closed)
Left Patch Set: add exception wrappers Created Feb. 27, 2015, 6:20 p.m.
Right Patch Set: rebase, parent = 5d5eb4df1bf2 Created March 13, 2015, 3:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/PluginClass.h ('k') | src/plugin/PluginErrorCodes.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 26 matching lines...) Expand all
37 #ifdef DEBUG_HIDE_EL 37 #ifdef DEBUG_HIDE_EL
38 DWORD profileTime = 0; 38 DWORD profileTime = 0;
39 #endif 39 #endif
40 40
41 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); 41 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR);
42 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); 42 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT);
43 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); 43 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE);
44 44
45 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; 45 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL };
46 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; 46 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED };
47 uint32_t iconHeight = 32;
48 uint32_t iconWidth = 32;
47 49
48 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL; 50 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL;
49 51
50 CLOSETHEMEDATA pfnClose = NULL; 52 CLOSETHEMEDATA pfnClose = NULL;
51 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; 53 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL;
52 OPENTHEMEDATA pfnOpenThemeData = NULL; 54 OPENTHEMEDATA pfnOpenThemeData = NULL;
53 55
54 ATOM CPluginClass::s_atomPaneClass = NULL; 56 ATOM CPluginClass::s_atomPaneClass = NULL;
55 HINSTANCE CPluginClass::s_hUxtheme = NULL; 57 HINSTANCE CPluginClass::s_hUxtheme = NULL;
56 std::set<CPluginClass*> CPluginClass::s_instances; 58 std::set<CPluginClass*> CPluginClass::s_instances;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if (SUCCEEDED(hr)) 261 if (SUCCEEDED(hr))
260 { 262 {
261 m_isAdvised = true; 263 m_isAdvised = true;
262 try 264 try
263 { 265 {
264 std::thread startInitObjectThread(StartInitObject, this); 266 std::thread startInitObjectThread(StartInitObject, this);
265 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr. 267 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr.
266 } 268 }
267 catch (const std::system_error& ex) 269 catch (const std::system_error& ex)
268 { 270 {
269 auto errDescription = std::string("Class::Thread - Failed to create StartInitObject thread, ") + 271 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH READ_CREATE_PROCESS,
270 ex.code().message() + ex.what(); 272 "Class::Thread - Failed to create StartInitObject thread");
271 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR _MAIN_THREAD_CREATE_PROCESS, errDescription.c_str());
272 } 273 }
273 } 274 }
274 else 275 else
275 { 276 {
276 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advice"); 277 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advise");
277 } 278 }
278 } 279 }
279 else // Check if loaded as toolbar handler 280 else // Check if loaded as toolbar handler
280 { 281 {
281 DEBUG_GENERAL("Loaded as toolbar handler"); 282 DEBUG_GENERAL("Loaded as toolbar handler");
282 CComPtr<IServiceProvider> pServiceProvider; 283 CComPtr<IServiceProvider> pServiceProvider;
283 284
284 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); 285 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider);
285 if (SUCCEEDED(hr)) 286 if (SUCCEEDED(hr))
286 { 287 {
(...skipping 16 matching lines...) Expand all
303 } 304 }
304 s_criticalSectionBrowser.Unlock(); 305 s_criticalSectionBrowser.Unlock();
305 } 306 }
306 } 307 }
307 else 308 else
308 { 309 {
309 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); 310 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)");
310 } 311 }
311 } 312 }
312 } 313 }
313 catch (std::runtime_error e) 314 catch (const std::runtime_error& ex)
314 { 315 {
315 DEBUG_ERROR(e.what()); 316 DEBUG_EXCEPTION(ex);
316 Unadvise(); 317 Unadvise();
317 } 318 }
318 } 319 }
319 else 320 else
320 { 321 {
321 Unadvise(); 322 Unadvise();
322 323
323 // Destroy window 324 // Destroy window
324 if (m_pWndProcStatus) 325 if (m_pWndProcStatus)
325 { 326 {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 else 482 else
482 { 483 {
483 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); 484 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state");
484 } 485 }
485 } 486 }
486 DEBUG_GENERAL("ShowStatusBar end"); 487 DEBUG_GENERAL("ShowStatusBar end");
487 } 488 }
488 489
489 // Entry point 490 // Entry point
490 void STDMETHODCALLTYPE CPluginClass::OnBeforeNavigate2( 491 void STDMETHODCALLTYPE CPluginClass::OnBeforeNavigate2(
491 /* [in] */ IDispatch* frameBrowserDisp, 492 /* [in] */ IDispatch* frameBrowserDisp,
Oleksandr 2015/03/12 05:10:57 Since we do have Doxygen set up, how about using /
Oleksandr 2015/03/13 16:42:03 So how about this comment?
sergei 2015/03/13 17:03:14 I've tested it, neither /* [in] */ nor /**< [in] *
492 /* [in] */ VARIANT* urlVariant, 493 /* [in] */ VARIANT* urlVariant,
493 /* [in] */ VARIANT* /*Flags*/, 494 /* [in] */ VARIANT* /*Flags*/,
494 /* [in] */ VARIANT* /*TargetFrameName*/, 495 /* [in] */ VARIANT* /*TargetFrameName*/,
495 /* [in] */ VARIANT* /*PostData*/, 496 /* [in] */ VARIANT* /*PostData*/,
496 /* [in] */ VARIANT* /*Headers*/, 497 /* [in] */ VARIANT* /*Headers*/,
497 /* [in, out] */ VARIANT_BOOL* /*Cancel*/) 498 /* [in, out] */ VARIANT_BOOL* /*Cancel*/)
498 { 499 {
499 try 500 try
500 { 501 {
501 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; 502 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp;
502 if (!webBrowser) 503 if (!webBrowser)
503 { 504 {
504 return; 505 return;
505 } 506 }
506
507 if (!urlVariant || urlVariant->vt != VT_BSTR) 507 if (!urlVariant || urlVariant->vt != VT_BSTR)
508 { 508 {
509 return; 509 return;
510 } 510 }
511 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); 511 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal));
512 UnescapeUrl(url); 512 UnescapeUrl(url);
513 513
514 //Register a mime filter if it's not registered yet 514 //Register a mime filter if it's not registered yet
515 if (s_mimeFilter == nullptr) 515 if (s_mimeFilter == nullptr)
516 { 516 {
517 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); 517 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance();
518 } 518 }
519 519 // If webbrowser2 is equal to top level browser (as set in SetSite), we are
520 // If webbrowser2 is equal to top level browser (as set in SetSite), we are navigating new page 520 // navigating new page
521 CPluginClient* client = CPluginClient::GetInstance(); 521 CPluginClient* client = CPluginClient::GetInstance();
522
523 if (url.find(L"javascript") == 0) 522 if (url.find(L"javascript") == 0)
524 { 523 {
525 } 524 }
526 else if (GetBrowser().IsEqualObject(webBrowser)) 525 else if (GetBrowser().IsEqualObject(webBrowser))
527 { 526 {
528 m_tab->OnNavigate(url); 527 m_tab->OnNavigate(url);
529 CString urlLegacy = ToCString(url); 528 DEBUG_GENERAL(
530 DEBUG_GENERAL(L"========================================================== ======================\nBegin main navigation url:" + urlLegacy + "\n=========== =====================================================================") 529 L"======================================================================== ========\n"
531 #ifdef ENABLE_DEBUG_RESULT 530 L"Begin main navigation url:" + url + L"\n"
532 CPluginDebug::DebugResultDomain(urlLegacy); 531 L"======================================================================== ========")
533 #endif 532
533 #ifdef ENABLE_DEBUG_RESULT
534 CPluginDebug::DebugResultDomain(url);
535 #endif
534 UpdateStatusBar(); 536 UpdateStatusBar();
535 } 537 }
536 else 538 else
537 { 539 {
538 DEBUG_NAVI(L"Navi::Begin navigation url:" + ToCString(url)) 540 DEBUG_NAVI(L"Navi::Begin navigation url:" + url)
539 m_tab->CacheFrame(url); 541 m_tab->CacheFrame(url);
540 } 542 }
541 } 543 }
542 catch (...) 544 catch (...)
543 { 545 {
544 } 546 }
545 } 547 }
546 548
547 // Entry point 549 // Entry point
548 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() 550 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete()
549 { 551 {
550 try 552 try
551 { 553 {
552 DEBUG_NAVI("Navi::Download Complete") 554 DEBUG_NAVI(L"Navi::Download Complete")
553 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); 555 ATL::CComPtr<IWebBrowser2> browser = GetBrowser();
554 if (browser) 556 if (browser)
555 { 557 {
556 m_tab->OnDownloadComplete(browser); 558 m_tab->OnDownloadComplete(browser);
557 } 559 }
558 } 560 }
559 catch (...) 561 catch (...)
560 { 562 {
561 } 563 }
562 } 564 }
563 565
564 // Entry point 566 // Entry point
565 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) 567 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/)
566 { 568 {
567 try 569 try
568 { 570 {
571 DEBUG_NAVI(L"Navi::Document Complete");
569 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; 572 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp;
570 if (!webBrowser2) 573 if (!webBrowser2)
571 { 574 {
572 return; 575 return;
573 } 576 }
574 std::wstring frameSrc = GetLocationUrl(*webBrowser2); 577 std::wstring frameSrc = GetLocationUrl(*webBrowser2);
575 UnescapeUrl(frameSrc); 578 UnescapeUrl(frameSrc);
576 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2); 579 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2);
577 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser); 580 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser);
578 } 581 }
579 catch (...) 582 catch (...)
580 { 583 {
581 } 584 }
582 } 585 }
583 586
584 // Entry point 587 // Entry point
585 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) 588 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask)
586 { 589 {
587 try 590 try
588 { 591 {
589 DEBUG_GENERAL("WindowStateChanged (check tab changed)"); 592 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)");
590 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED) 593 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED)
591 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_W INDOWSTATE_ENABLED); 594 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA BLED);
592 if (newtabshown) 595 if (newtabshown)
593 { 596 {
594 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId()); 597 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId());
595 if (it == s_threadInstances.end()) 598 if (it == s_threadInstances.end())
596 { 599 {
597 s_threadInstances[::GetCurrentThreadId()] = this; 600 s_threadInstances[::GetCurrentThreadId()] = this;
598 if (!m_isInitializedOk) 601 if (!m_isInitializedOk)
599 { 602 {
600 m_isInitializedOk = true; 603 m_isInitializedOk = true;
601 InitObject(true); 604 InitObject(true);
602 UpdateStatusBar(); 605 UpdateStatusBar();
603 } 606 }
604 } 607 }
605 } 608 }
606 notificationMessage.Hide(); 609 notificationMessage.Hide();
607 DEBUG_GENERAL("WindowStateChanged (check tab changed) end"); 610 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end");
608 } 611 }
609 catch (...) 612 catch (...)
610 { 613 {
611 } 614 }
612 } 615 }
613 616
614 // Entry point 617 // Entry point
615 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/) 618 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/)
616 { 619 {
617 try 620 try
618 { 621 {
619 if (m_hPaneWnd == NULL) 622 if (m_hPaneWnd == NULL)
620 { 623 {
621 CreateStatusBarPane(); 624 CreateStatusBarPane();
622 } 625 }
623 else 626 else
624 { 627 {
625 if (AdblockPlus::IE::InstalledMajorVersion() > 6) 628 if (AdblockPlus::IE::InstalledMajorVersion() > 6)
626 { 629 {
627 RECT rect; 630 RECT rect;
628 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); 631 //Get the RECT for the leftmost pane (the status text pane)
632 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re ct);
629 if (rectRes == TRUE) 633 if (rectRes == TRUE)
630 { 634 {
631 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom - rect.top, TRUE); 635 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec t.bottom - rect.top, TRUE);
632 } 636 }
633 } 637 }
634 } 638 }
639 }
640 catch (...)
641 {
642 }
643 }
644
645 // Entry point
646 void STDMETHODCALLTYPE CPluginClass::OnOnQuit()
647 {
648 try
649 {
650 Unadvise();
635 } 651 }
636 catch (...) 652 catch (...)
637 { 653 {
638 } 654 }
639 } 655 }
640 656
641 bool CPluginClass::InitObject(bool bBHO) 657 bool CPluginClass::InitObject(bool bBHO)
642 { 658 {
643 DEBUG_GENERAL("InitObject"); 659 DEBUG_GENERAL("InitObject");
644 CPluginSettings* settings = CPluginSettings::GetInstance(); 660 CPluginSettings* settings = CPluginSettings::GetInstance();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar") 868 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar")
853 return true; 869 return true;
854 } 870 }
855 871
856 // Calculate pane height 872 // Calculate pane height
857 AdblockPlus::Rectangle rcStatusBar; 873 AdblockPlus::Rectangle rcStatusBar;
858 ::GetClientRect(hWndStatusBar, &rcStatusBar); 874 ::GetClientRect(hWndStatusBar, &rcStatusBar);
859 875
860 if (rcStatusBar.Height() > 0) 876 if (rcStatusBar.Height() > 0)
861 { 877 {
878 if (rcStatusBar.Height() < iconWidth)
879 {
880 iconWidth = 19;
881 iconHeight = 19;
882 }
883
862 #ifdef _DEBUG 884 #ifdef _DEBUG
863 m_nPaneWidth = 70; 885 m_nPaneWidth = 70;
864 #else 886 #else
865 m_nPaneWidth = min(rcStatusBar.Height(), 22); 887 m_nPaneWidth = min(rcStatusBar.Height(), iconWidth);
866 #endif 888 #endif
867 } 889 }
868 else 890 else
869 { 891 {
870 #ifdef _DEBUG 892 #ifdef _DEBUG
871 m_nPaneWidth = 70; 893 m_nPaneWidth = 70;
872 #else 894 #else
873 m_nPaneWidth = 22; 895 m_nPaneWidth = iconWidth;
874 #endif 896 #endif
875 } 897 }
876 // Create pane window 898 // Create pane window
877 HWND hWndNewPane = ::CreateWindowEx( 899 HWND hWndNewPane = ::CreateWindowEx(
878 NULL, 900 NULL,
879 MAKEINTATOM(GetAtomPaneClass()), 901 MAKEINTATOM(GetAtomPaneClass()),
880 L"", 902 L"",
881 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 903 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
882 rcStatusBar.Width() - 500,0,m_nPaneWidth,rcStatusBar.Height(), 904 rcStatusBar.Width() - 500, 0, m_nPaneWidth, rcStatusBar.Height(),
883 hWndStatusBar, 905 hWndStatusBar,
884 (HMENU)3671, 906 (HMENU)3671,
885 _Module.m_hInst, 907 _Module.m_hInst,
886 NULL); 908 NULL);
887 909
888 if (!hWndNewPane) 910 if (!hWndNewPane)
889 { 911 {
890 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx") 912 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx")
891 return false; 913 return false;
892 } 914 }
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 } 1500 }
1479 } 1501 }
1480 } 1502 }
1481 } 1503 }
1482 1504
1483 // Draw icon 1505 // Draw icon
1484 if (CPluginClient::GetInstance()) 1506 if (CPluginClient::GetInstance())
1485 { 1507 {
1486 HICON hIcon = GetStatusBarIcon(pClass->GetTab()->GetDocumentUrl()); 1508 HICON hIcon = GetStatusBarIcon(pClass->GetTab()->GetDocumentUrl());
1487 1509
1488 int offx = (rcClient.Height() - 16)/2 + nDrawEdge; 1510 int offx = nDrawEdge;
1489 if (hIcon) 1511 if (hIcon)
1490 { 1512 {
1491 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL); 1513 //Get the RECT for the leftmost pane (the status text pane)
1492 offx += 22; 1514 RECT rect;
1515 BOOL rectRes = ::SendMessage(pClass->m_hStatusBarWnd, SB_GETRECT, 0, ( LPARAM)&rect);
1516 ::DrawIconEx(hDC, 0, rect.bottom - rect.top - iconHeight, hIcon, iconW idth, iconHeight, NULL, NULL, DI_NORMAL);
1517 offx += iconWidth;
1493 } 1518 }
1494 #ifdef _DEBUG 1519 #ifdef _DEBUG
1495 // Display version 1520 // Display version
1496 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0); 1521 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0);
1497 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont); 1522 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont);
1498 1523
1499 AdblockPlus::Rectangle rcText = rcClient; 1524 AdblockPlus::Rectangle rcText = rcClient;
1500 rcText.left += offx; 1525 rcText.left += offx;
1501 ::SetBkMode(hDC, TRANSPARENT); 1526 ::SetBkMode(hDC, TRANSPARENT);
1502 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER); 1527 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 if (m_hPaneWnd == NULL) 1644 if (m_hPaneWnd == NULL)
1620 { 1645 {
1621 CreateStatusBarPane(); 1646 CreateStatusBarPane();
1622 } 1647 }
1623 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) 1648 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE))
1624 { 1649 {
1625 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); 1650 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar");
1626 } 1651 }
1627 } 1652 }
1628 1653
1629 // Entry point
1630 void STDMETHODCALLTYPE CPluginClass::OnOnQuit()
1631 {
1632 try
1633 {
1634 Unadvise();
1635 }
1636 catch (...)
1637 {
1638 }
1639 }
1640 1654
1641 void CPluginClass::Unadvise() 1655 void CPluginClass::Unadvise()
1642 { 1656 {
1643 s_criticalSectionLocal.Lock(); 1657 s_criticalSectionLocal.Lock();
1644 { 1658 {
1645 if (m_isAdvised) 1659 if (m_isAdvised)
1646 { 1660 {
1647 HRESULT hr = DispEventUnadvise(GetBrowser()); 1661 HRESULT hr = DispEventUnadvise(GetBrowser());
1648 if (FAILED(hr)) 1662 if (FAILED(hr))
1649 { 1663 {
1650 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); 1664 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise");
1651 } 1665 }
1652 m_isAdvised = false; 1666 m_isAdvised = false;
1653 } 1667 }
1654 } 1668 }
1655 s_criticalSectionLocal.Unlock(); 1669 s_criticalSectionLocal.Unlock();
1656 } 1670 }
1657 1671
1658 HICON CPluginClass::GetIcon(int type) 1672 HICON CPluginClass::GetIcon(int type)
1659 { 1673 {
1660 HICON icon = NULL; 1674 HICON icon = NULL;
1661 1675
1662 s_criticalSectionLocal.Lock(); 1676 s_criticalSectionLocal.Lock();
1663 { 1677 {
1664 if (!s_hIcons[type]) 1678 if (!s_hIcons[type])
1665 { 1679 {
1666 s_hIcons[type] = ::LoadIcon(_Module.m_hInst, MAKEINTRESOURCE(s_hIconTypes[ type])); 1680 std::wstring imageToLoad = L"#";
1681 imageToLoad += std::to_wstring(s_hIconTypes[type]);
1682 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED);
1667 if (!s_hIcons[type]) 1683 if (!s_hIcons[type])
1668 { 1684 {
1669 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon") 1685 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon");
1670 } 1686 }
1671 } 1687 }
1672 1688
1673 icon = s_hIcons[type]; 1689 icon = s_hIcons[type];
1674 } 1690 }
1675 s_criticalSectionLocal.Unlock(); 1691 s_criticalSectionLocal.Unlock();
1676 1692
1677 return icon; 1693 return icon;
1678 } 1694 }
1679 1695
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 s_criticalSectionLocal.Unlock(); 1758 s_criticalSectionLocal.Unlock();
1743 1759
1744 } 1760 }
1745 } 1761 }
1746 } 1762 }
1747 1763
1748 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1764 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1749 } 1765 }
1750 return hTabWnd; 1766 return hTabWnd;
1751 } 1767 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld