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

📄 explorefolders.cpp

📁 funambol window mobile客户端源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
 * Funambol is a mobile platform developed by Funambol, Inc. 
 * 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 Affero General Public License version 3 as published by
 * the Free Software Foundation with the addition of the following permission
 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, see http://www.gnu.org/licenses or write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA.
 * 
 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by Funambol" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by Funambol".
 */

// exploreDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ui.h"

#include "ExploreFolders.h"
#include "FolderCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CExploreFolders dialog

#if defined(WIN32_PLATFORM_PSPC)
    HWND g_hwndTreeView = 0;
    HWND hwndCB;

    HTREEITEM hti, htiNext;
    TCHAR	  szDir[MAX_PATH];
#endif


IMPLEMENT_DYNAMIC(CExploreFolders, CDialog)

CExploreFolders::CExploreFolders(CWnd* pParent /*=NULL*/)
	: CDialog(CExploreFolders::IDD, pParent)
{
}

CExploreFolders::~CExploreFolders()
{
}

void CExploreFolders::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    #if defined(WIN32_PLATFORM_WFSP)
        DDX_Control(pDX, IDC_LIST2, lstFiles);
    #endif
}

BEGIN_MESSAGE_MAP(CExploreFolders, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
	ON_WM_SIZE()
#endif
	//}}AFX_MSG_MAP
    #if defined(WIN32_PLATFORM_WFSP)
        ON_COMMAND(IDCHOOSE, &CExploreFolders::OnChoose)
    #endif

    #if defined(WIN32_PLATFORM_PSPC)
       ON_NOTIFY(TVN_ITEMEXPANDED, IDC_TREEVIEW, &CExploreFolders::OnTvnItemExpanded)
       ON_NOTIFY(TVN_ITEMEXPANDING, IDC_TREEVIEW, &CExploreFolders::OnTvnItemExpanding)
       ON_NOTIFY(NM_DBLCLK, IDC_TREEVIEW, &CExploreFolders::OnTvnDblClk)
       ON_NOTIFY(TVN_SELCHANGED, IDC_TREEVIEW, &CExploreFolders::OnTvnSelChanged)
       ON_WM_CTLCOLOR()
    #endif

END_MESSAGE_MAP()


// CExploreFolders message handlers

BOOL CExploreFolders::OnInitDialog()
{
    CString s1;
    // on sph only briefcase is supported
    #if defined(WIN32_PLATFORM_WFSP)
        s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_EXPLORE_TITLE_BRIEFCASE);
    #else
        if(isNotes){
            s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_EXPLORE_TITLE_NOTES);
        }
        else{
            s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_EXPLORE_TITLE_BRIEFCASE);
        }
    #endif
    SetWindowText(s1);

	CDialog::OnInitDialog();

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

  #if defined(WIN32_PLATFORM_WFSP)

    // set the selection in tree

    s1 = folder;
    // add folders in path list
    CString token(""); int iStart =0;
    CString lastToken("");
    path.push_back(_T("\\"));
    while(iStart!=-1){
        token = s1.Tokenize(_T("\\"), iStart);
        if(iStart != -1){
            path.push_back(token+_T("\\"));
            lastToken = token;
        };
    }
    path.pop_back();

    BuildDirectory(path, s1);

    SetDlgItemText(IDC_EXPLORE_FOLDER, s1);
    s1+="*";
    GetDirectoryContents(&lstFiles, s1.GetBuffer(s1.GetLength()));

    lstFiles.SetFocus();
    lstFiles.SelectString(0,lastToken);

  #else
    // for PPC

    HWND hwndTV;
    CRect rcClient;
    CRect rcHeader;
    g_hInstance = AfxGetInstanceHandle(); // !
    // Start by initializing the common control libraries
    InitCommonControls();
    // Get the client area rect to put the treeview in
    GetClientRect(&rcClient);
    hwndCB = dlgCommandBar.hwndMB;

    GetDlgItem(IDC_HEADER_STATIC)->GetClientRect(&rcHeader);

    // We need to create the treeview control
    hwndTV = CreateWindowEx(0, WC_TREEVIEW, TEXT("Tree View Control"),
        WS_VISIBLE  | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS,
        0, rcHeader.BottomRight().y+5, rcClient.Width(),
        rcClient.Height()- rcHeader.BottomRight().y - 5,
        GetSafeHwnd(),
        (HMENU) IDC_TREEVIEW, g_hInstance, NULL);

    // Make sure the treeview was actually created
    if (!hwndTV){
        return FALSE;
    }

    if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV)) {
        ::DestroyWindow(hwndTV); // check it
        return FALSE;
    }

    // window creation was ok
    g_hwndTreeView = hwndTV;

    // set the selection in tree

    char* source;
    if(isNotes) // display folder for notes or for briefcase
        source = "note";
    else
        source = "briefcase";

    s1 = folder;

    HTREEITEM hti, htiNext, htiRoot, htiFound;
    TVITEM tvi;
    WCHAR tviText[256];

    hti = NULL; htiNext = NULL; htiRoot = NULL; htiFound = NULL;
    hti = AddItemToTree(hwndTV, TEXT("\\"),NULL, true);

    htiRoot = TreeView_GetRoot(hwndTV);
    CString token("\\"); int iStart =0;
    wstring completePath(TEXT(""));
    wstring previousPath(TEXT(""));

    CString lastToken("");

    while(iStart!=-1){
        if(iStart != -1){
            //path.push_back(token+_T("\\"));
            while (hti){
                htiNext = TreeView_GetNextSibling(hwndTV, hti);
                memset(&tvi, 0, sizeof(TV_ITEM));
                tvi.hItem = hti;
                tvi.mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
                tvi.cchTextMax = 256;//*sizeof(wchar_t);
                tvi.pszText = tviText;
                TreeView_GetItem(hwndTV, &tvi);
                if(wcscmp(tviText, token.GetBuffer(token.GetLength())) == 0){
                    htiFound = hti;
                    TreeView_Expand(hwndTV, htiFound,TVE_EXPAND);
                    TreeView_SelectDropTarget(hwndTV, htiFound);
                    hti = NULL;
                    break;
                }
                else{
                    hti = htiNext;
                    if(!htiNext){
                        hti = TreeView_GetChild(hwndTV, htiNext);
                    };
                }
            } // end while (hti)
            lastToken = token;
            hti = TreeView_GetChild(hwndTV, htiFound);
        };
        token = s1.Tokenize(_T("\\"), iStart);

        if (token != "") {
            completePath += TEXT("\\");
            completePath += token;
        }
        if (existsDirectory((wchar_t*)completePath.c_str())) {
            folder = completePath.c_str();
        } else {

⌨️ 快捷键说明

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