diff options
author | George Hazan <george.hazan@gmail.com> | 2015-07-29 21:18:27 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-07-29 21:18:27 +0000 |
commit | 1271802f514d41e8e06df7714d1f1e4a430b417b (patch) | |
tree | 5bd4ef52613333cba786f1246414e422a5e4c95a /plugins/SendScreenshotPlus/src/UAboutForm.cpp | |
parent | 14d0ed2003485ebf19d45672b065a7dd2bf5274a (diff) |
- warning fixes;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14757 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus/src/UAboutForm.cpp')
-rw-r--r-- | plugins/SendScreenshotPlus/src/UAboutForm.cpp | 141 |
1 files changed, 74 insertions, 67 deletions
diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.cpp b/plugins/SendScreenshotPlus/src/UAboutForm.cpp index f3b50a740d..d21b8deaeb 100644 --- a/plugins/SendScreenshotPlus/src/UAboutForm.cpp +++ b/plugins/SendScreenshotPlus/src/UAboutForm.cpp @@ -29,12 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include <list> -void TfrmAbout::Unload(){ +void TfrmAbout::Unload() +{ std::list<TfrmAbout*> lst; - for(CHandleMapping::iterator iter=_HandleMapping.begin(); iter!=_HandleMapping.end(); ++iter){ + for (CHandleMapping::iterator iter = _HandleMapping.begin(); iter != _HandleMapping.end(); ++iter) { lst.push_back(iter->second);//we can't delete inside loop.. not MT compatible } - while(!lst.empty()){ + while (!lst.empty()) { DestroyWindow(lst.front()->m_hWnd);//deletes class lst.pop_front(); } @@ -46,13 +47,13 @@ TfrmAbout::CHandleMapping TfrmAbout::_HandleMapping; INT_PTR CALLBACK TfrmAbout::DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) { - switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { - case IDC_CREDIT: - case IDC_LICENSE: - SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); - break; - default: - return FALSE; + switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { + case IDC_CREDIT: + case IDC_LICENSE: + SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); + break; + default: + return FALSE; } return (INT_PTR)GetStockObject(WHITE_BRUSH); //GetSysColorBrush(COLOR_WINDOW); } @@ -63,30 +64,30 @@ INT_PTR CALLBACK TfrmAbout::DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPA reinterpret_cast<TfrmAbout*>(lParam)->m_hWnd = hWnd; return wnd->second->wmInitdialog(wParam, lParam); } - wnd=_HandleMapping.find(hWnd); - if (wnd==_HandleMapping.end()) { // something screwed up + wnd = _HandleMapping.find(hWnd); + if (wnd == _HandleMapping.end()) { // something screwed up return FALSE; //dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam); } - switch (msg) - { + switch (msg) { // case WM_INITDIALOG: done on top - case WM_COMMAND: - return wnd->second->wmCommand(wParam, lParam); - break; - case WM_CLOSE: - return wnd->second->wmClose(wParam, lParam); - break; - case WM_DESTROY: - delete wnd->second; - break; + case WM_COMMAND: + return wnd->second->wmCommand(wParam, lParam); + break; + case WM_CLOSE: + return wnd->second->wmClose(wParam, lParam); + break; + case WM_DESTROY: + delete wnd->second; + break; } return FALSE; } //--------------------------------------------------------------------------- //WM_INITDIALOG: -LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { +LRESULT TfrmAbout::wmInitdialog(WPARAM, LPARAM) +{ // Headerbar SendDlgItemMessage(m_hWnd, IDC_HEADERBAR, WM_SETICON, ICON_BIG, (LPARAM)GetIcon(ICO_MAIN)); @@ -96,34 +97,34 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { mir_tstradd(pszText, _T(__COPYRIGHT)); mir_tstradd(pszText, _T("\r\n\r\n")); - HRSRC hRes = FindResource(g_hSendSS,MAKEINTRESOURCE(IDR_LICENSE),_T("TEXT")); - DWORD size = SizeofResource(g_hSendSS,hRes); - char* data = (char*)mir_alloc(size+1); - memcpy(data,LockResource(LoadResource(g_hSendSS,hRes)),size); + HRSRC hRes = FindResource(g_hSendSS, MAKEINTRESOURCE(IDR_LICENSE), _T("TEXT")); + DWORD size = SizeofResource(g_hSendSS, hRes); + char* data = (char*)mir_alloc(size + 1); + memcpy(data, LockResource(LoadResource(g_hSendSS, hRes)), size); data[size] = '\0'; TCHAR* pszCopyright = mir_a2t(data); mir_free(data); mir_tstradd(pszText, pszCopyright); mir_free(pszCopyright); - SetDlgItemText(m_hWnd,IDC_LICENSE, pszText); + SetDlgItemText(m_hWnd, IDC_LICENSE, pszText); mir_free(pszText); } //Credit { - HRSRC hRes = FindResource(g_hSendSS,MAKEINTRESOURCE(IDR_CREDIT),_T("TEXT")); - DWORD size = SizeofResource(g_hSendSS,hRes); - char* data = (char*)mir_alloc(size+1); - memcpy(data,LockResource(LoadResource(g_hSendSS,hRes)),size); + HRSRC hRes = FindResource(g_hSendSS, MAKEINTRESOURCE(IDR_CREDIT), _T("TEXT")); + DWORD size = SizeofResource(g_hSendSS, hRes); + char* data = (char*)mir_alloc(size + 1); + memcpy(data, LockResource(LoadResource(g_hSendSS, hRes)), size); data[size] = '\0'; TCHAR* pszText = mir_a2t(data); mir_free(data); - SetDlgItemText(m_hWnd,IDC_CREDIT, pszText); + SetDlgItemText(m_hWnd, IDC_CREDIT, pszText); mir_free(pszText); } - SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)GetIcon(ICO_MAIN)); - SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)GetIcon(ICO_MAINXS)); + SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)GetIcon(ICO_MAIN)); + SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)GetIcon(ICO_MAINXS)); //init controls btnPageClick(); @@ -133,75 +134,81 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { } //WM_COMMAND: -LRESULT TfrmAbout::wmCommand(WPARAM wParam, LPARAM lParam) { +LRESULT TfrmAbout::wmCommand(WPARAM wParam, LPARAM) +{ //--------------------------------------------------------------------------- if (HIWORD(wParam) == BN_CLICKED) { - switch(LOWORD(wParam)) { - case IDCANCEL: // ESC pressed - this->Close(); - break; - case IDA_btnClose: - Close(); - break; - case IDA_CONTRIBLINK: - m_Page = !m_Page; - btnPageClick(); - break; - default: - break; + switch (LOWORD(wParam)) { + case IDCANCEL: // ESC pressed + this->Close(); + break; + case IDA_btnClose: + Close(); + break; + case IDA_CONTRIBLINK: + m_Page = !m_Page; + btnPageClick(); + break; + default: + break; } } return FALSE; } //WM_CLOSE: -LRESULT TfrmAbout::wmClose(WPARAM wParam, LPARAM lParam) { - SendMessage(m_hWndOwner,UM_CLOSING, (WPARAM)m_hWnd, (LPARAM)IDD_UAboutForm); +LRESULT TfrmAbout::wmClose(WPARAM, LPARAM) +{ + SendMessage(m_hWndOwner, UM_CLOSING, (WPARAM)m_hWnd, (LPARAM)IDD_UAboutForm); DestroyWindow(m_hWnd); return FALSE; } //--------------------------------------------------------------------------- -TfrmAbout::TfrmAbout(HWND Owner) { +TfrmAbout::TfrmAbout(HWND Owner) +{ m_hWndOwner = Owner; m_Page = 1; // create window - m_hWnd = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UAboutForm),0, DlgTfrmAbout,(LPARAM)this); + m_hWnd = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UAboutForm), 0, DlgTfrmAbout, (LPARAM)this); //register object _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this)); } -TfrmAbout::~TfrmAbout() { +TfrmAbout::~TfrmAbout() +{ _HandleMapping.erase(m_hWnd); } //--------------------------------------------------------------------------- -void TfrmAbout::btnPageClick() { +void TfrmAbout::btnPageClick() +{ HWND hCtrl = GetDlgItem(m_hWnd, IDA_CONTRIBLINK); - const TCHAR* credits=TranslateT("Credits"); - const TCHAR* copyright=TranslateT("Copyright"); + const TCHAR* credits = TranslateT("Credits"); + const TCHAR* copyright = TranslateT("Copyright"); const TCHAR* title; const TCHAR* button; - if(!m_Page) { + if (!m_Page) { ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_HIDE); ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_SHOW); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIconBtn(ICO_BTN_ARROWR)); - title=copyright; - button=credits; - } else { + title = copyright; + button = credits; + } + else { ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_SHOW); ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_HIDE); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIconBtn(ICO_BTN_ARROWL)); - title=credits; - button=copyright; + title = credits; + button = copyright; } SetWindowText(hCtrl, button); TCHAR newTitle[128]; TCHAR* pszPlug = mir_a2t(__PLUGIN_NAME); - TCHAR* pszVer = mir_a2t(__VERSION_STRING_DOTS); - mir_sntprintf(newTitle,_countof(newTitle), _T("%s - %s\nv%s"), pszPlug, title , pszVer); + TCHAR* pszVer = mir_a2t(__VERSION_STRING_DOTS); + mir_sntprintf(newTitle, _countof(newTitle), _T("%s - %s\nv%s"), pszPlug, title, pszVer); mir_free(pszPlug); mir_free(pszVer); SetDlgItemText(m_hWnd, IDC_HEADERBAR, newTitle); - InvalidateRect(GetDlgItem(m_hWnd,IDC_HEADERBAR),NULL,1); + InvalidateRect(GetDlgItem(m_hWnd, IDC_HEADERBAR), NULL, 1); } |