void CPasskeyEntry::OnComboSelChange()
{
  CRecentFileList *mru = app.GetMRU();
  int curSel = m_MRU_combo.GetCurSel();
  const int N = mru->GetSize();

  if (curSel == CB_ERR) {
    ASSERT(0);
  } else if (curSel >= N) {
    m_filespec = L"";
  } else {
    int i = int(m_MRU_combo.GetItemData(curSel));
    if (i >= 0) // -1 means original m_filespec
      m_filespec = (*mru)[i];
    else if (i == -2)
      m_filespec = L"";
    else
      m_filespec = m_orig_filespec;
  }

  m_pctlPasskey->SetFocus();
  UpdateRO();
}
Beispiel #2
0
BOOL CGDSApp::OnOpenRecentFile(UINT nID)
{//@CODE_3639

	CRecentFileList *appRFL;
	LPTSTR tExt;
	CDLLInterface *ri;

	appRFL = GetRecentFileList();
	ASSERT(appRFL != NULL);

	ASSERT(nID >= ID_FILE_MRU_FILE1);
	ASSERT(nID < ID_FILE_MRU_FILE1 + (UINT)appRFL->GetSize());
	int nIndex = nID - ID_FILE_MRU_FILE1;
	ASSERT((*appRFL)[nIndex].GetLength() != 0);

	TRACE2("MRU: open file (%d) '%s'.\n", (nIndex) + 1,
			(LPCTSTR)(*appRFL)[nIndex]);

	// figure out type of resource wanted, by extension
	// get last . to find start of extension
	tExt = 	_tcsrchr((*appRFL)[nIndex], '.');

	// if not found, then no extension
	if ((tExt == NULL) || ((ri = FindExtensionMatch(tExt, TRUE)) == NULL))
	{
		MessageBox(GetMainWnd()->m_hWnd,_T("Unable to match extension for MRU file type.\n"), _T("Extension Error!"),
			MB_OK);
		return FALSE;
	}

	// Load/Create new resource
	if (!ri->Load((LPTSTR)(LPCTSTR)(*appRFL)[nIndex]))
		appRFL->Remove(nIndex);

	return TRUE;
}//@CODE_3639
Beispiel #3
0
void CBCGPFileDialog::OnInitDone()
{
	const int iBorderWidth = 20;
	const int iBorderHeight = 40;

	CWnd* pFD = GetParent();
	ASSERT (pFD != NULL);

	CRect rectClient;
	pFD->GetClientRect (rectClient);

	int nNewDlgWidth = rectClient.Width () + iBorderWidth * 2 + m_iExtraWidth;

	if (m_pBmpLogo != NULL)
	{
		BITMAP bmp;
		m_pBmpLogo->GetBitmap (&bmp);

		m_rectLogo = CRect (CPoint (max (0, (nNewDlgWidth - bmp.bmWidth) / 2), 8),
							CSize (bmp.bmWidth, bmp.bmHeight));
		m_iLogoAreaHeight = bmp.bmHeight + 20;
	}

	//---------------------------
	// Adjust parent window size:
	//---------------------------
	pFD->ModifyStyle (WS_THICKFRAME, WS_DLGFRAME | WS_BORDER);
	pFD->ModifyStyleEx (WS_EX_WINDOWEDGE, 0);
	pFD->SetWindowPos (NULL, -1, -1, nNewDlgWidth,
					rectClient.Height () + iBorderHeight * 2 + m_iLogoAreaHeight + m_iExtraHeight,
					SWP_NOMOVE | SWP_NOZORDER  | SWP_NOACTIVATE);

	//-------------------
	// Move all controls:
	//-------------------
	CWnd* pWndChild = pFD->GetWindow (GW_CHILD);
	while (pWndChild != NULL)
	{
		CRect rectCtl;
		pWndChild->GetClientRect (rectCtl);
		pWndChild->MapWindowPoints (pFD, rectCtl);
		pWndChild->SetWindowPos (NULL, 
			rectCtl.left + iBorderWidth, 
			rectCtl.top + iBorderHeight + m_iLogoAreaHeight,
			rectCtl.Width (), rectCtl.Height (), 
			SWP_NOZORDER | SWP_NOACTIVATE);

		pWndChild = pWndChild->GetNextWindow ();
	}

	//------------------------------------------
	// Create new and recent file list controls:
	//------------------------------------------
	CRect rectList (0, 0, 0, 0);
	m_wndNewList.Create (WS_VISIBLE | WS_BORDER | WS_TABSTOP | WS_CHILD | LVS_ICON | LVS_AUTOARRANGE | LVS_SINGLESEL, 
							rectList, pFD, iNewListCtrlId);
	m_wndNewList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	if (m_pImagesNew != NULL)
	{
		m_wndNewList.SetImageList (m_pImagesNew, LVSIL_NORMAL);
	}

	int i = 0;
	for (POSITION pos = m_lstNewItems.GetHeadPosition (); pos != NULL; i ++)
	{
		CNewItemInfo* pInfo = (CNewItemInfo*) m_lstNewItems.GetNext (pos);
		ASSERT_VALID (pInfo);

		m_wndNewList.InsertItem (i, pInfo->m_strName, pInfo->m_iIconIndex);
	}

	m_wndRecentList.Create (WS_TABSTOP | WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT, 
							rectList, pFD, iRecentListCtrlId);
	m_wndRecentList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	m_ImagesRecent.Create (	globalData.m_sizeSmallIcon.cx,
							globalData.m_sizeSmallIcon.cy,
							ILC_COLOR, 0, 10);
	m_wndRecentList.SetImageList (&m_ImagesRecent, LVSIL_SMALL);

	{
		CBCGPLocalResource locaRes;

		CString strFile;
		strFile.LoadString (IDS_BCGBARRES_FILE);
		m_wndRecentList.InsertColumn (0, strFile, LVCFMT_LEFT, 100);

		CString strFolder;
		strFolder.LoadString (IDS_BCGBARRES_FOLDER);
		m_wndRecentList.InsertColumn (1, strFolder);
	}

	CRecentFileList* pMRUFiles = 
		((CBCGApp*) AfxGetApp ())->m_pRecentFileList;

	if (pMRUFiles != NULL)
	{
		TCHAR szCurDir [_MAX_PATH + 1];
		::GetCurrentDirectory (_MAX_PATH, szCurDir);

		int nCurDir = lstrlen (szCurDir);
		ASSERT (nCurDir >= 0);

		szCurDir [nCurDir] = _T('\\');
		szCurDir [++ nCurDir] = _T('\0');

		//---------------
		// Add MRU files:
		//---------------
		int iNumOfFiles = 0;	// Actual added to menu
		for (int i = 0; i < pMRUFiles->GetSize (); i ++)
		{
			CString strFile = (*pMRUFiles) [i];
			if (!strFile.IsEmpty ())
			{
				CString strPath;
				CString strName;
				int iImage = -1;

				int iIndex = strFile.ReverseFind (_T('\\'));
				if (iIndex != -1)
				{
					strPath = strFile.Left (iIndex);
					strName = strFile.Mid (iIndex + 1);
				}
				else
				{
					strName = strFile;
				}

				SHFILEINFO  sfi;
				HIMAGELIST himlSmall = (HIMAGELIST) SHGetFileInfo (strFile,
                                       0,
                                       &sfi, 
                                       sizeof(SHFILEINFO), 
                                       SHGFI_SYSICONINDEX | SHGFI_SMALLICON);

				if (himlSmall != NULL)
				{
					CImageList* pImages = CImageList::FromHandle (himlSmall);
					ASSERT (pImages != NULL);

					HICON hIcon = pImages->ExtractIcon (sfi.iIcon);
					iImage = m_ImagesRecent.Add (hIcon);
					if (hIcon != NULL)
					{
						::DestroyIcon (hIcon);
					}
				}

				iIndex = m_wndRecentList.InsertItem (iNumOfFiles ++, strName, iImage);
				m_wndRecentList.SetItemText (iIndex, 1, strPath);

				int iPathWidth = m_wndRecentList.GetStringWidth (strPath) + 20;
				if (iPathWidth > m_wndRecentList.GetColumnWidth (1))
				{
					m_wndRecentList.SetColumnWidth (1, iPathWidth);
				}
			}
		}
	}

	//---------------------
	// Create tabs control:
	//---------------------
	CRect rectTabs;
	pFD->GetClientRect (rectTabs);
	rectTabs.DeflateRect (4, 4);
	rectTabs.top += m_iLogoAreaHeight;

	m_wndTab.Create (CBCGPTabWnd::STYLE_3D, rectTabs, pFD, iTabCtrlId, 
		CBCGPTabWnd::LOCATION_TOP);
	m_wndTab.m_pParent = this;
	m_wndTab.SetActiveTabBoldFont ();

	m_wndTab.SetFont (GetFont ());
	m_wndTab.SetOwner (this);

	m_wndDummy.Create (_T(""), WS_CHILD, CRect (0, 0, 0, 0), this);

	{
		CBCGPLocalResource locaRes;
		CString strTab;

		if (m_bNewPage)
		{
			m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_NEW_FILE, (UINT)-1, FALSE);
		}

		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_EXISTING, (UINT)-1, FALSE);
		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_RECENT, (UINT)-1, FALSE);
	}

	pFD->CenterWindow ();
	pFD->SetWindowText (m_strCaption);

	//------------------
	// Set dilaog icons:
	//------------------
	if (m_hIconSmall != NULL)
	{
		pFD->SetIcon (m_hIconSmall, FALSE);
	}

	if (m_hIconBig != NULL)
	{
		pFD->SetIcon (m_hIconBig, TRUE);
	}

	//--------------------------
	// Setup parent window proc:
	//--------------------------
	m_wndProc = (WNDPROC)SetWindowLongPtr(pFD->m_hWnd, GWLP_WNDPROC, 
		(LONG_PTR) CBCGPFileDialog::WindowProcNew);
}
void CWizardView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( UPDATE_HINT_WIZARDVIEW != lHint )
	{
		if( ::IsWindow( m_listRecent.GetSafeHwnd() ) )
			m_listRecent.Invalidate( );
		return;
	}
	if( IsWindowVisible() )
		SetFocus( );

	m_listRecent.DeleteAllItems( );

	//	insert items
	CStkUIApp * pApp = AfxGetStkUIApp();
	CRecentFileList * pRecent = NULL;
	if( pApp )
		pRecent = pApp->GetRecentFileList( );

	CString	strOpened;
	strOpened.LoadString( IDS_STRATEGYOPENED );

	CStringArray	astrAdded;

	int	count	=	0;
	if( pRecent )
	{
		for( int i=pRecent->GetSize()-1; i>=0; i-- )
		{
			CString strPath = (*pRecent)[i];
			if( strPath.IsEmpty() )
				continue;
			if( 0 != access(strPath,0) )
			{
				pRecent->Remove(i);
				continue;
			}

			TCHAR	szFullPath[_MAX_PATH];
			AfxFullPath( szFullPath, strPath );
			strPath	=	szFullPath;

			CString strName	=	CStrategy::GetName( strPath );
			BOOL	bOpened	=	pApp->IsFileOpened( strPath );
			int nItem = m_listRecent.InsertItem( count, strPath, bOpened ? 1 : 0 );
			m_listRecent.SetItemText( nItem, 0, strName );
			m_listRecent.SetItemText( nItem, 1, strPath );
			if( bOpened )
				m_listRecent.SetItemText( nItem, 3, strOpened );
			astrAdded.Add( strPath );
			
			CString	strTime;
			CFileStatus	status;
			if( CFile::GetStatus( strPath, status ) )
			{
				strTime = status.m_mtime.Format( "%Y-%m-%d" );
				m_listRecent.SetItemText( nItem, 2, strTime );
			}
			count ++;
		}
	}

	CString strExt	=	AfxGetStrategyFileExt( );
	if( !strExt.IsEmpty())
	{
		CFileFind finder;
		BOOL	bWorking	=	finder.FindFile( AfxGetFilePath( (LPCTSTR)AfxGetProfile().GetProjectPath(), LPCTSTR("*" + strExt) ) );
		while( bWorking )
		{
			bWorking	=	finder.FindNextFile();
			CString	strPath	=	finder.GetFilePath();

			int i;
			for( i=0; i<astrAdded.GetSize(); i++ )
			{
				if( 0 == strPath.CompareNoCase( astrAdded.ElementAt(i) ) )
					break;
			}
			if( i < astrAdded.GetSize() )
				continue;

			CString strName	=	CStrategy::GetName( strPath );
			BOOL	bOpened	=	pApp->IsFileOpened( strPath );
			int nItem = m_listRecent.InsertItem( count, strPath, bOpened ? 1 : 0 );
			m_listRecent.SetItemText( nItem, 0, strName );
			m_listRecent.SetItemText( nItem, 1, strPath );
			if( bOpened )
				m_listRecent.SetItemText( nItem, 3, strOpened );

			CString	strTime;
			CFileStatus	status;
			if( CFile::GetStatus( strPath, status ) )
			{
				strTime = status.m_mtime.Format( "%Y-%m-%d" );
				m_listRecent.SetItemText( nItem, 2, strTime );
			}
			count ++;

			if( count >= 256 )
				break;
		}
		finder.Close();
	}

	m_listRecent.Invalidate( );
}
//***********************************************************************************************	
void CBCGPRecentFilesListBox::FillList(LPCTSTR lpszSelectedPath/* = NULL*/)
{
	ASSERT(GetSafeHwnd() != NULL);

	ResetContent();
	ResetPins();
	
	m_lstCaptionIndexes.RemoveAll();

	m_nHighlightedItem = -1;
	m_bIsPinHighlighted = FALSE;

	int cyIcon = 32;

	if (globalData.GetRibbonImageScale () != 1.)
	{
		cyIcon = (int) (.5 + globalData.GetRibbonImageScale () * cyIcon);
	}

	int nItemHeight = max(cyIcon + 4, globalData.GetTextHeight () * 5 / 2);
	
	SetItemHeight(-1, nItemHeight);

	for (int i = 0; i < m_arIcons.GetSize(); i++)
	{
		HICON hIcon = m_arIcons[i];
		if (hIcon != NULL)
		{
			::DestroyIcon(hIcon);
		}
	}

	m_arIcons.RemoveAll();

	BOOL bHasPinnedItems = FALSE;

	// Add "pinned" items first
	if (g_pWorkspace != NULL)
	{
		const CStringArray& ar = g_pWorkspace->GetPinnedPaths(!m_bFoldersMode);

		for (int i = 0; i < (int)ar.GetSize(); i++)
		{
			int nIndex = AddItem(ar[i], 0, TRUE);
			if (nIndex >= 0 && lpszSelectedPath != NULL && ar[i] == lpszSelectedPath)
			{
				SetCurSel(nIndex);
			}

			if (nIndex >= 0)
			{
				bHasPinnedItems = TRUE;
			}
		}
	}

	if (bHasPinnedItems)
	{
		AddSeparator();
		m_arIcons.Add(NULL);
	}

	// Add MRU files:
	CRecentFileList* pMRUFiles = 
		((CBCGPApp*) AfxGetApp ())->m_pRecentFileList;

	if (pMRUFiles != NULL)
	{
		for (int i = 0; i < pMRUFiles->GetSize (); i++)
		{
			CString strPath = (*pMRUFiles)[i];

			int nIndex = AddItem(strPath, (ID_FILE_MRU_FILE1 + i));
			if (nIndex >= 0 && lpszSelectedPath != NULL && strPath == lpszSelectedPath)
			{
				SetCurSel(nIndex);
			}
		}
	}

	int nLastIndex = GetCount() - 1;
	if (nLastIndex >= 0 && IsSeparatorItem(nLastIndex))
	{
		DeleteString(nLastIndex);
	}
}
BOOL CPasskeyEntry::OnInitDialog(void)
{
  CPKBaseDlg::OnInitDialog();

  Fonts::GetInstance()->ApplyPasswordFont(GetDlgItem(IDC_PASSKEY));
  m_pctlPasskey->SetPasswordChar(PSSWDCHAR);

  switch(m_index) {
    case GCP_FIRST:
      // At start up - give the user the option unless file is R-O
      GetDlgItem(IDC_READONLY)->EnableWindow(m_bForceReadOnly ? FALSE : TRUE);
      GetDlgItem(IDC_READONLY)->ShowWindow(SW_SHOW);
      GetDlgItem(IDC_VERSION)->SetWindowText(m_appversion);
      break;
    case GCP_NORMAL:
      // otherwise during open - user can - again unless file is R-O
      if (m_bHideReadOnly) {
        GetDlgItem(IDC_READONLY)->EnableWindow(FALSE);
        GetDlgItem(IDC_READONLY)->ShowWindow(SW_HIDE);
      } else {
        GetDlgItem(IDC_READONLY)->EnableWindow(m_bForceReadOnly ? FALSE : TRUE);
        GetDlgItem(IDC_READONLY)->ShowWindow(SW_SHOW);
      }
      break;
    case GCP_RESTORE:
    case GCP_WITHEXIT:
      GetDlgItem(IDC_READONLY)->EnableWindow(m_bForceReadOnly ? FALSE : TRUE);
      GetDlgItem(IDC_READONLY)->ShowWindow(SW_SHOW);
      break;
    case GCP_CHANGEMODE:
      GetDlgItem(IDC_READONLY)->EnableWindow(FALSE);
      GetDlgItem(IDC_READONLY)->ShowWindow(SW_HIDE);
      break;
    default:
      ASSERT(FALSE);
  }

  // Only show virtual Keyboard menu if we can load DLL
  if (!CVKeyBoardDlg::IsOSKAvailable()) {
    GetDlgItem(IDC_VKB)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_VKB)->EnableWindow(FALSE);
  }

  if (m_index == GCP_FIRST) {
    GetDlgItem(IDC_SELECTED_DATABASE)->ShowWindow(SW_HIDE);

    CRecentFileList *mru = app.GetMRU();
    ASSERT(mru != NULL);

    int N = mru->GetSize();

    std::vector<CSecString> cs_tooltips;

    if (!m_filespec.IsEmpty()) {
      cs_tooltips.push_back(m_filespec);
      m_MRU_combo.AddString(NarrowPathText(m_filespec));
      m_MRU_combo.SelectString(-1, NarrowPathText(m_filespec));
      m_MRU_combo.SetItemData(0, DWORD_PTR(-1));
    }

    for (int i = 0; i < N; i++) {
      const CString &str = (*mru)[i];
      if (str != m_filespec && !str.IsEmpty()) {
        cs_tooltips.push_back(str);
        int li = m_MRU_combo.AddString(NarrowPathText(str));
        if (li != CB_ERR && li != CB_ERRSPACE)
          m_MRU_combo.SetItemData(li, i);
      }
    }
    if ((N > 0) || !m_filespec.IsEmpty()) {
      // Add an empty row to allow NODB
      int li = m_MRU_combo.AddString(L"");
      if (li != CB_ERR && li != CB_ERRSPACE) {
        m_MRU_combo.SetItemData(li, DWORD_PTR(-2)); // -1 already taken, but a < 0 value is easier to check than N
        CString cs_empty(MAKEINTRESOURCE(IDS_EMPTY_DB));
        cs_tooltips.push_back(cs_empty);
        N++; // for SetHeight
      }
    }

    if (N > 0) {
      SetHeight(N);
    }

    m_MRU_combo.SetToolTipStrings(cs_tooltips);
  }

  /*
   * this bit makes the background come out right on the bitmaps
   */

  if (m_index == GCP_FIRST) {
    m_ctlLogoText.ReloadBitmap(IDB_PSLOGO);
    m_ctlLogo.ReloadBitmap(IDB_CLOGO);
  } else {
    m_ctlLogo.ReloadBitmap(IDB_CLOGO_SMALL);
  }

  // Set the icon for this dialog.  The framework does this automatically
  //  when the application's main window is not a dialog

  SetIcon(m_hIcon, TRUE);  // Set big icon
  SetIcon(m_hIcon, FALSE); // Set small icon

  if (app.WasHotKeyPressed()) {
    // Reset it
    app.SetHotKeyPressed(false);
    // Following (1) brings to top when hotkey pressed,
    // (2) ensures focus is on password entry field, where it belongs.
    // This is "stronger" than BringWindowToTop().
    SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    SetActiveWindow();
    SetForegroundWindow();
    m_pctlPasskey->SetFocus();
    return FALSE;
  }

  // Following works fine for other (non-hotkey) cases:
  SetForegroundWindow();

  // If the dbase field's !empty, the user most likely will want to enter
  // a password:
  if (m_index == GCP_FIRST && !m_filespec.IsEmpty()) {
    m_MRU_combo.SetEditSel(-1, -1);
    m_pctlPasskey->SetFocus();
    return FALSE;
  }

  return TRUE;
}