⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 about.cpp

📁 funambol windows mobile plugin source code, the source code is taken from the funambol site
💻 CPP
字号:
/*
 * Copyright (C) 2003-2007 Funambol, Inc
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */

// About.cpp : implementation file
//

#include "stdafx.h"
#include "ui.h"
#include "About.h"
#include "customization.h"


// CAbout dialog

IMPLEMENT_DYNAMIC(CAbout, CDialog)

CAbout::CAbout(CWnd* pParent /*=NULL*/)
	: CDialog(CAbout::IDD, pParent)
{
    EEG = 0;

}

CAbout::~CAbout()
{
}

void CAbout::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_ABOUT_MSG, staticAboutMsg);
}


BEGIN_MESSAGE_MAP(CAbout, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
    ON_WM_SIZE()
#endif
    ON_WM_CTLCOLOR()
    ON_COMMAND(ID_SILENT, &CAbout::EE)
END_MESSAGE_MAP()


// CAbout message handlers

void CAbout::EE(){
    ++EEG;
    if(EEG == 10){
        CString s2;
        s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SILENT);
        SetDlgItemText(IDC_ABOUT_MSG, s2);
    }
}

BOOL CAbout::OnInitDialog()
{
    CString s1;

    // set window text title
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ABOUT); SetWindowText(s1);

    CDialog::OnInitDialog();

    ZeroMemory(&dlgCommandBar, sizeof(SHMENUBARINFO));
    dlgCommandBar.cbSize = sizeof(SHMENUBARINFO);
    dlgCommandBar.hwndParent = this->GetSafeHwnd();
    dlgCommandBar.dwFlags = SHCMBF_HMENU;
    dlgCommandBar.nToolBarId = IDM_SK1_CLOSE;
    #if defined WIN32_PLATFORM_WFSP
    #if (_WIN32_WCE < 0x500)
        dlgCommandBar.nToolBarId = IDR_MENUBAR_CLOSE;
    #endif
    #endif
    dlgCommandBar.hInstRes = getLocalizationUtils()->getLocaleResource();
    dlgCommandBar.nBmpId = 0;
    dlgCommandBar.cBmpImages = 0;
    if(!SHCreateMenuBar(&dlgCommandBar)){
          TRACE(_T("Cannot create command bar!"));
          return FALSE;
        };

    // load plugin version from Registry
    HKEY key;
    long err=0;
    ULONG dim;
    TCHAR *buf = NULL;

    RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("\\Software\\") ROOT_CONTEXT_W,
                    0, KEY_READ,  &key);
    if(key != 0)
    {
        // Get value length
        err = RegQueryValueEx(key, PLUGIN_VERSION, NULL, NULL, NULL, &dim);

        if (err == ERROR_SUCCESS) {
            if (dim > 0) {
                buf = new TCHAR[dim + 1];
                err = RegQueryValueEx(key, PLUGIN_VERSION, NULL, NULL,(UCHAR*)buf, &dim);
            }
        }
    }

    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ABOUT_MSG1);

    CString s2(buf);
    if(s2 != ""){
        s1+= s2;
        s1+="\n";
    }

    s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ABOUT_MSG2);
    s1+=s2;
    aboutMessage = s1;
    SetDlgItemText(IDC_ABOUT_MSG, aboutMessage);
    RegCloseKey(key);

    if(buf){
        delete [] buf; buf = NULL;
    }

    // set image position
    CRect rectImage;
    CRect rectClient;
    int x = 0;
    GetClientRect(&rectClient);
    GetDlgItem(IDC_IMG_FUNLOGO)->GetClientRect(&rectImage);
    x = (rectClient.Width()/2) - (rectImage.Width()/2);
    GetDlgItem(IDC_IMG_FUNLOGO)->SetWindowPos(&CWnd::wndTop, x,17,100,100,SWP_NOSIZE);

    // set text position
    CRect rectText;
    GetClientRect(&rectClient);
    GetDlgItem(IDC_ABOUT_MSG)->GetClientRect(&rectText);
    x = (rectClient.Width()/2) - (rectText.Width()/2);
    GetDlgItem(IDC_ABOUT_MSG)->SetWindowPos(&CWnd::wndTop, x,rectImage.BottomRight().y + 12,100,100,SWP_NOSIZE);

    // set ppc header
    LOGFONT lf;
    memset(&lf, 0, sizeof(LOGFONT));
    HFONT hFont = (HFONT) GetStockObject(SYSTEM_FONT);
    GetObject(hFont, sizeof lf, &lf);
    lf.lfWeight = FW_BOLD;
    lf.lfHeight +=FONT_HEIGHT_OFFSET;
    VERIFY(fontBold.CreateFontIndirect(&lf));

    #if defined(WIN32_PLATFORM_PSPC)
        s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ABOUT); SetDlgItemText(IDC_HEADER_STATIC, s1);
        GetDlgItem(IDC_HEADER_STATIC)->SetFont(&fontBold);
    #endif


    // fix for wrong title problem, we get & set the title for the main window
    wchar_t title[256];
    AfxGetMainWnd()->GetWindowText(title,256);
    AfxGetMainWnd()->SetWindowText(title);

    return TRUE;
}

#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CAbout::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
    int resId;
    CString s1;
    switch(DRA::GetDisplayMode())
    {
    case DRA::Landscape:
        resId = IDD_UI_ABOUT_WIDE; break;
    case DRA::Portrait:
        resId = IDD_UI_ABOUT; break;
    case DRA::Square:
        resId = IDD_UI_ABOUT_SQUARE; break;
    default:
        resId = IDD_UI_ABOUT; break;
    };

    DRA::RelayoutDialog( AfxGetInstanceHandle(), this->m_hWnd, MAKEINTRESOURCE(resId));

    // set image position
    CRect rectImage;
    CRect rectClient;
    int x = 0;
    GetClientRect(&rectClient);
    GetDlgItem(IDC_IMG_FUNLOGO)->GetClientRect(&rectImage);
    x = (rectClient.Width()/2) - (rectImage.Width()/2);
    GetDlgItem(IDC_IMG_FUNLOGO)->SetWindowPos(&CWnd::wndTop, x,17,100,100,SWP_NOSIZE);

    // set text position
    CRect rectText;
    GetClientRect(&rectClient);
    GetDlgItem(IDC_ABOUT_MSG)->GetClientRect(&rectText);
    x = (rectClient.Width()/2) - (rectText.Width()/2);
    GetDlgItem(IDC_ABOUT_MSG)->SetWindowPos(&CWnd::wndTop, x,rectImage.BottomRight().y + 12,100,100,SWP_NOSIZE);

    SetDlgItemText(IDC_ABOUT_MSG, aboutMessage);

    #if defined(WIN32_PLATFORM_PSPC)
        s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ABOUT); SetDlgItemText(IDC_HEADER_STATIC, s1);
    #endif
}
#endif

HBRUSH CAbout::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    // set ppc header text color
    #if defined(WIN32_PLATFORM_PSPC)
    if(pWnd->GetDlgCtrlID() == IDC_HEADER_STATIC) {
        pDC->SetBkMode(TRANSPARENT);
        pDC->SetTextColor(PPC_HEADER_TEXT_COLOR);
    }
    #endif

    return hbr;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -