Removed SeaShell from the tip.

Its in the attic if anyone needs to look at it.

svn path=/trunk/; revision=10746
This commit is contained in:
Steven Edwards
2004-08-31 02:38:41 +00:00
parent 37aba5c9fc
commit 51bdcda011
123 changed files with 0 additions and 29126 deletions
@@ -1,12 +0,0 @@
Debug
Release
*.coff
*.exe
*.d
*.o
*.sym
*.map
*.aps
*.res
*.opt
*.ncb
@@ -1,54 +0,0 @@
// FilterDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SeaShell.h"
#include "FilterDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFilterDlg dialog
CFilterDlg::CFilterDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFilterDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFilterDlg)
m_FileType = _T("");
m_Filter = _T("");
//}}AFX_DATA_INIT
}
void CFilterDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFilterDlg)
DDX_Text(pDX, IDC_EDIT_FILE_TYPE, m_FileType);
DDX_Text(pDX, IDC_EDIT_FILTER, m_Filter);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFilterDlg, CDialog)
//{{AFX_MSG_MAP(CFilterDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFilterDlg message handlers
BOOL CFilterDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
@@ -1,47 +0,0 @@
#if !defined(AFX_FILTERDLG_H__72E6269E_A226_4DA4_83CB_28B40EFDB28E__INCLUDED_)
#define AFX_FILTERDLG_H__72E6269E_A226_4DA4_83CB_28B40EFDB28E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FilterDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CFilterDlg dialog
class CFilterDlg : public CDialog
{
// Construction
public:
CFilterDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CFilterDlg)
enum { IDD = IDD_FILTER };
CString m_FileType;
CString m_Filter;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFilterDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFilterDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FILTERDLG_H__72E6269E_A226_4DA4_83CB_28B40EFDB28E__INCLUDED_)
@@ -1,114 +0,0 @@
// LeftView.cpp : implementation of the CLeftView class
//
#include "stdafx.h"
#include "SeaShell.h"
#include "SeaShellDoc.h"
#include "LeftView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLeftView
IMPLEMENT_DYNCREATE(CLeftView, CIEShellTreeView)
BEGIN_MESSAGE_MAP(CLeftView, CIEShellTreeView)
//{{AFX_MSG_MAP(CLeftView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CIEShellTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CIEShellTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CIEShellTreeView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLeftView construction/destruction
CLeftView::CLeftView()
{
// TODO: add construction code here
}
CLeftView::~CLeftView()
{
}
BOOL CLeftView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CIEShellTreeView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CLeftView drawing
void CLeftView::OnDraw(CDC* pDC)
{
CSeaShellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CLeftView printing
BOOL CLeftView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CLeftView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CLeftView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CLeftView::OnInitialUpdate()
{
CIEShellTreeView::OnInitialUpdate();
// TODO: You may populate your TreeView with items by directly accessing
// its tree control through a call to GetTreeCtrl().
}
/////////////////////////////////////////////////////////////////////////////
// CLeftView diagnostics
#ifdef _DEBUG
void CLeftView::AssertValid() const
{
CIEShellTreeView::AssertValid();
}
void CLeftView::Dump(CDumpContext& dc) const
{
CIEShellTreeView::Dump(dc);
}
CSeaShellDoc* CLeftView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSeaShellDoc)));
return (CSeaShellDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLeftView message handlers
@@ -1,71 +0,0 @@
// LeftView.h : interface of the CLeftView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_LEFTVIEW_H__A7EC0A9D_0FD3_4C0B_8853_C94ACB0213E2__INCLUDED_)
#define AFX_LEFTVIEW_H__A7EC0A9D_0FD3_4C0B_8853_C94ACB0213E2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CSeaShellDoc;
#include "IEShellTreeView.h"
class CLeftView : public CIEShellTreeView
{
protected: // create from serialization only
CLeftView();
DECLARE_DYNCREATE(CLeftView)
// Attributes
public:
CSeaShellDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLeftView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnInitialUpdate(); // called first time after construct
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CLeftView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CLeftView)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in LeftView.cpp
inline CSeaShellDoc* CLeftView::GetDocument()
{ return (CSeaShellDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LEFTVIEW_H__A7EC0A9D_0FD3_4C0B_8853_C94ACB0213E2__INCLUDED_)
@@ -1,88 +0,0 @@
// MFCExplorerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SeaShell.h"
#include "MFCExplorerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMFCExplorerDlg dialog
CMFCExplorerDlg::CMFCExplorerDlg(LPCTSTR pszPath,CWnd* pParent /*=NULL*/)
: CDialog(CMFCExplorerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMFCExplorerDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
if (pszPath)
m_sPath = pszPath;
}
void CMFCExplorerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMFCExplorerDlg)
DDX_Control(pDX, IDC_TREE_SHELL, m_tcShell);
DDX_Control(pDX, IDC_LIST_SHELL, m_lcShell);
DDX_Control(pDX, IDC_COMBO_SHELL, m_cbShell);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMFCExplorerDlg, CDialog)
//{{AFX_MSG_MAP(CMFCExplorerDlg)
ON_BN_CLICKED(IDC_MFC_BUTT_DETAILS, OnMfcButtDetails)
ON_BN_CLICKED(IDC_MFC_BUTT_LARGE_ICONS, OnMfcButtLargeIcons)
ON_BN_CLICKED(IDC_MFC_BUTT_REPORT, OnMfcButtReport)
ON_BN_CLICKED(IDC_MFC_BUTT_SMALL_ICONS, OnMfcButtSmallIcons)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMFCExplorerDlg message handlers
void CMFCExplorerDlg::OnMfcButtDetails()
{
// TODO: Add your control notification handler code here
m_lcShell.SetViewType(LVS_LIST);
}
void CMFCExplorerDlg::OnMfcButtLargeIcons()
{
// TODO: Add your control notification handler code here
m_lcShell.SetViewType(LVS_ICON);
}
void CMFCExplorerDlg::OnMfcButtReport()
{
// TODO: Add your control notification handler code here
m_lcShell.SetViewType(LVS_REPORT);
}
void CMFCExplorerDlg::OnMfcButtSmallIcons()
{
// TODO: Add your control notification handler code here
m_lcShell.SetViewType(LVS_SMALLICON);
}
BOOL CMFCExplorerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_cbShell.SetTreeCtrlWnd(m_tcShell.GetSafeHwnd());
m_tcShell.SetListCtrlWnd(m_lcShell.GetSafeHwnd());
m_tcShell.SetComboBoxWnd(m_cbShell.GetSafeHwnd());
m_tcShell.LoadFolderItems(m_sPath);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
@@ -1,56 +0,0 @@
#if !defined(AFX_MFCEXPLORERDLG_H__CDBB7A42_DEE1_4AFC_A7A3_13FE102A30EE__INCLUDED_)
#define AFX_MFCEXPLORERDLG_H__CDBB7A42_DEE1_4AFC_A7A3_13FE102A30EE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MFCExplorerDlg.h : header file
//
#include "IEShellTreeCtrl.h"
#include "IEShellListCtrl.h"
#include "IEShellComboBox.h"
/////////////////////////////////////////////////////////////////////////////
// CMFCExplorerDlg dialog
class CMFCExplorerDlg : public CDialog
{
// Construction
public:
CMFCExplorerDlg(LPCTSTR pszPath=NULL,CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CMFCExplorerDlg)
enum { IDD = IDD_MFC_EXPLORER };
CIEShellTreeCtrl m_tcShell;
CIEShellListCtrl m_lcShell;
CIEShellComboBox m_cbShell;
//}}AFX_DATA
void SetPath(LPCTSTR pszPath) { m_sPath = pszPath; }
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMFCExplorerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMFCExplorerDlg)
afx_msg void OnMfcButtDetails();
afx_msg void OnMfcButtLargeIcons();
afx_msg void OnMfcButtReport();
afx_msg void OnMfcButtSmallIcons();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CString m_sPath;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MFCEXPLORERDLG_H__CDBB7A42_DEE1_4AFC_A7A3_13FE102A30EE__INCLUDED_)
@@ -1,262 +0,0 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "SeaShell.h"
#include "MFCExplorerDlg.h"
#include "FilterDlg.h"
#include "ShellTreeDlg.h"
#include "MainFrm.h"
#include "LeftView.h"
#include "SeaShellView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CUIExplorerFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CUIExplorerFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_EXPLORERDIALOG, OnViewExplorerdialog)
ON_COMMAND(ID_VIEW_FILEFILTER, OnViewFilefilter)
ON_COMMAND(ID_VIEW_TREEDIALOG, OnViewTreedialog)
//}}AFX_MSG_MAP
ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
ON_MESSAGE(WM_SETTINGCHANGE,OnSettingChange)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_IDToolbar = IDR_MAINFRAME;
SetExplorerView(RUNTIME_CLASS(CSeaShellView));
}
CMainFrame::~CMainFrame()
{
}
void CMainFrame::CreateCoolBar()
{
if (m_pwndCoolBar == NULL)
m_pwndCoolBar = new CWebBrowserCoolBar;
// hook up the frame window for notification messages
((CWebBrowserCoolBar*)m_pwndCoolBar)->GetComboBox().SetTreeCtrlWnd(GetSafeHwnd());
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CUIExplorerFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CUIExplorerFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CUIExplorerFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CUIExplorerFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
CSeaShellView* CMainFrame::GetRightPane()
{
CWnd* pWnd = GetSplitterWnd().GetPane(0, 1);
CSeaShellView* pView = DYNAMIC_DOWNCAST(CSeaShellView, pWnd);
return pView;
}
void CMainFrame::OnUpdateViewStyles(CCmdUI* pCmdUI)
{
// TODO: customize or extend this code to handle choices on the
// View menu.
CSeaShellView* pView = GetRightPane();
// if the right-hand pane hasn't been created or isn't a view,
// disable commands in our range
if (pView == NULL)
pCmdUI->Enable(FALSE);
else
{
DWORD dwStyle = pView->GetListCtrl().GetViewType();
// if the command is ID_VIEW_LINEUP, only enable command
// when we're in LVS_ICON or LVS_SMALLICON mode
if (pCmdUI->m_nID == ID_VIEW_LINEUP)
{
if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
pCmdUI->Enable();
else
pCmdUI->Enable(FALSE);
}
else
{
// otherwise, use dots to reflect the style of the view
pCmdUI->Enable();
BOOL bChecked = FALSE;
switch (pCmdUI->m_nID)
{
case ID_VIEW_DETAILS:
bChecked = (dwStyle == LVS_REPORT);
break;
case ID_VIEW_SMALLICON:
bChecked = (dwStyle == LVS_SMALLICON);
break;
case ID_VIEW_LARGEICON:
bChecked = (dwStyle == LVS_ICON);
break;
case ID_VIEW_LIST:
bChecked = (dwStyle == LVS_LIST);
break;
default:
bChecked = FALSE;
break;
}
pCmdUI->SetRadio(bChecked ? 1 : 0);
}
}
}
void CMainFrame::OnViewStyle(UINT nCommandID)
{
// TODO: customize or extend this code to handle choices on the
// View menu.
CSeaShellView* pView = (CSeaShellView*)theApp.GetView(RUNTIME_CLASS(CSeaShellView));;
// if the right-hand pane has been created and is a CSeaShellView,
// process the menu commands...
if (pView != NULL)
{
DWORD dwStyle = -1;
switch (nCommandID)
{
case ID_VIEW_LINEUP:
{
// ask the list control to snap to grid
CListCtrl& refListCtrl = pView->GetListCtrl();
refListCtrl.Arrange(LVA_SNAPTOGRID);
}
break;
// other commands change the style on the list control
case ID_VIEW_DETAILS:
dwStyle = LVS_REPORT;
break;
case ID_VIEW_SMALLICON:
dwStyle = LVS_SMALLICON;
break;
case ID_VIEW_LARGEICON:
dwStyle = LVS_ICON;
break;
case ID_VIEW_LIST:
dwStyle = LVS_LIST;
break;
}
// change the style; window will repaint automatically
if (dwStyle != -1)
pView->GetListCtrl().SetViewType(dwStyle);
}
}
LRESULT CMainFrame::OnSettingChange(WPARAM wParam, LPARAM lParam)
{
TRACE(_T("OnSettingChange\n"));
CSeaShellView *pListView = (CSeaShellView*)theApp.GetView(RUNTIME_CLASS(CSeaShellView));
if (pListView)
pListView->GetListCtrl().SendMessage(WM_SETTINGCHANGE,wParam,lParam);
return 1;
}
void CMainFrame::OnViewExplorerdialog()
{
// TODO: Add your command handler code here
CLeftView *pTreeView = (CLeftView*)theApp.GetView(RUNTIME_CLASS(CLeftView));
CMFCExplorerDlg dlg;
if (pTreeView && pTreeView->GetShellTreeCtrl().GetSelectedItem() != pTreeView->GetShellTreeCtrl().GetRootItem())
{
dlg.SetPath(pTreeView->GetShellTreeCtrl().GetSelectedPath());
}
dlg.DoModal();
}
void CMainFrame::OnViewFilefilter()
{
// TODO: Add your command handler code here
CSeaShellView *pListView = (CSeaShellView*)theApp.GetView(RUNTIME_CLASS(CSeaShellView));
if (pListView)
{
CFilterDlg dlg;
dlg.m_Filter = pListView->GetShellListCtrl().GetFileFilter();
if (!pListView->GetShellListCtrl().GetExcludedFileTypes().IsEmpty())
dlg.m_FileType = pListView->GetShellListCtrl().GetExcludedFileTypes().GetHead();
if (dlg.DoModal() == IDOK)
{
if (!dlg.m_FileType.IsEmpty())
pListView->GetShellListCtrl().ExcludeFileType(dlg.m_FileType);
pListView->GetShellListCtrl().SetFileFilter(dlg.m_Filter);
pListView->GetShellListCtrl().Refresh();
}
}
}
void CMainFrame::OnViewTreedialog()
{
// TODO: Add your command handler code here
CShellTreeDlg dlg;
dlg.DoModal();
}
@@ -1,70 +0,0 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__476445A6_F5F7_4383_B534_EBAB2D5728B1__INCLUDED_)
#define AFX_MAINFRM_H__476445A6_F5F7_4383_B534_EBAB2D5728B1__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CSeaShellView;
#include "UIExplorerFrameWnd.h"
class CMainFrame : public CUIExplorerFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
protected:
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void CreateCoolBar();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
CSeaShellView* GetRightPane();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg LRESULT OnSettingChange(WPARAM wParam,LPARAM lParam);
afx_msg void OnViewExplorerdialog();
afx_msg void OnViewFilefilter();
afx_msg void OnViewTreedialog();
//}}AFX_MSG
afx_msg void OnUpdateViewStyles(CCmdUI* pCmdUI);
afx_msg void OnViewStyle(UINT nCommandID);
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__476445A6_F5F7_4383_B534_EBAB2D5728B1__INCLUDED_)
@@ -1,67 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by SeaShell.rc
//
#define IDD_ABOUTBOX 100
#define ID_VIEW_ARRANGE 127
#define IDR_MAINFRAME 128
#define IDR_SEASHETYPE 129
#define IDD_SHELL_TREE 130
#define IDD_MFC_EXPLORER 132
#define IDD_FILTER 133
#define IDR_POPUPMENU_LISTCTRL 204
#define IDR_POPUPMENU_HEADERCTRL 205
#define IDR_POPUPMENU_DRAGDROP 208
#define IDR_POPUPMENU_TREE_FOLDER 209
#define IDB_COLDTOOLBAR 210
#define IDB_HOTTOOLBAR 211
#define IDC_SHELL_TREE 1000
#define IDC_ST_PATH 1001
#define IDC_ST_HELP 1002
#define IDC_LIST_TEST 1003
#define IDC_BUTT_PROGRESS 1004
#define IDC_BUTT_NORMAL 1005
#define IDC_BUTT_DOWNLOAD 1006
#define IDC_TREE_SHELL 1012
#define IDC_LIST_SHELL 1013
#define IDC_MFC_BUTT_REPORT 1014
#define IDC_MFC_BUTT_SMALL_ICONS 1015
#define IDC_MFC_BUTT_LARGE_ICONS 1016
#define IDC_MFC_BUTT_DETAILS 1017
#define IDC_COMBO_SHELL 1018
#define IDC_EDIT_FILTER 1020
#define IDC_EDIT_FILE_TYPE 1021
#define ID_VIEW_EXPLORERDIALOG 32771
#define ID_VIEW_FILEFILTER 32772
#define ID_VIEW_TREEDIALOG 32773
#define ID_POPUP_DD_MOVE 42768
#define ID_POPUP_DD_COPY 42769
#define ID_POPUP_DD_CANCEL 42770
#define ID_UI_VIEW_LARGE_ICONS 42771
#define ID_UI_VIEW_SMALL_ICONS 42772
#define ID_UI_VIEW_DETAILS 42773
#define ID_UI_VIEW_LIST 42774
#define ID_UI_VIEW_GRIDLINES 42775
#define ID_UI_VIEW_COLUMN_ORDERING 42778
#define ID_UI_VIEW_FULL_ROW_SELECTION 42779
#define ID_UI_VIEW_TRACK_SELECT 42780
#define ID_UI_VIEW_COLUMN_SIZING 42781
#define ID_HEADER_REMOVE_COL 42782
#define ID_HEADER_EDIT_TEXT 42783
#define ID_HEADER_RESET 42784
#define ID_UI_VIEW_EDIT_COLUMN 42786
#define ID_POPUP_TF_NEW_FOLDER 42801
#define ID_POPUP_TF_DELETE_FOLDER 42802
#define ID_POPUP_TF_REFRESH 42803
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32774
#define _APS_NEXT_CONTROL_VALUE 1007
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
@@ -1,317 +0,0 @@
// SeaShell.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "SeaShell.h"
#include "MainFrm.h"
#include "SeaShellDoc.h"
#include "LeftView.h"
#include "UICtrl.h"
#include "TextProgressCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define WM_APP_UPDATE_PROGRESS WM_APP+1
#define WM_APP_FINISH_PROGRESS WM_APP+2
/////////////////////////////////////////////////////////////////////////////
// CSeaShellApp
BEGIN_MESSAGE_MAP(CSeaShellApp, CUIApp)
//{{AFX_MSG_MAP(CSeaShellApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CUIApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CUIApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CUIApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSeaShellApp construction
CSeaShellApp::CSeaShellApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CSeaShellApp object
CSeaShellApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CSeaShellApp initialization
BOOL CSeaShellApp::InitInstance()
{
AfxEnableControlContainer();
if (!AfxOleInit())
{
AfxMessageBox(_T("COM Failed to initialize"));
return FALSE;
}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CSeaShellDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CLeftView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
typedef struct THREADINFO
{
int nRow;
HWND hWnd;
HANDLE hEvent;
} *LPTHREADINFO;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CUIODListCtrl m_lcTest;
//}}AFX_DATA
enum Cols { COL_FILE_SIZE, COL_STATUS, COL_PROGRESS };
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
CEvent m_Event;
CWinThread *m_pThread;
static UINT ThreadFunc(LPVOID pParam);
// Implementation
protected:
virtual BOOL OnInitDialog();
void PumpMessages();
//{{AFX_MSG(CAboutDlg)
afx_msg void OnButtProgress();
afx_msg void OnButtNormal();
afx_msg void OnButtDownload();
afx_msg LRESULT OnAppUpdateProgress(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppFinishProgress(WPARAM wParam, LPARAM lParam );
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
m_pThread = NULL;
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Control(pDX, IDC_LIST_TEST, m_lcTest);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_BN_CLICKED(IDC_BUTT_PROGRESS, OnButtProgress)
ON_BN_CLICKED(IDC_BUTT_NORMAL, OnButtNormal)
ON_BN_CLICKED(IDC_BUTT_DOWNLOAD, OnButtDownload)
ON_MESSAGE(WM_APP_UPDATE_PROGRESS,OnAppUpdateProgress)
ON_MESSAGE(WM_APP_FINISH_PROGRESS,OnAppFinishProgress)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CSeaShellApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CSeaShellApp message handlers
void CAboutDlg::OnButtProgress()
{
// TODO: Add your control notification handler code here
int nRow = m_lcTest.AddTextItem();
m_lcTest.AddString(nRow,COL_FILE_SIZE,nRow+1);
m_lcTest.AddString(nRow,COL_STATUS,_T("Downloading"));
CTextProgressCtrl *pPB = m_lcTest.AddProgressBar(nRow,COL_PROGRESS,0,100);
if (pPB)
{
pPB->SetShowText(true);
pPB->SetPos(0);
pPB->SetRange(0,100);
for (int i = 0; i < (nRow+1); i++)
{
pPB->StepIt();
}
}
}
void CAboutDlg::PumpMessages()
{
// Must call Create() before using the dialog
ASSERT(m_hWnd!=NULL);
MSG msg;
// Handle dialog messages
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(!IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_lcTest.InitListCtrl(_T("File Size|Status|Progress"));
m_lcTest.SetColumnFormat(COL_FILE_SIZE,LVCFMT_CENTER);
m_lcTest.SetColumnFormat(COL_STATUS,LVCFMT_CENTER);
m_lcTest.AddIcon(IDR_MAINFRAME);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::OnButtNormal()
{
// TODO: Add your control notification handler code here
int nRow = m_lcTest.AddTextItem();
m_lcTest.AddString(nRow,COL_FILE_SIZE,nRow+1);
m_lcTest.SetTextColor(nRow,COL_FILE_SIZE,RGB(0,0,128));
m_lcTest.AddString(nRow,COL_STATUS,_T("Normal"));
m_lcTest.SetTextColor(nRow,COL_STATUS,RGB(70,38,10));
m_lcTest.AddString(nRow,COL_PROGRESS,_T("Progress"));
if (nRow % 2)
{
m_lcTest.SetBkColor(nRow,-1,RGB(20,100,20));
m_lcTest.SetRowBold(nRow,-1);
}
}
void CAboutDlg::OnButtDownload()
{
// TODO: Add your control notification handler code here
if (m_lcTest.GetCurSel() == -1)
return;
CTextProgressCtrl *pCtrl = m_lcTest.AddProgressBar(m_lcTest.GetCurSel(),COL_PROGRESS,0,120000);
pCtrl->SetBgColor(CLR_DEFAULT,RGB(255,255,255));
pCtrl->SetBarColor(CLR_DEFAULT,::GetSysColor(COLOR_MENU));
LPTHREADINFO pth = new THREADINFO;
pth->nRow = m_lcTest.GetCurSel();
pth->hWnd = this->GetSafeHwnd();
pth->hEvent = m_Event.m_hObject;
m_pThread = AfxBeginThread(CAboutDlg::ThreadFunc,(LPVOID)pth);
m_pThread->m_bAutoDelete = FALSE;
}
UINT CAboutDlg::ThreadFunc(LPVOID pParam)
{
LPTHREADINFO pth = (LPTHREADINFO)pParam;
ASSERT(pth);
DWORD dw;
for(int i=1;i < 120;i++)
{
dw = WaitForMultipleObjects(1,&pth->hEvent,TRUE,1000);
if ((dw - WAIT_OBJECT_0) == 0)
break;
::PostMessage(pth->hWnd,WM_APP_UPDATE_PROGRESS,pth->nRow,i*1000);
}
if (::IsWindow(pth->hWnd))
::PostMessage(pth->hWnd,WM_APP_FINISH_PROGRESS,pth->nRow,0);
delete pth;
TRACE0("Download thread is exiting\n");
return 1;
}
LRESULT CAboutDlg::OnAppUpdateProgress(WPARAM wParam, LPARAM lParam)
{
m_lcTest.AddString(wParam,COL_FILE_SIZE,lParam);
m_lcTest.UpdateProgressBar(wParam,COL_PROGRESS,lParam);
return 1;
}
LRESULT CAboutDlg::OnAppFinishProgress(WPARAM wParam, LPARAM lParam)
{
delete m_pThread;
m_pThread = NULL;
m_lcTest.DeleteProgressBar(wParam,COL_PROGRESS);
return 1;
}
void CAboutDlg::OnDestroy()
{
if (m_pThread)
{
m_Event.SetEvent();
::WaitForSingleObject(m_pThread->m_hThread, INFINITE);
delete m_pThread;
m_pThread = NULL;
}
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
@@ -1,559 +0,0 @@
# Microsoft Developer Studio Project File - Name="SeaShell" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=SeaShell - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "SeaShell.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "SeaShell.mak" CFG="SeaShell - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "SeaShell - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "SeaShell - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "SeaShell - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "SeaShellExt\Include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "SeaShell - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "SeaShellExt\Include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "SeaShell - Win32 Release"
# Name "SeaShell - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\FilterDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\LeftView.cpp
# End Source File
# Begin Source File
SOURCE=.\MainFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\MFCExplorerDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShell.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShell.rc
# End Source File
# Begin Source File
SOURCE=.\SeaShellDoc.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellView.cpp
# End Source File
# Begin Source File
SOURCE=.\ShellTreeDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\SeaShellExt\Include\cbformats.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\Dirwalk.h
# End Source File
# Begin Source File
SOURCE=.\FilterDlg.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\HtmlCtrl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\IEFolderTreeCtrl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\IEShellComboBox.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\IEShellDragDrop.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\IEShellListCtrl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\IEShellListView.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\IEShellTreeCtrl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\IEShellTreeView.h
# End Source File
# Begin Source File
SOURCE=.\LeftView.h
# End Source File
# Begin Source File
SOURCE=.\MainFrm.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\PIDL.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\Refresh.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\SeaShell.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellDoc.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellView.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\ShellContextMenu.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\ShellDetails.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\ShellPidl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\ShellSettings.h
# End Source File
# Begin Source File
SOURCE=.\ShellTreeDlg.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\TextParse.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIApp.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UICONT.H
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UICoolBar.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UICoolMenu.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\Uictrl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIDATA.H
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\uidragdropctrl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIDragDropTree.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\uidragimage.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\uidroptarget.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIExplorerFrameWnd.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIFixTB.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIFlatBar.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIFolderRefresh.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIFrameWnd.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIHtmlView.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIImageDropTarget.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIListView.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIMenuBar.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIMessages.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UIStatusBar.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UISubclass.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UITabSplitterWnd.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UITabView.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UITreeCtrl.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\UITreeView.h
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Include\WindowPlacement.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\coldtool.bmp
# End Source File
# Begin Source File
SOURCE=.\res\hottoolb.bmp
# End Source File
# Begin Source File
SOURCE=.\res\SeaShell.ico
# End Source File
# Begin Source File
SOURCE=.\res\SeaShell.rc2
# End Source File
# Begin Source File
SOURCE=.\res\SeaShellDoc.ico
# End Source File
# Begin Source File
SOURCE=.\res\Toolbar.bmp
# End Source File
# End Group
# Begin Group "SeaShellExt"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\SeaShellExt\cbformats.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\HtmlCtrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\IEFolderTreeCtrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\IEShellComboBox.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\IEShellDragDrop.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\IEShellListCtrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\IEShellListView.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\IEShellTreeCtrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\IEShellTreeView.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\InPlaceEdit.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\LocaleInfo.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\PIDL.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\ShellContextMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\ShellDetails.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\ShellPidl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\ShellSettings.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\TextParse.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\TextProgressCtrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIApp.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UICONT.CPP
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UICoolBar.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UICoolMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\Uictrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIDATA.CPP
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\uidragdropctrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIDragDropTree.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\uidragimage.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\uidroptarget.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIExplorerFrameWnd.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIFixTB.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIFlatBar.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIFrameWnd.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIHtmlView.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIImageDropTarget.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIListView.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIMenuBar.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIModulVer.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UIStatusBar.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UISubclass.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UITabSplitterWnd.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UITreeCtrl.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\UITreeView.cpp
# End Source File
# Begin Source File
SOURCE=.\SeaShellExt\WindowPlacement.cpp
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project
@@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "SeaShell"=".\SeaShell.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
@@ -1,50 +0,0 @@
// SeaShell.h : main header file for the SEASHELL application
//
#if !defined(AFX_SEASHELL_H__6922416D_59C7_4311_9767_0AF1B6CD7C95__INCLUDED_)
#define AFX_SEASHELL_H__6922416D_59C7_4311_9767_0AF1B6CD7C95__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CSeaShellApp:
// See SeaShell.cpp for the implementation of this class
//
#include "UIApp.h"
class CSeaShellApp : public CUIApp
{
public:
CSeaShellApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSeaShellApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CSeaShellApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
extern CSeaShellApp theApp;
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SEASHELL_H__6922416D_59C7_4311_9767_0AF1B6CD7C95__INCLUDED_)
@@ -1,553 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\SeaShell.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#include ""afxprint.rc"" // printing/print preview resources\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\SeaShell.ico"
IDR_SEASHETYPE ICON DISCARDABLE "res\\SeaShellDoc.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
IDB_COLDTOOLBAR BITMAP FIXED IMPURE "res\\coldtool.bmp"
IDB_HOTTOOLBAR BITMAP FIXED IMPURE "res\\hottoolb.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//
IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
BEGIN
BUTTON ID_FILE_NEW
BUTTON ID_FILE_OPEN
BUTTON ID_FILE_SAVE
SEPARATOR
BUTTON ID_EDIT_CUT
BUTTON ID_EDIT_COPY
BUTTON ID_EDIT_PASTE
SEPARATOR
BUTTON ID_FILE_PRINT
SEPARATOR
BUTTON ID_VIEW_LARGEICON
BUTTON ID_VIEW_SMALLICON
BUTTON ID_VIEW_LIST
BUTTON ID_VIEW_DETAILS
SEPARATOR
BUTTON ID_APP_ABOUT
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
MENUITEM "Save &As...", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT
MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW
MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP
MENUITEM SEPARATOR
MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
MENUITEM SEPARATOR
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
MENUITEM SEPARATOR
MENUITEM "&Explorer Dialog", ID_VIEW_EXPLORERDIALOG
MENUITEM "&Tree Dialog", ID_VIEW_TREEDIALOG
MENUITEM "&File Filter", ID_VIEW_FILEFILTER
END
POPUP "&Help"
BEGIN
MENUITEM "&About SeaShell...", ID_APP_ABOUT
END
END
IDR_POPUPMENU_LISTCTRL MENU DISCARDABLE
BEGIN
POPUP ""
BEGIN
POPUP "&View"
BEGIN
MENUITEM "&List", ID_UI_VIEW_LIST
MENUITEM "&Details", ID_UI_VIEW_DETAILS
MENUITEM "&Small Icons", ID_UI_VIEW_SMALL_ICONS
MENUITEM "&Large Icons", ID_UI_VIEW_LARGE_ICONS
END
MENUITEM SEPARATOR
MENUITEM "&Grid Lines", ID_UI_VIEW_GRIDLINES
MENUITEM "&Hot Tracking", ID_UI_VIEW_TRACK_SELECT
MENUITEM SEPARATOR
MENUITEM "&Full Row Selection", ID_UI_VIEW_FULL_ROW_SELECTION
MENUITEM "&Column Sizing", ID_UI_VIEW_COLUMN_SIZING
MENUITEM "Column &Ordering", ID_UI_VIEW_COLUMN_ORDERING
MENUITEM SEPARATOR
MENUITEM "&Rename", ID_UI_VIEW_EDIT_COLUMN
END
END
IDR_POPUPMENU_DRAGDROP MENU DISCARDABLE
BEGIN
POPUP ""
BEGIN
MENUITEM "&Move Here", ID_POPUP_DD_MOVE
MENUITEM "&Copy Here", ID_POPUP_DD_COPY
MENUITEM SEPARATOR
MENUITEM "Cancel", ID_POPUP_DD_CANCEL
END
END
IDR_POPUPMENU_HEADERCTRL MENU DISCARDABLE
BEGIN
POPUP ""
BEGIN
MENUITEM "&Delete", ID_HEADER_REMOVE_COL
MENUITEM SEPARATOR
MENUITEM "&Rename", ID_HEADER_EDIT_TEXT
MENUITEM "Reset &Header", ID_HEADER_RESET
END
END
IDR_POPUPMENU_TREE_FOLDER MENU DISCARDABLE
BEGIN
POPUP ""
BEGIN
MENUITEM "&New Folder", ID_POPUP_TF_NEW_FOLDER
MENUITEM "&Delete Folder", ID_POPUP_TF_DELETE_FOLDER
MENUITEM SEPARATOR
MENUITEM "&Refresh", ID_POPUP_TF_REFRESH
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"N", ID_FILE_NEW, VIRTKEY, CONTROL
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
"P", ID_FILE_PRINT, VIRTKEY, CONTROL
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
VK_F6, ID_NEXT_PANE, VIRTKEY
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 390, 266
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About SeaShell"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,21,20
LTEXT "SeaShell Version 1.0",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) 2000",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,333,7,50,14,WS_GROUP
CONTROL "List1",IDC_LIST_TEST,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS |
WS_BORDER | WS_TABSTOP,7,67,376,170
PUSHBUTTON "&Progress",IDC_BUTT_PROGRESS,7,245,50,14
PUSHBUTTON "N&ormal",IDC_BUTT_NORMAL,60,245,50,14
PUSHBUTTON "&Download",IDC_BUTT_DOWNLOAD,114,245,50,14
END
IDD_MFC_EXPLORER DIALOG DISCARDABLE 0, 0, 342, 223
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "MFC Explorer"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,7,202,50,14
PUSHBUTTON "Cancel",IDCANCEL,61,202,50,14
CONTROL "Tree1",IDC_TREE_SHELL,"SysTreeView32",WS_BORDER |
WS_TABSTOP,7,7,127,189
CONTROL "List1",IDC_LIST_SHELL,"SysListView32",LVS_REPORT |
WS_BORDER | WS_TABSTOP,139,7,196,167
CONTROL "",IDC_COMBO_SHELL,"ComboBoxEx32",CBS_DROPDOWN |
CBS_SORT | WS_VSCROLL | WS_TABSTOP,138,202,197,132
PUSHBUTTON "R",IDC_MFC_BUTT_REPORT,141,180,21,14
PUSHBUTTON "S",IDC_MFC_BUTT_SMALL_ICONS,168,180,20,14
PUSHBUTTON "L",IDC_MFC_BUTT_LARGE_ICONS,193,180,20,14
PUSHBUTTON "D",IDC_MFC_BUTT_DETAILS,219,181,21,14
END
IDD_FILTER DIALOG DISCARDABLE 0, 0, 186, 85
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Enter File Filter"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_EDIT_FILTER,7,18,172,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_FILE_TYPE,7,46,172,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,7,64,50,14
PUSHBUTTON "Cancel",IDCANCEL,64,64,50,14
LTEXT "Filter:",IDC_STATIC,7,7,80,8
LTEXT "File Type:",IDC_STATIC,7,36,34,8
END
IDD_SHELL_TREE DIALOG DISCARDABLE 0, 0, 306, 218
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Shell Tree"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Close",IDOK,117,197,50,14
CONTROL "Tree1",IDC_SHELL_TREE,"SysTreeView32",WS_BORDER |
WS_TABSTOP,7,7,292,139
LTEXT "Static",IDC_ST_HELP,49,171,247,21
LTEXT "Static",IDC_ST_PATH,48,155,246,8
LTEXT "Path:",IDC_STATIC,7,153,29,8
LTEXT "Help Text:",IDC_STATIC,7,172,34,8
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SeaShell MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "SeaShell\0"
VALUE "LegalCopyright", "Copyright (C) 2000\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "SeaShell.EXE\0"
VALUE "ProductName", "SeaShell Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 383
TOPMARGIN, 7
BOTTOMMARGIN, 259
END
IDD_MFC_EXPLORER, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 335
TOPMARGIN, 7
BOTTOMMARGIN, 216
END
IDD_FILTER, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 78
END
IDD_SHELL_TREE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 299
TOPMARGIN, 7
BOTTOMMARGIN, 211
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "SeaShell\n\nSeaShe\n\n\nSeaShell.Document\nSeaShe Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "SeaShell"
AFX_IDS_IDLEMESSAGE "Ready"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "CAP"
ID_INDICATOR_NUM "NUM"
ID_INDICATOR_SCRL "SCRL"
ID_INDICATOR_OVR "OVR"
ID_INDICATOR_REC "REC"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Create a new document\nNew"
ID_FILE_OPEN "Open an existing document\nOpen"
ID_FILE_CLOSE "Close the active document\nClose"
ID_FILE_SAVE "Save the active document\nSave"
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup"
ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup"
ID_FILE_PRINT "Print the active document\nPrint"
ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_MRU_FILE1 "Open this document"
ID_FILE_MRU_FILE2 "Open this document"
ID_FILE_MRU_FILE3 "Open this document"
ID_FILE_MRU_FILE4 "Open this document"
ID_FILE_MRU_FILE5 "Open this document"
ID_FILE_MRU_FILE6 "Open this document"
ID_FILE_MRU_FILE7 "Open this document"
ID_FILE_MRU_FILE8 "Open this document"
ID_FILE_MRU_FILE9 "Open this document"
ID_FILE_MRU_FILE10 "Open this document"
ID_FILE_MRU_FILE11 "Open this document"
ID_FILE_MRU_FILE12 "Open this document"
ID_FILE_MRU_FILE13 "Open this document"
ID_FILE_MRU_FILE14 "Open this document"
ID_FILE_MRU_FILE15 "Open this document"
ID_FILE_MRU_FILE16 "Open this document"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_CLEAR "Erase the selection\nErase"
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
ID_EDIT_FIND "Find the specified text\nFind"
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
ID_EDIT_UNDO "Undo the last action\nUndo"
ID_EDIT_REDO "Redo the previously undone action\nRedo"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
ID_VIEW_AUTOARRANGE "Arrange icons on a grid."
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_SMALLICON "Display items by using small icons.\nSmall Icons"
ID_VIEW_LARGEICON "Display items by using large icons.\nLarge Icons"
ID_VIEW_LIST "Displays items in a list.\nList"
ID_VIEW_DETAILS "Displays detailed information about each item in the window.\nDetails"
ID_VIEW_LINEUP "Arranges icons in a grid."
ID_VIEW_BYNAME "Sorts the icons alphabetically."
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_EXPLORERDIALOG "Show a explorer dialog with tree, list and combo"
ID_VIEW_FILEFILTER "Filter the file selection with wild cards"
ID_VIEW_TREEDIALOG "Show a dialog with just the shell tree control"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\SeaShell.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#include "afxprint.rc" // printing/print preview resources
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
@@ -1,84 +0,0 @@
// SeaShellDoc.cpp : implementation of the CSeaShellDoc class
//
#include "stdafx.h"
#include "SeaShell.h"
#include "SeaShellDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSeaShellDoc
IMPLEMENT_DYNCREATE(CSeaShellDoc, CDocument)
BEGIN_MESSAGE_MAP(CSeaShellDoc, CDocument)
//{{AFX_MSG_MAP(CSeaShellDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSeaShellDoc construction/destruction
CSeaShellDoc::CSeaShellDoc()
{
// TODO: add one-time construction code here
}
CSeaShellDoc::~CSeaShellDoc()
{
}
BOOL CSeaShellDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CSeaShellDoc serialization
void CSeaShellDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CSeaShellDoc diagnostics
#ifdef _DEBUG
void CSeaShellDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CSeaShellDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSeaShellDoc commands
@@ -1,57 +0,0 @@
// SeaShellDoc.h : interface of the CSeaShellDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_SEASHELLDOC_H__8B4AAB8C_DC87_4F7D_9171_BCE406941600__INCLUDED_)
#define AFX_SEASHELLDOC_H__8B4AAB8C_DC87_4F7D_9171_BCE406941600__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CSeaShellDoc : public CDocument
{
protected: // create from serialization only
CSeaShellDoc();
DECLARE_DYNCREATE(CSeaShellDoc)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSeaShellDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSeaShellDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CSeaShellDoc)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SEASHELLDOC_H__8B4AAB8C_DC87_4F7D_9171_BCE406941600__INCLUDED_)
@@ -1,10 +0,0 @@
*.coff
*.exe
*.d
*.o
*.sym
*.map
*.aps
*.res
*.opt
*.ncb
@@ -1,120 +0,0 @@
////////////////////////////////////////////////////////////////
// Microsoft Systems Journal -- December 1999
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
//
#include "StdAfx.h"
#include "HtmlCtrl.h"
#include "UIMessages.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CHtmlCtrl, CUIHtmlView)
BEGIN_MESSAGE_MAP(CHtmlCtrl, CUIHtmlView)
ON_WM_DESTROY()
ON_WM_MOUSEACTIVATE()
ON_MESSAGE(WM_APP_CB_IE_SEL_CHANGE,OnAppCbIeSelChange)
END_MESSAGE_MAP()
BOOL CHtmlCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS,
NULL,
NULL,
NULL);
ASSERT(cs.lpszClass);
BOOL bRet = CHtmlView::PreCreateWindow(cs);
return bRet;
}
//////////////////
// Create control in same position as an existing static control with
// the same ID (could be any kind of control, really)
//
BOOL CHtmlCtrl::CreateFromStatic(UINT nID, CWnd* pParent)
{
CStatic wndStatic;
if (!wndStatic.SubclassDlgItem(nID, pParent))
return FALSE;
// Get static control rect, convert to parent's client coords.
CRect rc;
wndStatic.GetWindowRect(&rc);
pParent->ScreenToClient(&rc);
wndStatic.DestroyWindow();
// create HTML control (CHtmlView)
return Create(NULL, // class name
NULL, // title
(WS_CHILD | WS_VISIBLE ), // style
rc, // rectangle
pParent, // parent
nID, // control ID
NULL); // frame/doc context not used
}
////////////////
// Override to avoid CView stuff that assumes a frame.
//
void CHtmlCtrl::OnDestroy()
{
// This is probably unecessary since ~CHtmlView does it, but
// safer to mimic CHtmlView::OnDestroy.
if (m_pBrowserApp) {
m_pBrowserApp->Release();
m_pBrowserApp = NULL;
}
CWnd::OnDestroy(); // bypass CView doc/frame stuff
}
////////////////
// Override to avoid CView stuff that assumes a frame.
//
int CHtmlCtrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg)
{
// bypass CView doc/frame stuff
return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, msg);
}
//////////////////
// Override navigation handler to pass to "app:" links to virtual handler.
// Cancels the navigation in the browser, since app: is a pseudo-protocol.
//
void CHtmlCtrl::OnBeforeNavigate2( LPCTSTR lpszURL,
DWORD nFlags,
LPCTSTR lpszTargetFrameName,
CByteArray& baPostedData,
LPCTSTR lpszHeaders,
BOOL* pbCancel )
{
CUIHtmlView::OnBeforeNavigate2(lpszURL,nFlags,lpszTargetFrameName,baPostedData,lpszHeaders,pbCancel);
LPCTSTR APP_PROTOCOL = _T("app:");
int len = _tcslen(APP_PROTOCOL);
if (_tcsnicmp(lpszURL, APP_PROTOCOL, len)==0) {
OnAppCmd(lpszURL + len);
*pbCancel = TRUE;
}
}
//////////////////
// Called when the browser attempts to navigate to "app:foo"
// with "foo" as lpszWhere. Override to handle app commands.
//
void CHtmlCtrl::OnAppCmd(LPCTSTR lpszWhere)
{
// default: do nothing
}
LRESULT CHtmlCtrl::OnAppCbIeSelChange(WPARAM wParam, LPARAM lParam)
{
if (wParam)
Navigate((LPCTSTR)wParam);
return 1;
}
@@ -1,548 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "IEFolderTreeCtrl.h"
#include "UIMessages.h"
#include <vector>
#include <map>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
typedef map<CShellPidlCompare,HTREEITEM> mapPidlToHTREEITEM;
typedef vector<LPITEMIDLIST> vecPidl;
int CALLBACK CIEFolderTreeCtrl::CompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
LPTVITEMDATA lptvid1 = (LPTVITEMDATA)((CUIListCtrlData*)lParam1)->GetExtData();
LPTVITEMDATA lptvid2 = (LPTVITEMDATA)((CUIListCtrlData*)lParam2)->GetExtData();
LPSHELLFOLDER psfParent = (LPSHELLFOLDER)lParamSort;
HRESULT hr = psfParent->CompareIDs (0, lptvid1->lpi, lptvid2->lpi);
if (FAILED (hr))
return 0;
return (short)hr;
}
/////////////////////////////////////////////////////////////////////////////
// CIEFolderTreeCtrl
CIEFolderTreeCtrl::CIEFolderTreeCtrl()
{
SHGetMalloc(&m_pMalloc);
m_hImageList = NULL;
}
CIEFolderTreeCtrl::~CIEFolderTreeCtrl()
{
// Free our memory allocator
if (m_pMalloc)
m_pMalloc->Release();
}
void CIEFolderTreeCtrl::Refresh()
{
HTREEITEM hItem = GetRootItem();
if (hItem == NULL)
return;
CWaitCursor w;
SetRedraw(FALSE);
RefreshNode(hItem);
SetRedraw(TRUE);
}
void CIEFolderTreeCtrl::OnDeleteItemData(DWORD dwData)
{
LPTVITEMDATA pItemData=(LPTVITEMDATA)dwData;
if (pItemData == NULL)
return;
if (pItemData->lpsfParent)
pItemData->lpsfParent->Release();
if (pItemData->lpi)
m_pMalloc->Free(pItemData->lpi);
if (pItemData->lpifq)
m_pMalloc->Free(pItemData->lpifq);
m_pMalloc->Free(pItemData);
}
BOOL CIEFolderTreeCtrl::LoadURL(HTREEITEM hItem)
{
if (GetRootItem() == hItem)
return FALSE;
if (ItemHasChildren(hItem))
return FALSE;
CString strText(GetItemText(hItem));
AfxMessageBox(strText);
return TRUE;
}
bool CIEFolderTreeCtrl::LoadItems(LPCTSTR pszPath,DWORD dwFolderType)
{
ASSERT(m_pMalloc);
if (m_hImageList == NULL)
Init();
bool bRet = false;
CWaitCursor w;
DeleteAllItems();
//DeleteItemData();
LPITEMIDLIST pidl=NULL;
LPSHELLFOLDER psfDesktop=NULL;
LPSHELLFOLDER pSubFolder=NULL;
HRESULT hr = SHGetDesktopFolder(&psfDesktop);
if (dwFolderType)
{
hr = SHGetSpecialFolderLocation(NULL, dwFolderType, &pidl);
#ifdef _DEBUG
CString sPath;
GetShellPidl().SHPidlToPathEx(pidl,sPath);
TRACE1("Populating special folder %s\n",sPath);
#endif
hr = psfDesktop->BindToObject(pidl, 0, IID_IShellFolder,(LPVOID*)&pSubFolder);
}
else
{
if (pszPath && *pszPath != '\0')
{
hr = m_ShellPidl.SHPathToPidlEx(pszPath,&pidl,psfDesktop);
if (SUCCEEDED(hr))
{
hr = psfDesktop->BindToObject(pidl, 0, IID_IShellFolder,(LPVOID*)&pSubFolder);
if (SUCCEEDED(hr))
m_sRootPath = pszPath;
}
}
else
{
hr = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl);
}
}
LPCTSTR pszTitle=NULL;
SHFILEINFO fileInfo;
ZeroMemory(&fileInfo,sizeof(fileInfo));
int nImage=0, nSelImage=0;
if (pidl)
{
SHGetFileInfo((LPCTSTR)pidl, NULL, &fileInfo, sizeof(fileInfo), SHGFI_PIDL|SHGFI_ATTRIBUTES|SHGFI_DISPLAYNAME);
pszTitle = fileInfo.szDisplayName;
m_ShellPidl.GetNormalAndSelectedIcons(pidl, nImage, nSelImage);
if (nImage < 0)
nImage = 0;
if (nSelImage < 0)
nSelImage = 0;
}
if (SUCCEEDED(hr))
{
LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
if (lptvid == NULL)
return bRet;
ZeroMemory(lptvid,sizeof(TVITEMDATA));
// Now make a copy of the ITEMIDLIST.
lptvid->lpi = m_ShellPidl.CopyLastItemID(pidl);
lptvid->lpifq = m_ShellPidl.CopyItemIDList(pidl);
lptvid->lpsfParent = NULL;
if (lptvid->lpsfParent)
lptvid->lpsfParent->AddRef();
HTREEITEM hRootItem = AddAnItem((HTREEITEM)NULL,pszTitle,(LPARAM)lptvid,(HTREEITEM)TVI_ROOT,nImage,nSelImage);
AddItems(hRootItem,pSubFolder ? pSubFolder : psfDesktop);
Expand(hRootItem,TVE_EXPAND);
PostMessage(WM_APP_POPULATE_TREE);
bRet = true;
}
if (pidl)
m_pMalloc->Free(pidl);
if (pSubFolder)
pSubFolder->Release();
if (psfDesktop)
psfDesktop->Release();
return bRet;
}
bool CIEFolderTreeCtrl::AddItems(HTREEITEM hItem,IShellFolder* pFolder)
{
IEnumIDList* pItems = NULL;
LPITEMIDLIST pidlNext = NULL;
DWORD dwFlags = SHCONTF_FOLDERS;
if (GetShellSettings().ShowAllObjects() && !GetShellSettings().ShowSysFiles())
dwFlags |= SHCONTF_INCLUDEHIDDEN;
// Enumerate all object in the given folder
HRESULT hr = pFolder->EnumObjects(NULL, dwFlags, &pItems);
if (hr != NOERROR)
return false;
while (NOERROR == hr)
{
hr = pItems->Next(1, &pidlNext, NULL);
if (hr == S_FALSE || pidlNext == NULL)
break;
if (AddFolder(hItem,pidlNext,pFolder) == NULL)
m_pMalloc->Free(pidlNext);
pidlNext = NULL;
}
if (pidlNext)
m_pMalloc->Free(pidlNext);
if (pItems)
pItems->Release();
Sort(hItem,pFolder);
return true;
}
void CIEFolderTreeCtrl::Sort(HTREEITEM hParent,LPSHELLFOLDER pFolder)
{
// Sort the the node based on pidls
TVSORTCB cbSort;
cbSort.hParent = hParent;
cbSort.lpfnCompare = CompareProc;
cbSort.lParam = (LPARAM)pFolder;
SortChildrenCB(&cbSort);
}
HTREEITEM CIEFolderTreeCtrl::AddFolder(HTREEITEM hItem,LPCTSTR pszPath)
{
LPITEMIDLIST pidlfq=NULL;
HRESULT hr = GetShellPidl().SHPathToPidlEx(pszPath,&pidlfq,NULL);
if (FAILED(hr))
return NULL;
LPTVITEMDATA lptvid = (LPTVITEMDATA)GetItemData(hItem);
ASSERT(lptvid);
LPITEMIDLIST pidl = GetShellPidl().CopyLastItemID(pidlfq);
HTREEITEM hFolderItem = AddFolder(hItem,pidl,lptvid->lpsfParent);
if (pidlfq)
m_pMalloc->Free(pidlfq);
return hFolderItem;
}
HTREEITEM CIEFolderTreeCtrl::AddFolder(HTREEITEM hItem,LPITEMIDLIST pidl,LPSHELLFOLDER pFolder)
{
ASSERT(m_pMalloc);
LPTSTR pszFilePath = NULL;
STRRET StrRetFilePath;
SHFILEINFO FileInfo;
ZeroMemory(&FileInfo,sizeof(FileInfo));
FileInfo.dwAttributes=SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
HRESULT hr = pFolder->GetAttributesOf(1,(LPCITEMIDLIST*)&pidl,&FileInfo.dwAttributes);
if (FAILED(hr))
return NULL;
// Create a submenu if this item is a folder
if (!(FileInfo.dwAttributes & (SFGAO_HASSUBFOLDER | SFGAO_FOLDER)))
return NULL;
pFolder->GetDisplayNameOf(pidl,SHGDN_INFOLDER,&StrRetFilePath);
GetShellPidl().StrRetToStr(StrRetFilePath, &pszFilePath, pidl);
if (pszFilePath)
{
lstrcpy(FileInfo.szDisplayName,pszFilePath);
m_pMalloc->Free(pszFilePath);
pszFilePath = NULL;
}
// allocate new itemdata
LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
if (lptvid == NULL)
return NULL;
ZeroMemory(lptvid,sizeof(TVITEMDATA));
// get itemdata for current node
LPTVITEMDATA lpptvid = (LPTVITEMDATA)GetItemData(hItem);
ASSERT(lpptvid);
// create new fully qualified pidl
lptvid->lpifq = m_ShellPidl.ConcatPidl(lpptvid->lpifq,pidl);
// save relative pidl (will be freed in the clean up)
lptvid->lpi = pidl;
int nImage=0;
int nSelImage=0;
// get icons for new fq pidl
m_ShellPidl.GetNormalAndSelectedIcons(lptvid->lpifq, nImage, nSelImage);
// save folder for later use(when node is expanded)
lptvid->lpsfParent = pFolder; // pointer to parent folder
// keep hold of it(will be released in clean up)
lptvid->lpsfParent->AddRef();
// add the node to the tree unsorted (will be sorted later)
int nChildren = 0;
if (FileInfo.dwAttributes & SFGAO_HASSUBFOLDER)
{
nChildren=1;
}
HTREEITEM hNewItem = AddAnItem(hItem,FileInfo.szDisplayName,(DWORD)lptvid,(HTREEITEM)TVI_FIRST,nImage,nSelImage,nChildren);
// set overlay images
if (hNewItem)
{
SetAttributes(hNewItem,pFolder,pidl);
}
return hNewItem;
}
void CIEFolderTreeCtrl::SetAttributes(HTREEITEM hItem,LPSHELLFOLDER pFolder,LPITEMIDLIST pidl)
{
DWORD dwAttributes = SFGAO_DISPLAYATTRMASK | SFGAO_REMOVABLE;
HRESULT hr = pFolder->GetAttributesOf(1,(LPCITEMIDLIST*)&pidl,&dwAttributes);
if (FAILED(hr))
return;
if ((dwAttributes & SFGAO_COMPRESSED) && GetShellSettings().ShowCompColor())
SetTextColor(hItem,RGB(0,0,255));
else
SetDefaultTextColor(hItem);
if (dwAttributes & SFGAO_GHOSTED)
SetItemState(hItem,TVIS_CUT,TVIS_CUT);
else
SetItemState(hItem,TVIS_CUT,0);
if (dwAttributes & SFGAO_LINK)
SetItemState(hItem,INDEXTOOVERLAYMASK(2),TVIS_OVERLAYMASK);
else
SetItemState(hItem,0,TVIS_OVERLAYMASK);
if (dwAttributes & SFGAO_SHARE)
SetItemState(hItem,INDEXTOOVERLAYMASK(1),TVIS_OVERLAYMASK);
else
SetItemState(hItem,0,TVIS_OVERLAYMASK);
}
BEGIN_MESSAGE_MAP(CIEFolderTreeCtrl, CUITreeCtrl)
//{{AFX_MSG_MAP(CIEFolderTreeCtrl)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_MESSAGE(WM_SETTINGCHANGE,OnSettingChange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIEFolderTreeCtrl message handlers
int CIEFolderTreeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CUITreeCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
BOOL CIEFolderTreeCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
// No label editing for Explorer items
cs.style |= (TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS);
return CTreeCtrl::PreCreateWindow(cs);
}
void CIEFolderTreeCtrl::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType)
{
// TODO: Add your specialized code here and/or call the base class
CUITreeCtrl::CalcWindowRect(lpClientRect, nAdjustType);
}
LPCITEMIDLIST CIEFolderTreeCtrl::GetPathPidl(HTREEITEM hItem)
{
if (hItem == NULL)
return NULL;
LPLVITEMDATA plvit = (LPLVITEMDATA)GetItemData(hItem);
ASSERT(plvit);
if (plvit == NULL)
return NULL;
return plvit->lpifq;
}
LPSHELLFOLDER CIEFolderTreeCtrl::GetItemFolder(HTREEITEM hItem)
{
LPTVITEMDATA lpidCurr = (LPTVITEMDATA)GetItemData(hItem);
ASSERT(lpidCurr);
if (lpidCurr == NULL)
return NULL;
LPSHELLFOLDER psfCurr=NULL;
#if 1 // bug fix by Gregoire
LPSHELLFOLDER psfDesktop=NULL;
SHGetDesktopFolder(&psfDesktop);
psfDesktop->BindToObject(lpidCurr->lpifq,0,IID_IShellFolder,(LPVOID*)&psfCurr);
#else
if (lpidCurr->lpsfParent)
lpidCurr->lpsfParent->BindToObject(lpidCurr->lpi,0,IID_IShellFolder,(LPVOID*)&psfCurr);
#endif
if (psfCurr == NULL)
{
SHGetDesktopFolder(&psfCurr);
}
return psfCurr;
}
CString CIEFolderTreeCtrl::GetPathName(HTREEITEM hItem)
{
if (hItem == NULL)
hItem = GetSelectedItem();
CString sPath;
if (hItem == NULL)
return sPath;
LPTVITEMDATA lptvid = (LPTVITEMDATA)GetItemData(hItem);
if (lptvid != NULL)
{
SHGetPathFromIDList(lptvid->lpifq,sPath.GetBuffer(MAX_PATH));
sPath.ReleaseBuffer();
}
return sPath;
}
void CIEFolderTreeCtrl::SetButtonState(HTREEITEM hItem)
{
LPSHELLFOLDER psfCurr=GetItemFolder(hItem);
if (psfCurr == NULL)
return;
IEnumIDList* pItems=NULL;
HRESULT hr = psfCurr->EnumObjects(NULL, SHCONTF_FOLDERS, &pItems);
int nChildren=0;
if (SUCCEEDED(hr))
{
pItems->Release();
nChildren=1;
}
if (nChildren == 1 && !ItemHasChildren(hItem))
{
TVITEM tv;
tv.mask = TVIF_CHILDREN;
ZeroMemory(&tv,sizeof(tv));
SetItem(&tv);
}
psfCurr->Release();
}
void CIEFolderTreeCtrl::RefreshNode(HTREEITEM hItem)
{
// If the item is not expanded, update its button state and return.
if (!(GetItemState(hItem, TVIS_EXPANDED) & TVIS_EXPANDED))
{
SetButtonState(hItem);
return;
}
LPSHELLFOLDER psfCurr=GetItemFolder(hItem);
if (psfCurr == NULL)
return;
mapPidlToHTREEITEM mPidlCurr;
vecPidl vPidlNew;
HTREEITEM hSelItem = GetSelectedItem();
HTREEITEM hChild = GetChildItem(hItem);
while (hChild != NULL)
{
HTREEITEM hNextItem = GetNextSiblingItem(hChild);
LPTVITEMDATA lpid = (LPTVITEMDATA)GetItemData(hChild);
mPidlCurr[CShellPidlCompare(psfCurr,lpid->lpi)] = hChild;
hChild = hNextItem;
}
LPITEMIDLIST pidlNext=NULL;
LPITEMIDLIST pidlCopy=NULL;
IEnumIDList* pItems=NULL;
DWORD dwFlags = SHCONTF_FOLDERS;
if (GetShellSettings().ShowAllObjects() && !GetShellSettings().ShowSysFiles())
dwFlags |= SHCONTF_INCLUDEHIDDEN;
HRESULT hr = psfCurr->EnumObjects(NULL, dwFlags, &pItems);
while (NOERROR == hr)
{
hr = pItems->Next(1, &pidlNext, NULL);
if (hr == S_FALSE || pidlNext == NULL)// || pidlNext == pidlCopy)
break;
pidlCopy = pidlNext;
mapPidlToHTREEITEM::iterator it = mPidlCurr.find(CShellPidlCompare(psfCurr,pidlNext));
if (it != mPidlCurr.end())
{
mPidlCurr.erase(it);
}
else
{
SetAttributes((*it).second,psfCurr,pidlNext);
vPidlNew.push_back(GetShellPidl().CopyItemIDList(pidlNext));
}
GetShellPidl().FreePidl(pidlNext);
pidlNext=NULL;
}
if (pItems)
pItems->Release();
for(mapPidlToHTREEITEM::iterator it1=mPidlCurr.begin();it1 != mPidlCurr.end();it1++)
{
HTREEITEM hDelItem = (*it1).second;
#ifdef _DEBUG
CString sPath;
GetShellPidl().SHPidlToPathEx((*it1).first.GetPidl(),sPath,psfCurr);
TRACE1("Deleting item %s in tree refresh\n",sPath);
#endif
DeleteItem(hDelItem);
}
HTREEITEM hSortItem=NULL;
for(vecPidl::iterator it2=vPidlNew.begin();it2 != vPidlNew.end();it2++)
{
AddFolder(hItem,*it2,psfCurr);
hSortItem = hItem;
}
if (hSortItem)
Sort(hSortItem,psfCurr);
// Remove all items from the map
mPidlCurr.erase(mPidlCurr.begin(),mPidlCurr.end());
vPidlNew.erase(vPidlNew.begin(),vPidlNew.end());
psfCurr->Release();
// Now repeat this procedure for hItem's children.
hChild = GetChildItem(hItem);
while (hChild != NULL)
{
RefreshNode(hChild);
hChild = GetNextSiblingItem (hChild);
}
}
void CIEFolderTreeCtrl::Init()
{
CUITreeCtrl::Init();
GetShellSettings().GetSettings();
// TODO: Add your specialized code here and/or call the base class
// Get the handle to the system image list, for our icons
SHFILEINFO sfi;
m_hImageList = (HIMAGELIST)SHGetFileInfo((LPCTSTR)_T("C:\\"),
0,
&sfi,
sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
// Attach ImageList to TreeCtrl
if (m_hImageList)
::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL,(LPARAM)m_hImageList);
}
void CIEFolderTreeCtrl::OnDestroy()
{
SetImageList(NULL,TVSIL_NORMAL);
CUITreeCtrl::OnDestroy();
}
LRESULT CIEFolderTreeCtrl::OnSettingChange(WPARAM wParam,LPARAM lParam)
{
LPCTSTR lpszSection=(LPCTSTR)lParam;
if (lpszSection == NULL)
return 0L;
if (lstrcmpi(lpszSection, _T("ShellState")) == 0)
{
GetShellSettings().GetSettings();
Refresh();
}
return 1L;
}
@@ -1,549 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// IEShellComboBox.cpp : implementation file
//
#include "stdafx.h"
#include "UIMessages.h"
#include "IEShellComboBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const CString strURLKey(_T("Software\\Microsoft\\Internet Explorer\\TypedURLs"));
const CString strIEKey(_T("\\CLSID\\{0002DF01-0000-0000-C000-000000000046}\\LocalServer32"));
/////////////////////////////////////////////////////////////////////////////
// CIEShellComboBox
CIEShellComboBox::CIEShellComboBox()
{
m_pidlMyComputer = NULL;
m_pidlMyDocuments = NULL;
m_pidlInternet = NULL;
m_hImageList = NULL;
m_hTreeWnd = NULL;
m_hIcon = NULL;
SHGetMalloc(&m_pMalloc);
m_bInternet = false;
}
CIEShellComboBox::~CIEShellComboBox()
{
DeleteAllItemData();
CShCMSort *pItem=NULL;
STL_FOR_ITERATOR(vecCMSort,m_vItems)
{
pItem = STL_GET_CURRENT(m_vItems);
DeleteItemData((LPTVITEMDATA)pItem->GetItemData());
delete pItem;
}
if (m_pMalloc)
{
if (m_pidlInternet)
m_pMalloc->Free(m_pidlInternet);
if (m_pidlMyComputer)
m_pMalloc->Free(m_pidlMyComputer);
if (m_pidlMyDocuments)
m_pMalloc->Free(m_pidlMyDocuments);
m_pMalloc->Release();
}
if (m_hIcon)
::DestroyIcon(m_hIcon);
}
void CIEShellComboBox::DeleteAllItemData()
{
for(vecItemData::iterator it=m_vecItemData.begin();it != m_vecItemData.end();it++)
{
DeleteItemData(*it);
}
m_vecItemData.erase(m_vecItemData.begin(),m_vecItemData.end());
}
void CIEShellComboBox::DeleteItemData(LPTVITEMDATA pItemData)
{
if (pItemData == NULL)
return;
if (pItemData->lpsfParent)
pItemData->lpsfParent->Release();
if (pItemData->lpi)
m_pMalloc->Free(pItemData->lpi);
if (pItemData->lpifq)
m_pMalloc->Free(pItemData->lpifq);
m_pMalloc->Free(pItemData);
}
LPITEMIDLIST CIEShellComboBox::GetSelectedPidl()
{
int nCurSel = GetCurSel();
if (nCurSel == -1)
return NULL;
LPTVITEMDATA lptvid = (LPTVITEMDATA)GetItemData(nCurSel);
if (lptvid == NULL)
return NULL;
return GetShellPidl().CopyItemIDList(lptvid->lpifq);
}
BEGIN_MESSAGE_MAP(CIEShellComboBox, CComboBoxEx)
//{{AFX_MSG_MAP(CIEShellComboBox)
ON_MESSAGE(WM_APP_CB_IE_HIT_ENTER,OnAppCbIeHitEnter)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropDown)
ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelChange)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_APP_CB_IE_POPULATE,OnCBIEPopulate)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIEShellComboBox message handlers
void CIEShellComboBox::Populate(LPITEMIDLIST pidlAbsSel)
{
if (m_hImageList == NULL)
SetShellImageList();
if (STL_EMPTY(m_vItems))
InitItems(pidlAbsSel);
if (GetShellPidl().ComparePidls(NULL,pidlAbsSel,m_pidlInternet))
LoadURLPrevList();
else
LoadItems(pidlAbsSel);
}
void CIEShellComboBox::LoadURLPrevList()
{
if (m_ImageList.m_hImageList)
::SendMessage(GetSafeHwnd(), CBEM_SETIMAGELIST, 0, (LPARAM)m_ImageList.m_hImageList);
ResetContent();
HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER,strURLKey,0,KEY_READ,&hKey) != ERROR_SUCCESS)
return;
TCHAR szValueName[_MAX_PATH];
BYTE pData[_MAX_PATH];
DWORD dwSizeValueName = sizeof(szValueName)-1;
DWORD dwSizeData = sizeof(pData)-1;
DWORD dwType=0;
COMBOBOXEXITEM item;
ZeroMemory(&item,sizeof(item));
item.mask |= (CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE);
item.iItem = -1;
item.iImage = 0;
for(DWORD dwIndex=0;RegEnumValue(hKey,
dwIndex,
szValueName,
&dwSizeValueName,
NULL,
&dwType,
pData,
&dwSizeData) == ERROR_SUCCESS;dwIndex++)
{
item.pszText = (LPTSTR)(LPCTSTR)pData;
item.cchTextMax = lstrlen(item.pszText);
InsertItem(&item);
dwSizeValueName = sizeof(szValueName)-1;
dwSizeData = sizeof(pData)-1;
}
RegCloseKey(hKey);
m_bInternet = true;
}
void CIEShellComboBox::InitItems(LPITEMIDLIST pidlAbsSel)
{
LPSHELLFOLDER psfDesktop=NULL;
LPITEMIDLIST pidlDesktop=NULL;
HRESULT hr = SHGetDesktopFolder(&psfDesktop);
SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop);
SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &m_pidlMyComputer);
SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &m_pidlMyDocuments);
SHGetSpecialFolderLocation(NULL, CSIDL_INTERNET, &m_pidlInternet);
int nImage=0, nSelImage=0;
SHFILEINFO fileInfo;
SHGetFileInfo((LPCTSTR)pidlDesktop, NULL, &fileInfo, sizeof(fileInfo), SHGFI_PIDL|SHGFI_ATTRIBUTES|SHGFI_DISPLAYNAME);
m_ShellPidl.GetNormalAndSelectedIcons(pidlDesktop, nImage, nSelImage);
CShCMSort *pItem = new CShCMSort;
pItem->SetText(fileInfo.szDisplayName);
pItem->SetImage(nImage);
pItem->SetSelImage(nSelImage);
LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
lptvid->lpi = GetShellPidl().CopyItemID(pidlDesktop);
lptvid->lpifq = GetShellPidl().CopyItemIDList(pidlDesktop);
lptvid->lpsfParent = NULL;
STL_ADD_ITEM(m_vItems,pItem);
BuildFolderList(psfDesktop,pidlDesktop,pidlAbsSel,1);
if (m_pMalloc)
{
if (pidlDesktop)
m_pMalloc->Free(pidlDesktop);
}
psfDesktop->Release();
}
void CIEShellComboBox::BuildFolderList(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl,LPITEMIDLIST pidlAbsSel, int nIndent)
{
vecCMSort vItems;
AddItems(vItems,pFolder,pidl,nIndent);
// Sort the this node based on pidls
STL_SORT(vItems,pFolder,STL_SORT_FUNC);
CShCMSort *pItem=NULL;
STL_FOR_ITERATOR(vecCMSort,vItems)
{
pItem = STL_GET_CURRENT(vItems);
STL_ADD_ITEM(m_vItems,pItem);
if (GetShellPidl().ComparePidls(pFolder,pItem->GetPidl(),m_pidlMyComputer))
{
LPSHELLFOLDER pSubFolder=NULL;
HRESULT hr = pFolder->BindToObject(pItem->GetPidl(), 0, IID_IShellFolder,(LPVOID*)&pSubFolder);
if (SUCCEEDED(hr))
{
BuildFolderList(pSubFolder,pItem->GetPidl(),pidlAbsSel,nIndent+1);
pSubFolder->Release();
}
}
}
}
void CIEShellComboBox::LoadItems(LPITEMIDLIST pidlAbsSel)
{
if (m_hImageList)
::SendMessage(GetSafeHwnd(), CBEM_SETIMAGELIST, 0, (LPARAM)m_hImageList);
GetComboBoxCtrl()->ResetContent();
DeleteAllItemData();
CShCMSort *pItem=NULL;
int nCount = GetShellPidl().GetCount(pidlAbsSel);
LPITEMIDLIST pidlCompare=NULL;
int nSelItem=-1;
int nItem=0;
int n=0;
int nIndent=0;
CString sPath;
STL_FOR_ITERATOR(vecCMSort,m_vItems)
{
pItem = STL_GET_CURRENT(m_vItems);
nItem = AddItem(pItem);
nIndent = pItem->GetIndent();
if (nIndent == 0)
nIndent = 1;
// TRACE2("Getting pidl %d of %u\n",nIndent,nCount);
pidlCompare=GetShellPidl().CopyItemID(pidlAbsSel,nIndent);
// Desktop item
if (nCount == 0 && n == 0)
{
nSelItem = 0;
sPath = pItem->GetText();
}
else if (nCount == 1 && GetShellPidl().ComparePidls(NULL,pItem->GetPidl(),pidlAbsSel) == true)
{
nSelItem = nItem;
sPath = pItem->GetText();
}
else if (GetShellPidl().CompareMemPidls(pItem->GetPidl(),pidlCompare) == true
&& GetShellPidl().CompareMemPidls(pItem->GetPidl(),m_pidlMyComputer) == false)
{
LPITEMIDLIST pidlAbs=NULL;
CString sDisplayName;
CShCMSort Item;
int nImage=0;
int nSelImage=0;
for(int i=nIndent+1;i < (nCount+1);i++)
{
pidlAbs = GetShellPidl().CopyAbsItemID(pidlAbsSel,i);
if (pidlAbs)
{
GetShellPidl().SHPidlToPathEx(pidlAbs,sPath,NULL);
GetShellPidl().GetDisplayName(pidlAbs,sDisplayName);
GetShellPidl().GetNormalAndSelectedIcons(pidlAbs,nImage,nSelImage);
Item.SetText(sDisplayName);
Item.SetImage(nImage);
Item.SetSelImage(nSelImage);
LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
lptvid->lpi = GetShellPidl().CopyItemID(pidlAbs);
lptvid->lpifq = pidlAbs;
LPTVITEMDATA dt_lptvid = (LPTVITEMDATA)pItem->GetItemData();
lptvid->lpsfParent = dt_lptvid->lpsfParent;
lptvid->lpsfParent->AddRef();
Item.SetItemData((DWORD)lptvid);
Item.SetIndent(i);
m_vecItemData.push_back(lptvid);
nItem = AddItem(&Item);
}
}
if (nSelItem == -1)
nSelItem = nItem;
if (sPath.Find(_T("::")) == 0)
GetShellPidl().GetDisplayName(pidlAbsSel,sPath);
else if(sPath.IsEmpty())
sPath = pItem->GetText();
}
if (pidlCompare)
{
m_pMalloc->Free(pidlCompare);
pidlCompare = NULL;
}
n++;
}
if (nSelItem >= 0)
GetComboBoxCtrl()->SetCurSel(nSelItem);
GetEditCtrl()->SetWindowText(sPath);
m_bInternet = false;
}
int CIEShellComboBox::AddItem(const CShCMSort *pItem)
{
// add the node to the combo box
COMBOBOXEXITEM item;
ZeroMemory(&item,sizeof(item));
item.mask |= (CBEIF_IMAGE | CBEIF_INDENT | CBEIF_LPARAM | CBEIF_TEXT | CBEIF_SELECTEDIMAGE);
item.iItem = -1;
item.pszText = (LPTSTR)(LPCTSTR)pItem->GetText();
item.cchTextMax = lstrlen(item.pszText);
item.iImage = pItem->GetImage();
item.iSelectedImage = pItem->GetSelImage();
item.iOverlay = pItem->GetOverlayImage();
item.iIndent = pItem->GetIndent();
item.lParam = (LPARAM)pItem->GetItemData();
return InsertItem(&item);
}
void CIEShellComboBox::AddItems(vecCMSort &vItems,IShellFolder* pFolder,LPITEMIDLIST pidlAbs,int nIndent)
{
IEnumIDList* pItems = NULL;
LPITEMIDLIST pidlNext = NULL;
LPITEMIDLIST pidlCopy = NULL;
LPTSTR pszFilePath = NULL;
STRRET StrRetFilePath;
// Enumerate all object in the given folder
HRESULT hr = pFolder->EnumObjects(NULL, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS, &pItems);
SHFILEINFO fileinfo;
while (NOERROR == hr)
{
hr = pItems->Next(1, &pidlNext, NULL);
if (hr == S_FALSE || pidlNext == NULL || pidlNext == pidlCopy)
break;
pidlCopy = pidlNext;
pFolder->GetDisplayNameOf(pidlNext,SHGDN_INFOLDER,&StrRetFilePath);
GetShellPidl().StrRetToStr(StrRetFilePath, &pszFilePath, pidlNext);
ZeroMemory(&fileinfo,sizeof(fileinfo));
fileinfo.dwAttributes=SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
hr = pFolder->GetAttributesOf(1,(const struct _ITEMIDLIST **)&pidlCopy,&fileinfo.dwAttributes);
if (SUCCEEDED(hr))
lstrcpy(fileinfo.szDisplayName,pszFilePath);
// Create a submenu if this item is a folder
if (fileinfo.dwAttributes & (SFGAO_HASSUBFOLDER | SFGAO_FOLDER))
{
if (fileinfo.dwAttributes & SFGAO_FOLDER)
{
AddFolder(vItems,fileinfo,pidlAbs,pidlNext,pFolder,nIndent);
}
}
if (pszFilePath)
m_pMalloc->Free(pszFilePath);
}
if (pidlNext)
m_pMalloc->Free(pidlNext);
if (pItems)
pItems->Release();
}
void CIEShellComboBox::AddFolder(vecCMSort &vItems,const SHFILEINFO &FileInfo,LPITEMIDLIST pidlAbs,LPITEMIDLIST pidl,LPSHELLFOLDER pFolder,int nIndent)
{
ASSERT(m_pMalloc);
// allocate new itemdata
LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
if (lptvid == NULL)
return;
ZeroMemory(lptvid,sizeof(TVITEMDATA));
// create new fully qualified pidl
lptvid->lpifq = m_ShellPidl.ConcatPidl(pidlAbs,pidl);
// Now make a copy of the last item in the pidl.
lptvid->lpi = pidl;
int nImage=0;
int nSelImage=0;
// get icons for new fq pidl
m_ShellPidl.GetNormalAndSelectedIcons(lptvid->lpifq, nImage, nSelImage);
// save folder for later use(when node is expanded)
lptvid->lpsfParent = pFolder; // pointer to parent folder
// keep hold of it(will be released in clean up)
lptvid->lpsfParent->AddRef();
CShCMSort *pSMI = new CShCMSort;
pSMI->SetPidl(pidl);
pSMI->SetText(FileInfo.szDisplayName);
pSMI->SetImage(nImage);
pSMI->SetSelImage(nSelImage);
pSMI->SetItemData((DWORD)lptvid);
pSMI->SetIndent(nIndent);
STL_ADD_ITEM(vItems,pSMI);
}
void CIEShellComboBox::SetShellImageList()
{
// TODO: Add your specialized creation code here
HKEY hKey;
if (RegOpenKeyEx(HKEY_CLASSES_ROOT,strIEKey,0,KEY_READ,&hKey) == ERROR_SUCCESS)
{
BYTE szValueName[_MAX_PATH];
DWORD dwType=0;
DWORD dwSizeData = sizeof(szValueName)-1;
RegQueryValueEx(hKey,NULL,0,&dwType,szValueName,&dwSizeData);
CString sPath((LPCTSTR)szValueName);
if (sPath.Left(1) == _T('"'))
sPath = sPath.Right(sPath.GetLength()-1);
if (sPath.Right(1) == _T('"'))
sPath = sPath.Left(sPath.GetLength()-1);
if (sPath.Find(_T("%")) != -1)
{
TCHAR szPath[MAX_PATH];
if (ExpandEnvironmentStrings(sPath,szPath,sizeof(szPath)) > 0)
sPath = szPath;
}
if (sPath.Find(_T("~")) != -1)
{
TCHAR szPath[MAX_PATH];
if (GetLongPathName(sPath,szPath,sizeof(szPath)) > 0)
sPath = szPath;
}
ExtractIconEx(sPath, 1, NULL, &m_hIcon, 1);
// create the small icon image list
UINT cxSmallIcon = ::GetSystemMetrics(SM_CXSMICON);
UINT cySmallIcon = ::GetSystemMetrics(SM_CYSMICON);
if (m_ImageList.GetSafeHandle() != NULL)
m_ImageList.DeleteImageList();
m_ImageList.Create(cxSmallIcon,
cySmallIcon,
ILC_MASK | ILC_COLOR16,
1,
1);
if (m_hIcon)
m_ImageList.Add(m_hIcon);
}
SHFILEINFO sfi;
m_hImageList = (HIMAGELIST)SHGetFileInfo((LPCTSTR)_T("C:\\"),
0,
&sfi,
sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
// Attach ImageList to the window
if (m_hImageList)
::SendMessage(m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)m_hImageList);
}
void CIEShellComboBox::SelectionChanged(bool bEnter)
{
LPITEMIDLIST pidlSel = GetSelectedPidl();
GetEditCtrl()->GetWindowText(m_sText);
UINT mess=WM_APP_CB_IE_SEL_CHANGE;
if (bEnter)
mess=WM_APP_CB_IE_HIT_ENTER;
if (m_hTreeWnd)
{
if (mess == WM_APP_CB_IE_SEL_CHANGE)
::SendMessage(m_hTreeWnd,mess,(WPARAM)pidlSel,(LPARAM)(LPCTSTR)m_sText);
else
::SendMessage(m_hTreeWnd,mess,(WPARAM)m_bInternet,(LPARAM)(LPCTSTR)m_sText);
}
}
int CIEShellComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CComboBoxEx::OnCreate(lpCreateStruct) == -1)
return -1;
SetShellImageList();
if (m_cbEdit.GetSafeHwnd() == NULL)
{
m_cbEdit.SubclassWindow(GetEditCtrl()->GetSafeHwnd());
m_cbEdit.SetTreeWnd(m_hTreeWnd);
}
return 0;
}
void CIEShellComboBox::OnDestroy()
{
SetImageList(NULL);
CComboBoxEx::OnDestroy();
// TODO: Add your message handler code here
}
LRESULT CIEShellComboBox::OnCBIEPopulate(WPARAM wParam,LPARAM lParam)
{
Populate((LPITEMIDLIST)wParam);
return 1L;
}
void CIEShellComboBox::OnDropDown()
{
}
void CIEShellComboBox::OnSelChange()
{
SelectionChanged(false);
}
void CIEShellComboBox::OnKillFocus(CWnd *pNewWnd)
{
CComboBoxEx::OnKillFocus(pNewWnd);
SetEditSel(-1,0);
}
void CIEShellComboBox::OnSetFocus(CWnd *pWnd)
{
CComboBoxEx::OnSetFocus(pWnd);
SetEditSel(-1,-1);
}
BOOL CIEShellComboBoxEdit::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_RETURN)
{
GetParent()->GetParent()->PostMessage(WM_APP_CB_IE_HIT_ENTER);
return TRUE;
}
}
return CEdit::PreTranslateMessage(pMsg);
}
void CIEShellComboBox::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CComboBoxEx::PreSubclassWindow();
if (m_cbEdit.GetSafeHwnd() == NULL)
{
m_cbEdit.SubclassWindow(GetEditCtrl()->GetSafeHwnd());
m_cbEdit.SetTreeWnd(m_hTreeWnd);
}
}
LRESULT CIEShellComboBox::OnAppCbIeHitEnter(WPARAM wParam, LPARAM lParam)
{
SelectionChanged(true);
return 1;
}
@@ -1,131 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "IEShellDragDrop.h"
#include "cbformats.h"
#ifndef OleStdGetDropEffect
#define OleStdGetDropEffect(grfKeyState) \
( (grfKeyState & MK_CONTROL) ? \
( (grfKeyState & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY ) : \
( (grfKeyState & MK_SHIFT) ? DROPEFFECT_MOVE : DROPEFFECT_NONE ) )
#endif
bool CIEShellDragDrop::DragEnter(CDD_OleDropTargetInfo *pInfo,LPSHELLFOLDER psfFolder,LPITEMIDLIST pidl)
{
// DWORD dwEffect = m_ShellPidl.GetDragDropAttributes(pInfo->GetDataObject()->m_lpDataObject);
IDropTarget *pdt=NULL;
if (psfFolder == NULL)
psfFolder = m_psfDesktop;
HRESULT hr = psfFolder->GetUIObjectOf(pInfo->GetSafeHwnd(),1,(LPCITEMIDLIST*)&pidl, IID_IDropTarget, NULL, (LPVOID*)&pdt);
if (FAILED(hr))
return false;
DWORD dwKeyState = pInfo->GetKeyboardState();
CPoint pt(pInfo->GetPoint());
::ClientToScreen(pInfo->GetSafeHwnd(),&pt);
POINTL ptl;
ptl.x = pt.x;
ptl.y = pt.y;
DWORD dwEffect=0;
pdt->DragEnter(pInfo->GetDataObject()->m_lpDataObject, dwKeyState, ptl, &dwEffect);
pdt->DragLeave();
pInfo->SetDropEffect(dwEffect);
pdt->Release();
return true;
}
bool CIEShellDragDrop::DragLeave(CDD_OleDropTargetInfo *pInfo)
{
return false;
}
bool CIEShellDragDrop::DragOver(CDD_OleDropTargetInfo *pInfo,LPSHELLFOLDER psfFolder,LPITEMIDLIST pidl)
{
pInfo->SetDropEffect(DROPEFFECT_NONE);
IDropTarget *pdt=NULL;
if (psfFolder == NULL)
psfFolder = m_psfDesktop;
HRESULT hr = psfFolder->GetUIObjectOf(pInfo->GetSafeHwnd(),1,(LPCITEMIDLIST*)&pidl, IID_IDropTarget, NULL, (LPVOID*)&pdt);
if (FAILED(hr))
return false;
DWORD dwKeyState = pInfo->GetKeyboardState();
TRACE1("dwKeyState=%u\n",dwKeyState);
CPoint pt(pInfo->GetPoint());
::ClientToScreen(pInfo->GetSafeHwnd(),&pt);
POINTL ptl;
ptl.x = pt.x;
ptl.y = pt.y;
DWORD dwEffect=OleStdGetDropEffect(dwKeyState);
if (dwEffect == DROPEFFECT_NONE)
dwEffect = DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK;
TRACE1("dropEffect=%u\n",dwEffect);
pdt->DragEnter(pInfo->GetDataObject()->m_lpDataObject, dwKeyState, ptl, &dwEffect);
pdt->DragOver(dwKeyState, ptl, &dwEffect);
pdt->DragLeave();
pdt->Release();
pInfo->SetDropEffect(dwEffect);
return true;
}
bool CIEShellDragDrop::DragDrop(CDD_OleDropTargetInfo *pInfo,LPSHELLFOLDER psfFolder,LPITEMIDLIST pidl)
{
IDropTarget *pdt=NULL;
if (psfFolder == NULL)
psfFolder = m_psfDesktop;
HRESULT hr = psfFolder->GetUIObjectOf(pInfo->GetSafeHwnd(),1,(LPCITEMIDLIST*)&pidl, IID_IDropTarget, NULL, (LPVOID*)&pdt);
if (FAILED(hr))
return false;
CPoint pt(pInfo->GetPoint());
TRACE2("Drop received at point(client) %d,%d\n",pt.x,pt.y);
::ClientToScreen(pInfo->GetSafeHwnd(),&pt);
TRACE2("Drop received at point(screen) %d,%d\n",pt.x,pt.y);
CWDClipboardData::Instance()->IsDataAvailable(pInfo->GetDataObject());
#ifdef _DEBUG
if (pInfo->GetDataObject()->IsDataAvailable(CF_TEXT))
{
CCF_String cfString;
if (CWDClipboardData::Instance()->GetData(pInfo->GetDataObject(),&cfString,CWDClipboardData::e_cfString))
{
TRACE1("Received CF_TEXT %s\n",cfString.GetString());
}
}
if (pInfo->GetDataObject()->IsDataAvailable(CF_HDROP))
{
CCF_HDROP cfHDROP;
if (CWDClipboardData::Instance()->GetData(pInfo->GetDataObject(),&cfHDROP,CWDClipboardData::e_cfHDROP))
{
for(UINT i=0;i < cfHDROP.GetCount();i++)
TRACE2("Received CF_HDROP %s (%u)\n",cfHDROP.GetFileName(i),i);
}
}
#endif
POINTL ptl;
ptl.x = pt.x;
ptl.y = pt.y;
DWORD dwKeyState = pInfo->GetKeyboardState();
DWORD dw = DROPEFFECT_MOVE;
pdt->DragEnter(pInfo->GetDataObject()->m_lpDataObject, dwKeyState, ptl, &dw);
pdt->DragOver(dwKeyState, ptl, &dw);
DWORD dwEffect = m_ShellPidl.GetDragDropAttributes(pInfo->GetDataObject());
TRACE2("Keyboardstate=%u DragDropEffect=%u\n",dwKeyState,dwEffect);
pdt->Drop(pInfo->GetDataObject()->m_lpDataObject, dwKeyState, ptl, &dwEffect);
pdt->Release();
return true;
}
File diff suppressed because it is too large Load Diff
@@ -1,174 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// IEShellListView.cpp : implementation file
#include "stdafx.h"
#include "UIRes.h"
#include "IEShellListView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIEShellListView
IMPLEMENT_DYNCREATE(CIEShellListView,CUIListView)
CIEShellListView::CIEShellListView()
: CUIListView(IDC_LIST_SHELL)
{
m_pActiveWnd = NULL;
}
CIEShellListView::~CIEShellListView()
{
}
void CIEShellListView::SetActiveWindow(CWnd *pWnd)
{
ASSERT_VALID(pWnd);
if (pWnd->GetSafeHwnd() == NULL)
return;
if (m_pActiveWnd->GetSafeHwnd() == pWnd->GetSafeHwnd())
return;
CRect rect;
m_pActiveWnd->GetWindowRect(rect);
ScreenToClient(&rect);
m_pActiveWnd->ShowWindow(SW_HIDE);
m_pActiveWnd = pWnd;
m_pActiveWnd->ShowWindow(SW_SHOW);
m_pActiveWnd->MoveWindow(&rect);
}
void CIEShellListView::LoadShellFolderItems(const CRefreshShellFolder &rFolder)
{
LPTVITEMDATA lptvid = reinterpret_cast<LPTVITEMDATA>(rFolder.GetItemData());
if (lptvid == NULL)
return;
GetShellListCtrl().Populate(lptvid);
}
BEGIN_MESSAGE_MAP(CIEShellListView, CUIListView)
//{{AFX_MSG_MAP(CIEShellListView)
ON_MESSAGE(WM_SETMESSAGESTRING,OnSetmessagestring)
ON_MESSAGE(WM_APP_UPDATE_ALL_VIEWS,OnAppUpdateAllViews)
ON_WM_SIZE()
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
ON_MESSAGE(WM_APP_CB_IE_SEL_CHANGE,OnCBIESelChange)
ON_MESSAGE(WM_APP_CB_IE_HIT_ENTER,OnCBIEHitEnter)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIEShellListView message handlers
void CIEShellListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
if (lHint == HINT_TREE_SEL_CHANGED)
{
GetListCtrl().SendMessage(WM_APP_UPDATE_ALL_VIEWS,(WPARAM)lHint,(LPARAM)pHint);
}
}
void CIEShellListView::CreateListCtrl()
{
// TODO: Add your specialized code here and/or call the base class
m_pListCtrl = new CIEShellListCtrl;
m_pActiveWnd = m_pListCtrl;
}
CIEShellListCtrl &CIEShellListView::GetShellListCtrl()
{
// TODO: Add your specialized code here and/or call the base class
return static_cast<CIEShellListCtrl&>(GetListCtrl());
}
LRESULT CIEShellListView::OnAppUpdateAllViews(WPARAM wParam, LPARAM lParam)
{
if (wParam == HINT_TREE_INTERNET_FOLDER_SELECTED)
{
if (lParam)
{
if (m_htmlCtrl.GetSafeHwnd() == NULL)
{
if (m_htmlCtrl.Create(NULL, // class name
NULL, // title
(WS_CHILD | WS_VISIBLE), // style
CRect(), // rectangle
this, // parent
2000, // control ID
NULL)) // frame/doc context not use
{
m_htmlCtrl.SetNotifyWnd(GetParentFrame()->GetSafeHwnd());
m_htmlCtrl.GoHome();
}
}
else
GetParentFrame()->SendMessage(WM_APP_CB_IE_SET_EDIT_TEXT,(WPARAM)(LPCTSTR)m_htmlCtrl.GetLocationURL(),0);
SetActiveWindow(&m_htmlCtrl);
}
else
SetActiveWindow(m_pListCtrl);
}
return 1;
}
void CIEShellListView::OnSize(UINT nType, int cx, int cy)
{
// TODO: Add your message handler code here
if (m_pActiveWnd && m_pActiveWnd->GetSafeHwnd())
m_pActiveWnd->MoveWindow(0,0,cx,cy);
else
CView::OnSize(nType, cx, cy);
}
LRESULT CIEShellListView::OnCBIESelChange(WPARAM wParam,LPARAM lParam)
{
if (m_pActiveWnd->GetSafeHwnd() == m_htmlCtrl.GetSafeHwnd())
{
ASSERT(lParam);
if (lParam)
m_htmlCtrl.Navigate((LPCTSTR)lParam);
}
return 1L;
}
LRESULT CIEShellListView::OnCBIEHitEnter(WPARAM wParam,LPARAM lParam)
{
if (m_pActiveWnd->GetSafeHwnd() == m_htmlCtrl.GetSafeHwnd())
{
ASSERT(lParam);
if (lParam)
m_htmlCtrl.Navigate((LPCTSTR)lParam);
}
return 1L;
}
LRESULT CIEShellListView::OnSetmessagestring(WPARAM wParam, LPARAM lParam)
{
CFrameWnd *pFrame = GetParentFrame();
if (pFrame)
return pFrame->SendMessage(WM_SETMESSAGESTRING,wParam,lParam);
return 0;
}
@@ -1,691 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// IEShellTreeCtrl.cpp : implementation file
#include "stdafx.h"
#include "IEShellTreeCtrl.h"
#include "cbformats.h"
#include "UIMessages.h"
#include "dirwalk.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIEShellTreeCtrl
CIEShellTreeCtrl::CIEShellTreeCtrl()
{
m_lptvid = NULL;
m_hListWnd = NULL;
m_hComboWnd = NULL;
m_nThreadCount = 0;
m_bRefreshAllowed = true;
m_bNotifyParent = false;
// Turn off WM_DROPFILES
SetDropFiles(false);
}
CIEShellTreeCtrl::~CIEShellTreeCtrl()
{
}
void CIEShellTreeCtrl::ShellExecute(HTREEITEM hItem,LPCTSTR pszVerb)
{
SHELLEXECUTEINFO si;
ZeroMemory(&si,sizeof(si));
si.cbSize = sizeof(si);
si.hwnd = GetSafeHwnd();
si.nShow = SW_SHOW;
si.lpIDList = (LPVOID)GetPathPidl(hItem);
si.fMask = SEE_MASK_INVOKEIDLIST;
if (pszVerb)
si.lpVerb = pszVerb;
ShellExecuteEx(&si);
}
void CIEShellTreeCtrl::RefreshComboBox(LPTVITEMDATA lptvid)
{
if (m_hComboWnd)
{
::PostMessage(m_hComboWnd,WM_APP_CB_IE_POPULATE,(WPARAM)lptvid->lpifq,0);
}
}
void CIEShellTreeCtrl::SetNotificationObject(bool bNotify)
{
if (bNotify)
CreateFileChangeThreads(GetSafeHwnd());
else
DestroyThreads();
}
void CIEShellTreeCtrl::UpOneLevel(HTREEITEM hItem)
{
if (hItem == NULL)
{
hItem = GetSelectedItem();
}
if (hItem == NULL)
return;
HTREEITEM hParentItem = GetParentItem(hItem);
if (hParentItem)
Select(hParentItem,TVGN_CARET);
}
void CIEShellTreeCtrl::DestroyThreads()
{
if (m_nThreadCount == 0)
return;
for (UINT i=0;i < m_nThreadCount; i++)
m_event[i].SetEvent();
::WaitForMultipleObjects (m_nThreadCount, m_hThreads, TRUE, INFINITE);
for (i=0; i < m_nThreadCount; i++)
delete m_pThreads[i];
m_nThreadCount = 0;
}
void CIEShellTreeCtrl::CreateFileChangeThreads(HWND hwnd)
{
if (m_nThreadCount)
return;
TCHAR szDrives[MAX_PATH];
DWORD dwSize = sizeof(szDrives)/sizeof(TCHAR);
DWORD dwChars = GetLogicalDriveStrings(dwSize,szDrives);
if (dwChars == 0 || dwChars > dwSize)
{
TRACE(_T("Warning: CreateFileChangeThreads failed in GetLogicalDriveStrings\n"));
return;
}
UINT nType;
CString sDrive;
LPCTSTR pszDrives=szDrives;
while (*pszDrives != '\0')
{
sDrive = pszDrives;
nType = ::GetDriveType(sDrive);
if (nType == DRIVE_FIXED || nType == DRIVE_REMOTE || nType == DRIVE_RAMDISK)
{
CreateFileChangeThread(sDrive,hwnd);
}
#if 1 // bugfix by mad79
pszDrives=pszDrives+sDrive.GetLength()+1;
#else
pszDrives = _tcsninc(pszDrives,sDrive.GetLength()+1);
#endif
}
}
void CIEShellTreeCtrl::CreateFileChangeThread(const CString& sPath,HWND hwnd)
{
if (m_nThreadCount >= MAX_THREADS)
return;
PDC_THREADINFO pThreadInfo = new DC_THREADINFO; // Thread will delete
pThreadInfo->sPath = sPath;
pThreadInfo->hEvent = m_event[m_nThreadCount].m_hObject;
pThreadInfo->pTreeCtrl = this;
CWinThread* pThread = AfxBeginThread (ThreadFunc, pThreadInfo,
THREAD_PRIORITY_IDLE);
pThread->m_bAutoDelete = FALSE;
m_hThreads[m_nThreadCount] = pThread->m_hThread;
m_pThreads[m_nThreadCount++] = pThread;
}
HTREEITEM CIEShellTreeCtrl::SearchSiblings(HTREEITEM hItem,LPITEMIDLIST pidlAbs)
{
LPTVITEMDATA pItem = NULL;
HTREEITEM hChildItem = GetChildItem(hItem);
HTREEITEM hFoundItem;
while (hChildItem)
{
pItem = (LPTVITEMDATA)GetItemData(hChildItem);
if (GetShellPidl().ComparePidls(NULL,pItem->lpifq,pidlAbs))
break;
hFoundItem = SearchSiblings(hChildItem,pidlAbs);
if (hFoundItem)
return hFoundItem;
hChildItem = GetNextSiblingItem(hChildItem);
}
return hChildItem;
}
HTREEITEM CIEShellTreeCtrl::ExpandMyComputer(LPITEMIDLIST pidlAbs)
{
HTREEITEM hItem=NULL;
if (pidlAbs == NULL)
return hItem;
LPITEMIDLIST pidlMyComputer=NULL;
LPITEMIDLIST pidlFirst=GetShellPidl().CopyItemID(pidlAbs);
SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlMyComputer);
if (GetShellPidl().ComparePidls(NULL,pidlMyComputer,pidlFirst))
{
hItem = ExpandPidl(pidlMyComputer);
}
if (pidlMyComputer)
GetShellPidl().FreePidl(pidlMyComputer);
if (pidlFirst)
GetShellPidl().FreePidl(pidlFirst);
return hItem;
}
HTREEITEM CIEShellTreeCtrl::ExpandPidl(LPITEMIDLIST pidlAbs)
{
HTREEITEM hItem = SearchSiblings(GetRootItem(),pidlAbs);
if (hItem)
{
Expand(hItem,TVE_EXPAND);
}
return hItem;
}
HTREEITEM CIEShellTreeCtrl::FindPidl(LPITEMIDLIST pidlAbs,BOOL bSelect)
{
HTREEITEM hItem = NULL;
if (pidlAbs == NULL)
hItem = GetRootItem();
else
hItem = SearchSiblings(GetRootItem(),pidlAbs);
if (bSelect && hItem != GetSelectedItem())
{
SelectItem(hItem);
SelectionChanged(hItem,GetItemData(hItem));
}
return hItem;
}
HTREEITEM CIEShellTreeCtrl::FindItem (HTREEITEM hItem, const CString& strTarget)
{
while (hItem != NULL)
{
if (GetItemText (hItem) == strTarget)
break;
hItem = GetNextSiblingItem (hItem);
}
return hItem;
}
UINT CIEShellTreeCtrl::DeleteChildren (HTREEITEM hItem)
{
UINT nCount = 0;
HTREEITEM hChild = GetChildItem (hItem);
while (hChild != NULL)
{
HTREEITEM hNextItem = GetNextSiblingItem (hChild);
DeleteItem (hChild);
hChild = hNextItem;
nCount++;
}
return nCount;
}
void CIEShellTreeCtrl::Init()
{
ModifyStyle(0,TVS_EDITLABELS);
CIEFolderTreeCtrl::Init();
}
void CIEShellTreeCtrl::Refresh()
{
SetRefreshAllowed(false);
CIEFolderTreeCtrl::Refresh();
SetRefreshAllowed(true);
}
bool CIEShellTreeCtrl::DragEnter(CDD_OleDropTargetInfo *pInfo)
{
HTREEITEM hItem = pInfo->GetTreeItem();
if (hItem == NULL)
return false;
LPTVITEMDATA ptvid = (LPTVITEMDATA)GetItemData(hItem);
ASSERT(ptvid);
if (ptvid == NULL)
return false;
return m_ShellDragDrop.DragEnter(pInfo,ptvid->lpsfParent,ptvid->lpi);
}
bool CIEShellTreeCtrl::DragLeave(CDD_OleDropTargetInfo *pInfo)
{
return m_ShellDragDrop.DragLeave(pInfo);
}
bool CIEShellTreeCtrl::DragOver(CDD_OleDropTargetInfo *pInfo)
{
pInfo->SetDropEffect(DROPEFFECT_NONE);
HTREEITEM hItem = pInfo->GetTreeItem();
if (hItem == NULL)
return false;
LPTVITEMDATA ptvid = (LPTVITEMDATA)GetItemData(hItem);
ASSERT(ptvid);
if (ptvid == NULL)
return false;
return m_ShellDragDrop.DragOver(pInfo,ptvid->lpsfParent,ptvid->lpi);
}
bool CIEShellTreeCtrl::DragDrop(CDD_OleDropTargetInfo *pInfo)
{
HTREEITEM hItem = pInfo->GetTreeItem();
if (hItem == NULL)
return false;
LPTVITEMDATA ptvid = (LPTVITEMDATA)GetItemData(hItem);
ASSERT(ptvid);
if (ptvid == NULL)
return false;
return m_ShellDragDrop.DragDrop(pInfo,ptvid->lpsfParent,ptvid->lpi);
}
DROPEFFECT CIEShellTreeCtrl::DoDragDrop(NM_TREEVIEW* pNMTreeView,COleDataSource *pOleDataSource)
{
if (pNMTreeView->itemNew.hItem == GetRootItem())
return DROPEFFECT_NONE;
CCF_ShellIDList sl;
CShellPidl pidl;
HTREEITEM hParentItem = GetParentItem(pNMTreeView->itemNew.hItem);
LPTVITEMDATA ptvid = (LPTVITEMDATA)GetItemData(pNMTreeView->itemNew.hItem);
LPTVITEMDATA ptvid_parent = (LPTVITEMDATA)GetItemData(hParentItem);
ASSERT(ptvid);
ASSERT(ptvid_parent);
if (GetShellPidl().IsDesktopFolder(ptvid->lpsfParent))
sl.AddPidl(GetShellPidl().GetEmptyPidl());
else
sl.AddPidl(ptvid_parent->lpifq);
sl.AddPidl(ptvid->lpi);
CCF_HDROP cf_hdrop;
CCF_String cf_text;
CString sPath;
pidl.SHPidlToPathEx(ptvid->lpifq,sPath);
cf_hdrop.AddDropPoint(CPoint(pNMTreeView->ptDrag),FALSE);
cf_hdrop.AddFileName(sPath);
sPath += _T("\r\n");
cf_text.SetString(sPath);
CWDClipboardData::Instance()->SetData(pOleDataSource,&cf_text,CWDClipboardData::e_cfString);
CWDClipboardData::Instance()->SetData(pOleDataSource,&cf_hdrop,CWDClipboardData::e_cfHDROP);
CWDClipboardData::Instance()->SetData(pOleDataSource,&sl,CWDClipboardData::e_cfShellIDList);
return GetShellPidl().GetDragDropAttributes(ptvid);
}
bool CIEShellTreeCtrl::EndLabelEdit(HTREEITEM hItem,LPCTSTR pszText)
{
LPTVITEMDATA plvit = (LPTVITEMDATA)GetItemData(hItem);
CString sFromPath;
CString sToPath;
GetShellPidl().SHPidlToPathEx(plvit->lpifq,sFromPath);
sToPath = sFromPath;
sToPath.Replace(GetItemText(hItem),pszText);
SHFILEOPSTRUCT shf;
TCHAR szFrom[MAX_PATH+1];
TCHAR szTo[MAX_PATH+1];
ZeroMemory(szFrom,sizeof(szFrom));
lstrcpy(szFrom,sFromPath);
ZeroMemory(szTo,sizeof(szTo));
lstrcpy(szTo,sToPath);
ZeroMemory(&shf,sizeof(shf));
shf.hwnd = GetSafeHwnd();
shf.wFunc = FO_RENAME;
shf.pFrom = szFrom;
shf.pTo = szTo;
#ifdef _DEBUG
CString sMess;
sMess = szFrom;
sMess += _T("\n");
sMess += szTo;
AfxMessageBox(sMess);
#endif
if (SHFileOperation(&shf) == 0)
return true;
SetRefreshAllowed(false);
return false;
}
bool CIEShellTreeCtrl::SHMoveFile(HTREEITEM hSrcItem,HTREEITEM hDestItem)
{
LPTVITEMDATA plvit_src = (LPTVITEMDATA)GetItemData(hSrcItem);
LPTVITEMDATA plvit_dest = (LPTVITEMDATA)GetItemData(hDestItem);
CString sFromPath;
CString sToPath;
GetShellPidl().SHPidlToPathEx(plvit_src->lpifq,sFromPath);
GetShellPidl().SHPidlToPathEx(plvit_dest->lpifq,sToPath);
SHFILEOPSTRUCT shf;
TCHAR szFrom[MAX_PATH+1];
TCHAR szTo[MAX_PATH+1];
ZeroMemory(szFrom,sizeof(szFrom));
lstrcpy(szFrom,sFromPath);
ZeroMemory(szTo,sizeof(szTo));
lstrcpy(szTo,sToPath);
ZeroMemory(&shf,sizeof(shf));
shf.hwnd = GetSafeHwnd();
shf.wFunc = FO_MOVE;
shf.pFrom = szFrom;
shf.pTo = szTo;
return SHFileOperation(&shf) == 0 ? true : false;
}
BOOL CIEShellTreeCtrl::TransferItem(HTREEITEM hitemDrag, HTREEITEM hitemDrop)
{
return SHMoveFile(hitemDrag,hitemDrop) ? TRUE : FALSE;
}
bool CIEShellTreeCtrl::GetFolderInfo(HTREEITEM hItem,CString &sPath,CString &sName)
{
LPTVITEMDATA lptvid = (LPTVITEMDATA)GetItemData(hItem);
if (lptvid == NULL)
return false;
GetShellPidl().SHPidlToPathEx(lptvid->lpifq,sPath,NULL,SHGDN_NORMAL);
GetShellPidl().GetDisplayName(lptvid->lpi,sName);
return true;
}
bool CIEShellTreeCtrl::LoadFolderItems(LPCTSTR pszPath)
{
return LoadItems(pszPath);
}
CRefresh *CIEShellTreeCtrl::CreateRefreshObject(HTREEITEM hItem,LPARAM lParam)
{
CRefreshShellFolder *pRefresh=NULL;
if (lParam)
{
pRefresh = new CRefreshShellFolder(hItem,lParam);
}
return pRefresh;
}
bool CIEShellTreeCtrl::Expanding(NM_TREEVIEW *nmtvw)
{
if ((nmtvw->itemNew.state & TVIS_EXPANDEDONCE) || nmtvw->itemNew.hItem == GetRootItem())
return false;
LPSHELLFOLDER pFolder=NULL;
CUIListCtrlData *pData = (CUIListCtrlData*)nmtvw->itemNew.lParam;
ASSERT(pData);
ASSERT_KINDOF(CUIListCtrlData,pData);
LPTVITEMDATA lptvid=(LPTVITEMDATA)pData->GetExtData();
if (lptvid)
{
HRESULT hr=lptvid->lpsfParent->BindToObject(lptvid->lpi,
0, IID_IShellFolder,(LPVOID*)&pFolder);
if (SUCCEEDED(hr))
{
if (!AddItems(nmtvw->itemNew.hItem,pFolder))
SetButtonState(nmtvw->itemNew.hItem);
}
return false;
}
// prevent from expanding
return true;
}
BEGIN_MESSAGE_MAP(CIEShellTreeCtrl, CIEFolderTreeCtrl)
//{{AFX_MSG_MAP(CIEShellTreeCtrl)
ON_MESSAGE(WM_SETMESSAGESTRING,OnSetmessagestring)
ON_MESSAGE(WM_APP_CB_IE_HIT_ENTER,OnAppCbIeHitEnter)
// NOTE - the ClassWizard will add and remove mapping macros here.
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_APP_POPULATE_TREE,OnAppPopulateTree)
ON_MESSAGE(WM_APP_CB_IE_SEL_CHANGE,OnCBIESelChange)
ON_MESSAGE(WM_APP_DIR_CHANGE_EVENT,OnAppDirChangeEvent)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIEShellTreeCtrl message handlers
BOOL CIEShellTreeCtrl::OnWndMsg( UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult )
{
if ((message == WM_MEASUREITEM || message == WM_DRAWITEM && wParam == 0) || message == WM_INITMENUPOPUP)
{
if (m_lptvid)
{
return GetShellPidl().HandleMenuMsg(m_hWnd,m_lptvid->lpsfParent, m_lptvid->lpi,
message,wParam,lParam);
}
}
return CIEFolderTreeCtrl::OnWndMsg(message, wParam, lParam, pResult );
}
void CIEShellTreeCtrl::PreSubclassWindow()
{
CIEFolderTreeCtrl::PreSubclassWindow();
CreateFileChangeThreads(GetSafeHwnd());
}
/////////////////////////////////////////////////////////////////////////
// Thread function for detecting file system changes
UINT CIEShellTreeCtrl::ThreadFunc (LPVOID pParam)
{
///////////////////////////////
PDC_THREADINFO pThreadInfo = (PDC_THREADINFO) pParam;
HANDLE hEvent = pThreadInfo->hEvent;
CIEShellTreeCtrl *pTreeCtrl = pThreadInfo->pTreeCtrl;
HWND hWnd = pTreeCtrl->GetSafeHwnd();
TCHAR szPath[MAX_PATH];
lstrcpy(szPath,pThreadInfo->sPath);
delete pThreadInfo;
////////////////////////////////////
// Get a handle to a file change notification object.
TRACE(_T("Creating directory thread handler for %s\n"),szPath);
HANDLE hDirChange = ::FindFirstChangeNotification (szPath,TRUE,FILE_NOTIFY_CHANGE_DIR_NAME);
// Return now if ::FindFirstChangeNotification failed.
if (hDirChange == INVALID_HANDLE_VALUE)
return 1;
const int nHandles=2;
HANDLE aHandles[nHandles];
aHandles[0] = hDirChange;
aHandles[1] = hEvent;
BOOL bContinue = TRUE;
// Sleep until a file change notification wakes this thread or
// m_event becomes set indicating it's time for the thread to end.
while (bContinue)
{
TRACE(_T("TreeControl waiting for %u multiple objects\n"),nHandles);
DWORD dw = ::WaitForMultipleObjects (nHandles, aHandles, FALSE, INFINITE);
if (dw - WAIT_OBJECT_0 == 0)
{ // Respond to a change notification.
::FindNextChangeNotification (hDirChange);
TRACE(_T("-- Directory notify event was fired in CIEShellTreeCtrl --\n"));
if (pTreeCtrl->RefreshAllowed())
{
::PostMessage (hWnd, WM_APP_DIR_CHANGE_EVENT,0,0);
}
else
{
TRACE(_T("but not sending as refresh disallowed\n"));
pTreeCtrl->SetRefreshAllowed(true);
TRACE(_T("Refresh is now allowed\n"));
}
}
else if(dw - WAIT_OBJECT_0 == 1)
{
bContinue = FALSE;
TRACE(_T("Directory Notify Thread was signalled to stop\n"));
}
}
// Close the file change notification handle and return.
::FindCloseChangeNotification (hDirChange);
TRACE(_T("Directory Notify Thread is ending\n"));
return 0;
}
void CIEShellTreeCtrl::OnDestroy()
{
DestroyThreads();
CIEFolderTreeCtrl::OnDestroy();
}
LRESULT CIEShellTreeCtrl::OnAppDirChangeEvent(WPARAM wParam, LPARAM lParam)
{
if (!RefreshAllowed())
return 1L;
Refresh();
if (m_bNotifyParent)
GetParent()->SendMessage(WM_APP_UPDATE_ALL_VIEWS,(WPARAM)HINT_SHELL_DIR_CHANGED,(LPARAM)(LPCTSTR)GetRootPath());
return 1L;
}
LRESULT CIEShellTreeCtrl::OnCBIESelChange(WPARAM wParam,LPARAM lParam)
{
LPITEMIDLIST pidl = (LPITEMIDLIST)wParam;
ExpandMyComputer(pidl);
FindPidl(pidl);
GetShellPidl().FreePidl(pidl);
SetFocus();
return 1L;
}
// Selection has changed
void CIEShellTreeCtrl::UpdateEvent(LPARAM lHint,CObject *pHint)
{
// TODO: Add your specialized code here and/or call the base class
// Notify the combo box
const CRefreshShellFolder *pRefresh = static_cast<CRefreshShellFolder*>(pHint);
LPTVITEMDATA lptvid = reinterpret_cast<LPTVITEMDATA>(pRefresh->GetItemData());
ASSERT(lptvid);
// Notify combo box
RefreshComboBox(lptvid);
// Notify list control
if (m_hListWnd)
{
::SendMessage(m_hListWnd,WM_APP_UPDATE_ALL_VIEWS,(WPARAM)lHint,(LPARAM)pHint);
return;
}
// or let base class handle it
CUITreeCtrl::UpdateEvent(lHint,pHint);
}
LRESULT CIEShellTreeCtrl::OnAppPopulateTree(WPARAM wParam, LPARAM lParam)
{
TRACE0("Selecting root item\n");
HTREEITEM hRoot = GetRootItem();
if (hRoot == NULL)
return 1L;
SelectItem(hRoot);
#ifndef _DEBUG
SelectionChanged(hRoot,GetItemData(hRoot));
#else
LPTVITEMDATA lptvid = reinterpret_cast<LPTVITEMDATA>(GetItemData(hRoot));
RefreshComboBox(lptvid);
#endif
return 1;
}
void CIEShellTreeCtrl::DeleteKey(HTREEITEM hItem)
{
// TODO: Add your specialized code here and/or call the base class
SHFILEOPSTRUCT shf;
ZeroMemory(&shf,sizeof(shf));
TCHAR szFrom[MAX_PATH+1];
ZeroMemory(szFrom,sizeof(szFrom)*sizeof(TCHAR));
lstrcpy(szFrom,GetPathName(hItem));
shf.hwnd = GetSafeHwnd();
shf.wFunc = FO_DELETE;
shf.pFrom = szFrom;
shf.fFlags = GetKeyState(VK_SHIFT) < 0 ? 0 : FOF_ALLOWUNDO;
SHFileOperation(&shf);
}
void CIEShellTreeCtrl::DoubleClick(HTREEITEM hItem)
{
// TODO: Add your specialized code here and/or call the base class
ShellExecute(hItem);
}
void CIEShellTreeCtrl::GoBack(HTREEITEM hItem)
{
// TODO: Add your specialized code here and/or call the base class
UpOneLevel(hItem);
}
void CIEShellTreeCtrl::ShowPopupMenu(HTREEITEM hItem,CPoint point)
{
// TODO: Add your specialized code here and/or call the base class
if (m_PopupID)
{
CUITreeCtrl::ShowPopupMenu(hItem,point);
}
// TODO: Add your control notification handler code here
m_lptvid = (LPTVITEMDATA)GetItemData(hItem);
if (m_lptvid)
GetShellPidl().PopupTheMenu(m_hWnd,m_lptvid->lpsfParent, &m_lptvid->lpi, 1, &point);
}
void CIEShellTreeCtrl::ShowProperties(HTREEITEM hItem)
{
// TODO: Add your specialized code here and/or call the base class
ShellExecute(hItem,_T("properties"));
}
LRESULT CIEShellTreeCtrl::OnAppCbIeHitEnter(WPARAM wParam, LPARAM lParam)
{
if (lParam == NULL)
return 0L;
LPCTSTR pszPath = (LPCTSTR)lParam;
LPITEMIDLIST pidl=NULL;
GetShellPidl().SHPathToPidlEx(pszPath,&pidl,NULL);
if (pidl == NULL)
return 0L;
int nCount = GetShellPidl().GetCount(pidl);
LPITEMIDLIST pidlPart=NULL;
LPITEMIDLIST pidlFull=NULL;
HTREEITEM hItem=NULL;
SetRedraw(FALSE);
for(int i=0;i < nCount;i++)
{
pidlPart=GetShellPidl().CopyItemID(pidl,i+1);
if (pidlPart)
{
pidlFull = GetShellPidl().ConcatPidl(pidlFull,pidlPart);
hItem = ExpandPidl(pidlFull);
if (hItem == NULL)
break;
GetShellPidl().FreePidl(pidlPart);
}
}
if (hItem && GetShellPidl().ComparePidls(NULL,pidl,pidlFull))
{
Select(hItem,TVGN_CARET);
}
else
{
CString sMess;
sMess.Format(_T("%s was not found"),pszPath);
AfxMessageBox(sMess,MB_ICONSTOP);
}
if (pidl)
GetShellPidl().FreePidl(pidl);
if (pidlFull)
GetShellPidl().FreePidl(pidlFull);
SetRedraw(TRUE);
return 1;
}
LRESULT CIEShellTreeCtrl::OnSetmessagestring(WPARAM wParam, LPARAM lParam)
{
if (GetParent())
return GetParent()->SendMessage(WM_SETMESSAGESTRING,wParam,lParam);
return 0;
}
@@ -1,107 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// IEShellTreeView.cpp : implementation file
#include "stdafx.h"
#include "UIRes.h"
#include "UIMessages.h"
#include "IEShellTreeView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIEShellTreeView
IMPLEMENT_DYNCREATE(CIEShellTreeView,CUITreeView)
CIEShellTreeView::CIEShellTreeView()
: CUITreeView(IDC_TREE_SHELL)
{
m_bPopulated = false;
}
CIEShellTreeView::~CIEShellTreeView()
{
}
LPTVITEMDATA CIEShellTreeView::GetSelectedItemData()
{
HTREEITEM hItem = GetShellTreeCtrl().GetSelectedItem();
LPTVITEMDATA ptvid=NULL;
if (hItem)
ptvid = (LPTVITEMDATA)GetShellTreeCtrl().GetItemData(hItem);
return ptvid;
}
void CIEShellTreeView::OnInitialUpdate()
{
CUITreeView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
if (!m_bPopulated)
{
GetShellTreeCtrl().SetComboBoxWnd(GetParentFrame()->GetSafeHwnd());
PopulateTree(NULL);
}
}
bool CIEShellTreeView::PopulateTree(LPCTSTR pszPath)
{
CIEShellTreeCtrl *pCtrl = (CIEShellTreeCtrl*)m_pTreeCtrl;
m_bPopulated = pCtrl->LoadFolderItems(pszPath);
return m_bPopulated;
}
void CIEShellTreeView::CreateTreeCtrl()
{
// TODO: Add your specialized code here and/or call the base class
m_pTreeCtrl = new CIEShellTreeCtrl;
}
BEGIN_MESSAGE_MAP(CIEShellTreeView, CUITreeView)
//{{AFX_MSG_MAP(CIEShellTreeView)
ON_MESSAGE(WM_SETMESSAGESTRING,OnSetmessagestring)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIEShellTreeView message handlers
void CIEShellTreeView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
if (bActivate && pDeactiveView != NULL)
{
// theApp.SwitchTab(CViewTabView::TAB_LIST_FOLDER);
GetTreeCtrl().SetFocus();
}
CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
LRESULT CIEShellTreeView::OnSetmessagestring(WPARAM wParam, LPARAM lParam)
{
CFrameWnd *pFrame = GetParentFrame();
if (pFrame)
return pFrame->SendMessage(WM_SETMESSAGESTRING,wParam,lParam);
return 0;
}
@@ -1,156 +0,0 @@
// InPlaceEdit.cpp : implementation file
//
// Zafir Anjum
#include "stdafx.h"
#include "InPlaceEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit
CInPlaceEdit::CInPlaceEdit(int iItem, int iSubItem, CString sInitText)
:m_sInitText( sInitText )
{
m_iItem = iItem;
m_iSubItem = iSubItem;
m_bESC = FALSE;
}
CInPlaceEdit::~CInPlaceEdit()
{
}
BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit)
//{{AFX_MSG_MAP(CInPlaceEdit)
ON_WM_KILLFOCUS()
ON_WM_NCDESTROY()
ON_WM_CHAR()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit message handlers
BOOL CInPlaceEdit::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN )
{
if(pMsg->wParam == VK_RETURN
|| pMsg->wParam == VK_DELETE
|| pMsg->wParam == VK_ESCAPE
|| GetKeyState( VK_CONTROL)
)
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return TRUE; // DO NOT process further
}
}
return CEdit::PreTranslateMessage(pMsg);
}
void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
CString str;
GetWindowText(str);
// Send Notification to parent of ListView ctrl
LV_DISPINFO dispinfo;
dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
dispinfo.hdr.idFrom = GetDlgCtrlID();
dispinfo.hdr.code = LVN_ENDLABELEDIT;
dispinfo.item.mask = LVIF_TEXT;
dispinfo.item.iItem = m_iItem;
dispinfo.item.iSubItem = m_iSubItem;
dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
dispinfo.item.cchTextMax = str.GetLength();
GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(),
(LPARAM)&dispinfo );
DestroyWindow();
}
void CInPlaceEdit::OnNcDestroy()
{
CEdit::OnNcDestroy();
delete this;
}
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if( nChar == VK_ESCAPE || nChar == VK_RETURN)
{
if( nChar == VK_ESCAPE )
m_bESC = TRUE;
GetParent()->SetFocus();
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
// Resize edit control if needed
// Get text extent
CString str;
GetWindowText( str );
CWindowDC dc(this);
CFont *pFont = GetParent()->GetFont();
CFont *pFontDC = dc.SelectObject( pFont );
CSize size = dc.GetTextExtent( str );
dc.SelectObject( pFontDC );
size.cx += 5; // add some extra buffer
// Get client rect
CRect rect, parentrect;
GetClientRect( &rect );
GetParent()->GetClientRect( &parentrect );
// Transform rect to parent coordinates
ClientToScreen( &rect );
GetParent()->ScreenToClient( &rect );
// Check whether control needs to be resized
// and whether there is space to grow
if( size.cx > rect.Width() )
{
if( size.cx + rect.left < parentrect.right )
rect.right = rect.left + size.cx;
else
rect.right = parentrect.right;
MoveWindow( &rect );
}
}
int CInPlaceEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CEdit::OnCreate(lpCreateStruct) == -1)
return -1;
// Set the proper font
CFont* font = GetParent()->GetFont();
SetFont(font);
SetWindowText( m_sInitText );
SetFocus();
SetSel( 0, -1 );
return 0;
}
@@ -1,120 +0,0 @@
#ifndef __DIRWALK_H__
#define __DIRWALK_H__
////////////////////////////////////////////////
// CSplitPath
////////////////////////////////////////////////
class CTRL_EXT_CLASS CSplitPath
{
public:
CSplitPath(LPCTSTR pszPath);
CSplitPath();
virtual ~CSplitPath();
// operations
public:
void Split(LPCTSTR pszPath);
void Make();
// attributes
public:
CString GetPath() const;
CString GetDrive() const;
CString GetDir() const;
CString GetFileName() const;
CString GetExt() const;
void SetDrive(LPCTSTR pszDrive);
void SetDir(LPCTSTR pszDir);
void SetFileName(LPCTSTR pszFileName);
void SetExt(LPCTSTR pszExt);
protected:
void Init();
private:
TCHAR m_szPath[MAX_PATH];
TCHAR m_szDrive[_MAX_DRIVE];
TCHAR m_szDir[_MAX_DIR];
TCHAR m_szFname[_MAX_FNAME];
TCHAR m_szExt[_MAX_EXT];
};
inline CSplitPath::CSplitPath()
{
Init();
}
inline CSplitPath::CSplitPath(LPCTSTR pszPath)
{
Init();
Split(pszPath);
}
inline void CSplitPath::Init()
{
m_szPath[0] = 0;
m_szDrive[0] = 0;
m_szDir[0] = 0;
m_szFname[0] = 0;
m_szExt[0] = 0;
}
inline CSplitPath::~CSplitPath()
{
}
inline CString CSplitPath::GetPath() const
{
return m_szPath;
}
inline CString CSplitPath::GetDrive() const
{
return m_szDrive;
}
inline CString CSplitPath::GetDir() const
{
return m_szDir;
}
inline CString CSplitPath::GetFileName() const
{
return m_szFname;
}
inline CString CSplitPath::GetExt() const
{
return m_szExt;
}
inline void CSplitPath::SetDrive(LPCTSTR pszDrive)
{
lstrcpy(m_szDrive,pszDrive);
}
inline void CSplitPath::SetDir(LPCTSTR pszDir)
{
lstrcpy(m_szDir,pszDir);
}
inline void CSplitPath::SetFileName(LPCTSTR pszFileName)
{
lstrcpy(m_szFname,pszFileName);
}
inline void CSplitPath::SetExt(LPCTSTR pszExt)
{
lstrcpy(m_szExt,pszExt);
}
inline void CSplitPath::Split(LPCTSTR pszPath)
{
_tsplitpath(pszPath,m_szDrive,m_szDir,m_szFname,m_szExt);
}
inline void CSplitPath::Make()
{
_tmakepath(m_szPath,m_szDrive,m_szDir,m_szFname,m_szExt);
}
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
#endif //__DIRWALK_H__
@@ -1,42 +0,0 @@
////////////////////////////////////////////////////////////////
// Microsoft Systems Journal -- December 1999
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
//
#include "UIHtmlView.h"
class CTRL_EXT_CLASS CHtmlCtrl : public CUIHtmlView {
public:
CHtmlCtrl() { }
~CHtmlCtrl() { }
BOOL CreateFromStatic(UINT nID, CWnd* pParent);
// Normally, CHtmlView destroys itself in PostNcDestroy,
// but we don't want to do that for a control since a control
// is usually implemented as a stack object in a dialog.
//
virtual void PostNcDestroy() { }
// overrides to bypass MFC doc/view frame dependencies
afx_msg void OnDestroy();
afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg);
// override to trap "app:" pseudo protocol
virtual void OnBeforeNavigate2( LPCTSTR lpszURL,
DWORD nFlags,
LPCTSTR lpszTargetFrameName,
CByteArray& baPostedData,
LPCTSTR lpszHeaders,
BOOL* pbCancel );
// override to handle links to "app:mumble...". lpszWhere will be "mumble"
virtual void OnAppCmd(LPCTSTR lpszWhere);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
DECLARE_MESSAGE_MAP();
afx_msg LRESULT OnAppCbIeSelChange(WPARAM wParam, LPARAM lParam );
DECLARE_DYNAMIC(CHtmlCtrl)
};
@@ -1,128 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_IEFOLDERTREECTRL_H__9743E545_1F3A_11D2_A40D_9CB186000000__INCLUDED_)
#define AFX_IEFOLDERTREECTRL_H__9743E545_1F3A_11D2_A40D_9CB186000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// IEFolderTreeCtrl.h : header file
//
#include "ShellPidl.h"
#include "ShellSettings.h"
#include "Refresh.h"
#include "UITreeCtrl.h"
/////////////////////////////////////////////////////////////////////////////
// CIEFolderTreeCtrl window
#include <shlobj.h>
class CTRL_EXT_CLASS CIEFolderTreeCtrl : public CUITreeCtrl
{
// Construction
public:
CIEFolderTreeCtrl();
// Attributes
public:
CShellPidl &GetShellPidl();
CString GetRootPath();
void SetRootPath(const CString &sPath);
const CShellSettings &GetShellSettings() const;
CShellSettings &GetShellSettings();
virtual LPCITEMIDLIST GetPathPidl(HTREEITEM hItem);
virtual CString GetPathName(HTREEITEM hItem=NULL);
// Operations
public:
virtual void Sort(HTREEITEM hParent,LPSHELLFOLDER pFolder);
virtual void Refresh();
protected:
virtual LPSHELLFOLDER GetItemFolder(HTREEITEM hItem);
virtual HTREEITEM AddFolder(HTREEITEM hItem,LPITEMIDLIST pidl,LPSHELLFOLDER pFolder);
virtual HTREEITEM AddFolder(HTREEITEM hItem,LPCTSTR pszPath);
virtual bool LoadItems(LPCTSTR pszPath=NULL,DWORD dwFolderType=0);
virtual bool AddItems(HTREEITEM hItem,IShellFolder* pFolder);
virtual void OnDeleteItemData(DWORD dwData);
virtual void SetButtonState(HTREEITEM hItem);
virtual void RefreshNode(HTREEITEM hItem);
virtual void SetAttributes(HTREEITEM hItem,LPSHELLFOLDER pFolder,LPITEMIDLIST pidl);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIEFolderTreeCtrl)
public:
virtual void Init();
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType = adjustBorder);
//}}AFX_VIRTUAL
virtual BOOL LoadURL(HTREEITEM hItem);
// Implementation
public:
virtual ~CIEFolderTreeCtrl();
// Generated message map functions
protected:
static int CALLBACK CompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
//{{AFX_MSG(CIEFolderTreeCtrl)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDeleteItem(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg LRESULT OnSettingChange(WPARAM wParam,LPARAM lParam);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
IMalloc* m_pMalloc;
CShellPidl m_ShellPidl;
CString m_sRootPath;
HIMAGELIST m_hImageList;
CShellSettings m_ShellSettings;
};
inline const CShellSettings &CIEFolderTreeCtrl::GetShellSettings() const
{
return m_ShellSettings;
}
inline CShellSettings &CIEFolderTreeCtrl::GetShellSettings()
{
return m_ShellSettings;
}
inline CString CIEFolderTreeCtrl::GetRootPath()
{
return m_sRootPath;
}
inline void CIEFolderTreeCtrl::SetRootPath(const CString &sPath)
{
m_sRootPath = sPath;
}
inline CShellPidl &CIEFolderTreeCtrl::GetShellPidl()
{
return m_ShellPidl;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IEFOLDERTREECTRL_H__9743E545_1F3A_11D2_A40D_9CB186000000__INCLUDED_)
@@ -1,142 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_IESHELLCOMBOBOX_H__1EABA279_32DD_4A2D_8957_F478E4D3E5EB__INCLUDED_)
#define AFX_IESHELLCOMBOBOX_H__1EABA279_32DD_4A2D_8957_F478E4D3E5EB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// IEShellComboBox.h : header file
//
#include "ShellContextMenu.h"
#include "ShellPidl.h"
#include "Refresh.h"
////////////////////////////////////////////////
// CIEShellComboBoxEdit
////////////////////////////////////////////////
class CIEShellComboBoxEdit : public CEdit
{
public:
CIEShellComboBoxEdit();
virtual ~CIEShellComboBoxEdit();
public:
CString &GetText() { GetWindowText(m_sText); return m_sText; }
void SetTreeWnd(HWND hWnd);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
private:
CString m_sText;
HWND m_hTreeWnd;
};
inline CIEShellComboBoxEdit::CIEShellComboBoxEdit()
{
m_hTreeWnd = NULL;
}
inline CIEShellComboBoxEdit::~CIEShellComboBoxEdit()
{
}
inline void CIEShellComboBoxEdit::SetTreeWnd(HWND hWnd)
{
m_hTreeWnd = hWnd;
}
/////////////////////////////////////////////////////////////////////////////
// CIEShellComboBox window
class CTRL_EXT_CLASS CIEShellComboBox : public CComboBoxEx
{
// Construction
public:
CIEShellComboBox();
// Attributes
public:
CShellPidl &GetShellPidl() { return m_ShellPidl; }
LPITEMIDLIST GetSelectedPidl();
void SetTreeCtrlWnd(HWND hWnd) { m_hTreeWnd = hWnd; }
// Operations
public:
void Populate(LPITEMIDLIST pidlAbsSel=NULL);
protected:
void BuildFolderList(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl,LPITEMIDLIST pidlAbsSel,int nIndent);
void InitItems(LPITEMIDLIST pidlAbsSel);
void LoadItems(LPITEMIDLIST pidlAbsSel);
void LoadURLPrevList();
void SetShellImageList();
int AddItem(const CShCMSort *pItem);
void DeleteItemData(LPTVITEMDATA pItemData);
void DeleteAllItemData();
void AddItems(vecCMSort &vItems,IShellFolder* pFolder,LPITEMIDLIST pidlAbs,int nIndent);
void AddFolder(vecCMSort &vItems,const SHFILEINFO &FileInfo,LPITEMIDLIST pidlAbs,LPITEMIDLIST pidl,LPSHELLFOLDER pFolder,int nIndent);
void SelectionChanged(bool bEnter=false);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIEShellComboBox)
public:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CIEShellComboBox();
// Generated message map functions
protected:
//{{AFX_MSG(CIEShellComboBox)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnKillFocus(CWnd *pNewWnd);
afx_msg void OnSetFocus(CWnd *pWnd);
afx_msg void OnDropDown();
afx_msg void OnSelChange();
afx_msg LRESULT OnCBIEPopulate(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnAppCbIeHitEnter(WPARAM wParam, LPARAM lParam );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
LPMALLOC m_pMalloc;
LPITEMIDLIST m_pidlMyComputer;
LPITEMIDLIST m_pidlMyDocuments;
LPITEMIDLIST m_pidlInternet;
CShellPidl m_ShellPidl;
vecItemData m_vecItemData;
vecCMSort m_vItems;
HIMAGELIST m_hImageList;
CImageList m_ImageList;
HWND m_hTreeWnd;
HICON m_hIcon;
CIEShellComboBoxEdit m_cbEdit;
CString m_sText;
bool m_bInternet;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IESHELLCOMBOBOX_H__1EABA279_32DD_4A2D_8957_F478E4D3E5EB__INCLUDED_)
@@ -1,55 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __IESHELLDRAGDROP_H__
#define __IESHELLDRAGDROP_H__
#include "UIDragDropCtrl.h"
#include "ShellPidl.h"
////////////////////////////////////////////////
// CIEShellDragDrop
////////////////////////////////////////////////
class CIEShellDragDrop
{
public:
CIEShellDragDrop();
virtual ~CIEShellDragDrop();
public:
virtual bool DragDrop(CDD_OleDropTargetInfo *pInfo,LPSHELLFOLDER psfFolder,LPITEMIDLIST pidl);
virtual bool DragOver(CDD_OleDropTargetInfo *pInfo,LPSHELLFOLDER psfFolder,LPITEMIDLIST pidl);
virtual bool DragEnter(CDD_OleDropTargetInfo *pInfo,LPSHELLFOLDER psfFolder,LPITEMIDLIST pidl);
virtual bool DragLeave(CDD_OleDropTargetInfo *pInfo);
protected:
private:
CShellPidl m_ShellPidl;
LPSHELLFOLDER m_psfDesktop;
};
inline CIEShellDragDrop::CIEShellDragDrop()
{
m_psfDesktop = NULL;
SHGetDesktopFolder(&m_psfDesktop);
}
inline CIEShellDragDrop::~CIEShellDragDrop()
{
if (m_psfDesktop)
m_psfDesktop->Release();
}
#endif //__IESHELLDRAGDROP_H__
@@ -1,215 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __IESHELLLISTCTRL_H__
#define __IESHELLLISTCTRL_H__
#ifndef __AFXMT_H__
#include "afxmt.h"
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef struct SLC_COLUMN_DATA
{
SLC_COLUMN_DATA() { pidl = NULL; iImage = -1;}
CStringArray sItems;
LPITEMIDLIST pidl;
int iImage;
} SLC_COLUMN_DATA, *PSLC_COLUMN_DATA;
class CCF_HDROP;
// IEShellListCtrl.h : header file
//
#include <afxpriv.h>
#include "UICtrl.h"
#include "ShellPidl.h"
#include "ShellDetails.h"
#include "ShellSettings.h"
#include "Refresh.h"
#include "IEShellDragDrop.h"
/////////////////////////////////////////////////////////////////////////////
// CIEShellListCtrl window
#include <vector>
using namespace std;
typedef vector<LPLVITEMDATA> vecListItemData;
class CTRL_EXT_CLASS CIEShellListCtrl : public CUIODListCtrl
{
// Construction
public:
CIEShellListCtrl();
enum Cols
{
COL_NAME,
COL_SIZE,
COL_TYPE,
COL_MODIFIED,
COL_MAX
};
// Attributes
public:
void SetFileFilter(LPCTSTR pszFilter) { m_sFileFilter = pszFilter; }
CString GetFileFilter() { return m_sFileFilter.IsEmpty() ? _T("*.*") : m_sFileFilter; }
void SetNotifyParent(bool bNotifyParent) { m_bNotifyParent = bNotifyParent; }
void NoExtAllowed() { m_bNoExt = true; }
void ExcludeFileType(LPCTSTR pszType) { m_ExcludedLookup.AddHead(pszType); }
CStringList &GetExcludedFileTypes() { return m_ExcludedLookup; }
void FillExcludedFileTypes(CComboBox &cb);
void SetExcludedFileTypes(CComboBox &cb);
bool RefreshAllowed() { return m_bRefreshAllowed; }
void SetRefreshAllowed(bool bRefresh) { m_bRefreshAllowed = bRefresh; }
CShellPidl &GetShellPidl() { return m_ShellPidl; }
LPMALLOC GetMalloc() { return m_pMalloc; }
LPTVITEMDATA GetTVID() { return &m_tvid; }
LPSHELLFOLDER GetShellFolder() { return m_tvid.lpsfParent; }
bool GetCallBack() { return m_bCallBack; }
CString GetPathName(int nRow);
CString GetCurrPathName();
LPCITEMIDLIST GetPathPidl(int nRow);
const CShellSettings &GetShellSettings() const;
CShellSettings &GetShellSettings();
// Operations
public:
virtual void PopupTheMenu(int nRow,CPoint point);
virtual void ShellExecute(int nRow,LPCTSTR pszVerb=NULL);
virtual void SetNotificationObject(bool bNotify);
virtual BOOL Populate(LPTVITEMDATA lptvid,LPSHELLFOLDER psfFolder,bool bCallBack);
virtual BOOL Populate(LPCTSTR pszPath, bool bCallBack=false);
virtual BOOL Populate(LPTVITEMDATA lptvid);
virtual void Refresh();
virtual void StartPopulate();
virtual void EndPopulate();
// Overridables
protected:
virtual void DestroyThreads();
virtual void Load();
virtual void SetColumnWidths();
virtual void RemoveExt(LPTSTR pszFileName);
virtual void InitColumns();
virtual CString GetColumns();
virtual BOOL InitImageLists();
virtual BOOL InitItems(LPTVITEMDATA lptvid, bool bCallBack);
virtual void InitShellSettings();
virtual bool FilterItem(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl,UINT ulAttrs);
virtual bool GetColText(int nCol,LPCITEMIDLIST pidlAbs,LPLVITEMDATA lplvid,CString &sText);
virtual void GetText(PSLC_COLUMN_DATA pColData,LV_DISPINFO *pDispInfo,LPLVITEMDATA lplvid);
virtual void GetFileDetails(LPCITEMIDLIST pidl, CString &sSize, CString &sDateTime);
virtual void CreateFileChangeThread(HWND hwnd);
virtual void FreeTVID();
virtual void FreeInterface(IUnknown *pInterface);
virtual bool UseShellColumns();
virtual LPCTSTR GetFilterMask(LPCTSTR pszFilter,CString &sMask);
private:
void LoadFilterFiles(const CString &sFileFilter);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIEShellListCtrl)
public:
virtual void ChangeStyle(UINT &dwStyle);
virtual void Init();
protected:
virtual void GoBack(int nRow);
virtual void ShowPopupMenu(int nRow,int nCol,CPoint point);
virtual BOOL OnEnter(NM_LISTVIEW* pNMListView);
virtual BOOL DoubleClick(NM_LISTVIEW* pNMListView);
virtual void PreSubclassWindow();
virtual bool DragOver(CDD_OleDropTargetInfo *pInfo);
virtual bool DragLeave(CDD_OleDropTargetInfo *pInfo);
virtual bool DragEnter(CDD_OleDropTargetInfo *pInfo);
virtual bool DragDrop(CDD_OleDropTargetInfo *pInfo);
virtual BOOL GetDispInfo(LV_DISPINFO *pDispInfo);
virtual PFNLVCOMPARE GetCompareFunc();
virtual void AllItemsDeleted();
virtual DROPEFFECT DoDragDrop(int *pnRows,COleDataSource *pOleDataSource);
virtual bool EndLabelEdit(int nRow,int nCol,LPCTSTR pszText);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CIEShellListCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CIEShellListCtrl)
// NOTE - the ClassWizard will add and remove member functions here.
afx_msg void OnDestroy();
afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
afx_msg LRESULT OnAppFileChangeNewPath(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnAppFileChangeEvent(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnAppUpdateAllViews(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnSettingChange(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnSetmessagestring(WPARAM wParam, LPARAM lParam );
//}}AFX_MSG
afx_msg LRESULT OnAppDeleteKey(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnAppPropertiesKey(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
private:
static UINT ThreadFunc (LPVOID pParam);
enum { MAX_THREADS=1 };
vecListItemData m_vecItemData;
CShellPidl m_ShellPidl;
TVITEMDATA m_tvid;
LPSHELLFOLDER m_psfSubFolder;
LPITEMIDLIST m_pidlInternet;
IMalloc *m_pMalloc;
HANDLE m_hThreads[MAX_THREADS];
CWinThread *m_pThreads[MAX_THREADS];
CEvent m_event[MAX_THREADS];
CEvent m_MonitorEvent[MAX_THREADS];
CString m_sMonitorPath;
CIEShellDragDrop m_ShellDragDrop;
CShellDetails m_ShellDetails;
CShellSettings m_ShellSettings;
CString m_sColumns;
CString m_sFileFilter;
CStringList m_FilterLookup;
CStringList m_ExcludedLookup;
int m_nThreadCount;
bool m_bCallBack;
bool m_bNoExt;
bool m_bRefreshAllowed;
bool m_bPopulateInit;
bool m_bInitiliazed;
bool m_bNotifyParent;
};
/////////////////////////////////////////////////////////////////////////////
typedef struct FC_THREADINFO
{
HANDLE hEvent;
HANDLE hMonitorEvent;
CIEShellListCtrl *pListCtrl;
} FC_THREADINFO, *PFC_THREADINFO;
inline const CShellSettings &CIEShellListCtrl::GetShellSettings() const
{
return m_ShellSettings;
}
inline CShellSettings &CIEShellListCtrl::GetShellSettings()
{
return m_ShellSettings;
}
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //__IESHELLLISTCTRL_H__
@@ -1,81 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __IESHELLLISTVIEW_H__
#define __IESHELLLISTVIEW_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// IEShellListView.h : header file
//
#include "IEShellListCtrl.h"
#include "UIListView.h"
#include "HtmlCtrl.h"
/////////////////////////////////////////////////////////////////////////////
// CIEShellListView window
class CTRL_EXT_CLASS CIEShellListView : public CUIListView
{
// Construction
protected:
CIEShellListView();
DECLARE_DYNCREATE(CIEShellListView)
// Attributes
public:
CIEShellListCtrl &GetShellListCtrl();
// Operations
public:
// Overrides
protected:
virtual void LoadShellFolderItems(const CRefreshShellFolder &rFolder);
virtual void SetActiveWindow(CWnd *pWnd);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIEShellListView)
public:
virtual void CreateListCtrl();
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CIEShellListView();
// Generated message map functions
protected:
//{{AFX_MSG(CIEShellListView)
// NOTE - the ClassWizard will add and remove member functions here.
afx_msg LRESULT OnAppUpdateAllViews(WPARAM wParam,LPARAM lParam);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg LRESULT OnSetmessagestring(WPARAM wParam, LPARAM lParam );
//}}AFX_MSG
afx_msg LRESULT OnCBIESelChange(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnCBIEHitEnter(WPARAM wParam,LPARAM lParam);
DECLARE_MESSAGE_MAP()
private:
CWnd *m_pActiveWnd;
CHtmlCtrl m_htmlCtrl;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //__IESHELLLISTVIEW_H__
@@ -1,137 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __IESHELLTREECTRL_H__
#define __IESHELLTREECTRL_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXMT_H__
#include "afxmt.h"
#endif
// IEShellTreeCtrl.h : header file
//
#include <afxpriv.h>
#include "IEFolderTreeCtrl.h"
#include "IEShellDragDrop.h"
/////////////////////////////////////////////////////////////////////////////
// CIEShellTreeCtrl window
class CTRL_EXT_CLASS CIEShellTreeCtrl : public CIEFolderTreeCtrl
{
// Construction
public:
CIEShellTreeCtrl();
// Attributes
public:
void SetNotifyParent(bool bNotifyParent) { m_bNotifyParent = bNotifyParent; }
bool RefreshAllowed() { return m_bRefreshAllowed; }
void SetRefreshAllowed(bool bRefresh) { m_bRefreshAllowed = bRefresh; }
void SetListCtrlWnd(HWND hWnd) { m_hListWnd = hWnd; }
void SetComboBoxWnd(HWND hWnd) { m_hComboWnd = hWnd; }
CString GetSelectedPath() { return GetPathName(); }
// Operations
public:
virtual void UpOneLevel(HTREEITEM hItem=NULL);
virtual void ShellExecute(HTREEITEM hItem,LPCTSTR pszVerb=NULL);
virtual void SetNotificationObject(bool bNotify);
virtual bool LoadFolderItems(LPCTSTR pszPath=NULL);
virtual bool GetFolderInfo(HTREEITEM hItem,CString &sPath,CString &sName);
virtual void Refresh();
virtual HTREEITEM FindPidl(LPITEMIDLIST pidlAbs,BOOL bSelect=TRUE);
virtual HTREEITEM ExpandPidl(LPITEMIDLIST pidlAbs);
virtual HTREEITEM ExpandMyComputer(LPITEMIDLIST pidlAbs);
// Overrides
protected:
virtual void RefreshComboBox(LPTVITEMDATA lptvid);
virtual void DestroyThreads();
virtual void CreateFileChangeThreads(HWND hwnd);
virtual void CreateFileChangeThread (const CString& sPath,HWND hwnd);
virtual HTREEITEM SearchSiblings(HTREEITEM hItem,LPITEMIDLIST pidlAbs);
virtual HTREEITEM FindItem(HTREEITEM hItem, const CString& strTarget);
virtual UINT DeleteChildren(HTREEITEM hItem);
virtual bool SHMoveFile(HTREEITEM hSrcItem,HTREEITEM hDestItem);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIEShellTreeCtrl)
virtual BOOL OnWndMsg( UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult );
virtual bool Expanding(NM_TREEVIEW *nmtvw);
virtual CRefresh *CreateRefreshObject(HTREEITEM hItem,LPARAM lParam);
virtual DROPEFFECT DoDragDrop(NM_TREEVIEW* pNMTreeView,COleDataSource *pOleDataSource);
virtual bool EndLabelEdit(HTREEITEM hItem,LPCTSTR pszText);
virtual BOOL TransferItem(HTREEITEM hitemDrag, HTREEITEM hitemDrop);
protected:
virtual void Init();
virtual void ShowProperties(HTREEITEM hItem);
virtual void ShowPopupMenu(HTREEITEM hItem,CPoint point);
virtual void DoubleClick(HTREEITEM hItem);
virtual void DeleteKey(HTREEITEM hItem);
virtual void GoBack(HTREEITEM hItem);
virtual void PreSubclassWindow();
virtual void UpdateEvent(LPARAM lHint,CObject *pHint);
virtual bool DragDrop(CDD_OleDropTargetInfo *pInfo);
virtual bool DragOver(CDD_OleDropTargetInfo *pInfo);
virtual bool DragEnter(CDD_OleDropTargetInfo *pInfo);
virtual bool DragLeave(CDD_OleDropTargetInfo *pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CIEShellTreeCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CIEShellTreeCtrl)
// NOTE - the ClassWizard will add and remove member functions here.
afx_msg BOOL OnRclick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDestroy();
afx_msg LRESULT OnAppDirChangeEvent(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnCBIESelChange(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnAppPopulateTree(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppCbIeHitEnter(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnSetmessagestring(WPARAM wParam, LPARAM lParam );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
enum { MAX_THREADS=32 };
static UINT ThreadFunc (LPVOID pParam);
LPTVITEMDATA m_lptvid;
HANDLE m_hThreads[MAX_THREADS];
CWinThread *m_pThreads[MAX_THREADS];
CEvent m_event[MAX_THREADS];
int m_nThreadCount;
bool m_bRefreshAllowed;
bool m_bNotifyParent;
CIEShellDragDrop m_ShellDragDrop;
HWND m_hListWnd;
HWND m_hComboWnd;
};
/////////////////////////////////////////////////////////////////////////////
typedef struct DC_THREADINFO
{
HANDLE hEvent;
CIEShellTreeCtrl *pTreeCtrl;
CString sPath;
} DC_THREADINFO, *PDC_THREADINFO;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //__IESHELLTREECTRL_H__
@@ -1,84 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __IESHELLTREEVIEW_H__
#define __IESHELLTREEVIEW_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// IEShellTreeView.h : header file
//
#include "IEShellTreeCtrl.h"
#include "UITreeView.h"
/////////////////////////////////////////////////////////////////////////////
// CIEShellTreeView window
class CTRL_EXT_CLASS CIEShellTreeView : public CUITreeView
{
// Construction
protected:
CIEShellTreeView();
DECLARE_DYNCREATE(CIEShellTreeView)
// Attributes
public:
CIEShellTreeCtrl &GetShellTreeCtrl();
void SetPath(LPCTSTR pszPath);
LPTVITEMDATA GetSelectedItemData();
// Operations
public:
// Overrides
virtual bool PopulateTree(LPCTSTR pszPath);
protected:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIEShellTreeView)
virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
virtual void CreateTreeCtrl();
virtual void OnInitialUpdate();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CIEShellTreeView();
// Generated message map functions
protected:
//{{AFX_MSG(CIEShellTreeView)
// NOTE - the ClassWizard will add and remove member functions here.
afx_msg LRESULT OnSetmessagestring(WPARAM wParam, LPARAM lParam );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
bool m_bPopulated;
CString m_sPath;
};
/////////////////////////////////////////////////////////////////////////////
inline void CIEShellTreeView::SetPath(LPCTSTR pszPath)
{
m_sPath = pszPath;
}
inline CIEShellTreeCtrl &CIEShellTreeView::GetShellTreeCtrl()
{
return static_cast<CIEShellTreeCtrl&>(GetTreeCtrl());
}
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //__IESHELLTREEVIEW_H__
@@ -1,49 +0,0 @@
#ifndef __INPLACEEDIT_H__
#define __INPLACEEDIT_H__
/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit window
// Zafir Anjum
class CInPlaceEdit : public CEdit
{
// Construction
public:
CInPlaceEdit(int iItem, int iSubItem, CString sInitText);
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CInPlaceEdit)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CInPlaceEdit();
// Generated message map functions
protected:
//{{AFX_MSG(CInPlaceEdit)
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnNcDestroy();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
int m_iItem;
int m_iSubItem;
CString m_sInitText;
BOOL m_bESC; // To indicate whether ESC key was pressed
};
/////////////////////////////////////////////////////////////////////////////
#endif //__INPLACEEDIT_H__
@@ -1,111 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// LocaleInfo.h: interface for the CLocaleInfo class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_LOCALEINFO_H__53D6820E_C28F_4DB9_AB7D_87B9E8EAE233__INCLUDED_)
#define AFX_LOCALEINFO_H__53D6820E_C28F_4DB9_AB7D_87B9E8EAE233__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CTRL_EXT_CLASS CLocaleInfo
{
public:
CLocaleInfo();
virtual ~CLocaleInfo();
public:
// Properties
LPCTSTR GetNegativeSign() const;
LPCTSTR GetDecimalSep() const;
LPCTSTR GetThousandSep() const;
LPCTSTR GetLongDate() const;
LPCTSTR GetShortDate() const;
LPCTSTR GetShortTime() const;
LPCTSTR GetLongTime() const;
LPCTSTR GetDateSep() const;
LPCTSTR GetTimeSep() const;
CString ConvertStdToWinFormat(LPCTSTR pszFormat);
CString FormatDateTime(const COleDateTime &oleDateTime);
CString FormatDateTime(const FILETIME &ft);
protected:
void StdToWinFormatCode(CString &sCode);
void GetAllLocaleInfo();
void AllocLocaleInfo(LCTYPE lctype,LPTSTR *pszInfo);
private:
LPTSTR m_pszNegativeSign;
LPTSTR m_pszDecimalSep;
LPTSTR m_pszThousandSep;
LPTSTR m_pszLongDate;
LPTSTR m_pszShortDate;
LPTSTR m_pszLongTime;
LPTSTR m_pszShortTime;
LPTSTR m_pszDateSep;
LPTSTR m_pszTimeSep;
public:
static CLocaleInfo *CLocaleInfo::Instance();
};
inline LPCTSTR CLocaleInfo::GetNegativeSign() const
{
return m_pszNegativeSign;
}
inline LPCTSTR CLocaleInfo::GetDecimalSep() const
{
return m_pszDecimalSep;
}
inline LPCTSTR CLocaleInfo::GetThousandSep() const
{
return m_pszThousandSep;
}
inline LPCTSTR CLocaleInfo::GetLongDate() const
{
return m_pszLongDate;
}
inline LPCTSTR CLocaleInfo::GetShortTime() const
{
return m_pszShortTime;
}
inline LPCTSTR CLocaleInfo::GetLongTime() const
{
return m_pszLongTime;
}
inline LPCTSTR CLocaleInfo::GetShortDate() const
{
return m_pszShortDate;
}
inline LPCTSTR CLocaleInfo::GetDateSep() const
{
return m_pszDateSep;
}
inline LPCTSTR CLocaleInfo::GetTimeSep() const
{
return m_pszTimeSep;
}
#endif // !defined(AFX_LOCALEINFO_H__53D6820E_C28F_4DB9_AB7D_87B9E8EAE233__INCLUDED_)
@@ -1,108 +0,0 @@
////////////////////////////////////////////////////////////////////
// PIDL.h: interface for the CPIDL class.
//
#ifndef __PIDL_H
#define __PIDL_H
#include <shlobj.h>
class CPIDL
{
public:
LPITEMIDLIST m_pidl;
// == Construction/Destruction == //
CPIDL() : m_pidl(NULL) {}
// Copy constructor
CPIDL(const CPIDL& cpidl) : m_pidl(NULL) { Set(cpidl); }
// From path (szPath relative to the folder psf) - see Set()
CPIDL(LPCTSTR szPath, LPSHELLFOLDER psf = m_sfDesktop);
// From a list ptr - *doesn't* copy the actual data - see Set()
CPIDL(LPITEMIDLIST pidl) : m_pidl(pidl) {}
virtual ~CPIDL();
// == Assignment == //
// Make a copy of cpidl's list data
HRESULT Set(const CPIDL& cpidl);
// Set by path: szPath relative to the folder psf.
HRESULT Set(LPCTSTR szPath, LPSHELLFOLDER psf = m_sfDesktop);
// Points the CPIDL to an existing item list: does *not* copy
// the actual data - just the pointer (unlike MakeCopyOf()).
HRESULT Set(LPITEMIDLIST pidl);
// Special Assignment: Copies the data of an exisiting list.
HRESULT MakeCopyOf(LPITEMIDLIST pidl);
// Special Assignment: Makes a PIDL rooted at the desktop.
HRESULT MakeAbsPIDLOf(LPSHELLFOLDER psf, LPITEMIDLIST pidl);
// == Item Access == //
// Returns a pointer to the first item in the list
LPSHITEMID GetFirstItemID() const { return (LPSHITEMID)m_pidl; }
// Points to the next item in the list
void GetNextItemID(LPSHITEMID& pid) const
{ (LPBYTE &)pid += pid->cb; }
// == General Operations == //
void Free(); // Frees the memory used by the item id list
UINT GetSize() const; // Counts the actual memory in use
// Split into direct parent and object pidls
void Split(CPIDL& parent, CPIDL& obj) const;
// Concatenation
CPIDL operator + (CPIDL& pidl) const; // using + operator
static void Concat(const CPIDL &a, const CPIDL& b,
CPIDL& result); // result = a+b (faster)
// == Shell Name-space Access Helper Functions == //
// 1) Won't always work: psf->GetUIObjectOf(pidl, ... )
// 2) Will always work: pidl.GetUIObjectOf(..., psf)
HRESULT GetUIObjectOf(REFIID riid, LPVOID *ppvOut,
HWND hWnd = NULL, LPSHELLFOLDER psf = m_sfDesktop);
// Places the STRRET string in the cStr field.
void ExtractCStr(STRRET& strRet) const;
// == Conversion Operators == //
operator LPITEMIDLIST& () { return m_pidl; }
operator LPITEMIDLIST * () { return &m_pidl; }
operator LPCITEMIDLIST () const { return m_pidl; }
operator LPCITEMIDLIST* () const
{ return (LPCITEMIDLIST *)&m_pidl; }
protected:
static LPSHELLFOLDER m_sfDesktop; // desktop object
static LPMALLOC m_pAllocator; // system allocator
// allocate memory for the pidl using the system allocator
void AllocMem(int iAllocSize);
// initializer (used for automatic initialization)
static struct pidl_initializer {
pidl_initializer();
~pidl_initializer();
} m_initializer;
friend struct pidl_initializer;
};
#endif // __PIDL_H
@@ -1,68 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __REFRESH_H__
#define __REFRESH_H__
#include "UIFolderRefresh.h"
// SHELL ITEM DATA STRUCTURES
// List Control
typedef struct tagLVID
{
LPSHELLFOLDER lpsfParent;
LPITEMIDLIST lpi;
LPITEMIDLIST lpifq;
ULONG ulAttribs;
LPARAM lParam;
} LVITEMDATA, *LPLVITEMDATA;
// Tree Control
typedef struct tagTVID
{
LPSHELLFOLDER lpsfParent;
LPITEMIDLIST lpi;
LPITEMIDLIST lpifq;
LPARAM lParam;
} TVITEMDATA, *LPTVITEMDATA;
#include <vector>
using namespace std;
typedef vector<LPTVITEMDATA> vecItemData;
class CRefreshIEFolder : public CRefresh
{
private:
CRefreshIEFolder(const CRefreshIEFolder &rRefresh);
CRefreshIEFolder &operator=(const CRefreshIEFolder &rRefresh);
public:
CRefreshIEFolder(HTREEITEM hItem,LPARAM lParam) : CRefresh(hItem,lParam) {}
LPTVITEMDATA GetItemData() const { return (LPTVITEMDATA)GetExtData(); }
};
class CRefreshShellFolder : public CRefresh
{
private:
CRefreshShellFolder(const CRefreshShellFolder &rRefresh);
CRefreshShellFolder &operator=(const CRefreshShellFolder &rRefresh);
public:
CRefreshShellFolder(HTREEITEM hItem,LPARAM lParam) : CRefresh(hItem,lParam) {}
LPTVITEMDATA GetItemData() const { return (LPTVITEMDATA)GetExtData(); }
};
#endif //__REFRESH_H__
@@ -1,21 +0,0 @@
#ifndef __SEASHELLEXT_H__
#define __SEASHELLEXT_H__
#ifdef _DEBUG
#pragma warning(disable : 4127)
#endif
#pragma warning(disable : 4514)
#pragma warning(disable : 4710)
#pragma warning(disable : 4786)
#pragma warning(disable : 4511 4512)
#include <afxole.h>
#include <afxtempl.h>
#include <afxinet.h>
#include <afxmt.h>
#include <atlbase.h>
#include "W2KFix.h"
#define CTRL_EXT_CLASS
#endif //__SEASHELLEXT_H__
@@ -1,381 +0,0 @@
/***************************************************************************/
/* NOTE: */
/* This document is copyright (c) by Oz Solomonovich. All non-commercial */
/* use is allowed, as long as this document is not altered in any way, and */
/* due credit is given. */
/***************************************************************************/
// ShellContextMenu.h : header file
//
#if !defined(AFX_SHELLCONTEXTMENU_H__24BAC666_2B03_11D3_B9C1_0000861DFCE7__INCLUDED_)
#define AFX_SHELLCONTEXTMENU_H__24BAC666_2B03_11D3_B9C1_0000861DFCE7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//#define USESTL
#if defined USESTL
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<CMenu*> vecODMenu;
#define STL_FOR_ITERATOR(t,v) for(t::iterator it=v.begin();it != v.end();it++)
#define STL_ERASE_ALL(v) v.erase(v.begin(),v.end())
#define STL_GET_CURRENT(v) *it
#define STL_ADD_ITEM(v,i) v.push_back(i);
#define STL_EMPTY(v) v.empty()
#define STL_SORT(v,f,c) TRACE0("Sorting with STL\n"); is_less_than_pidl::psf = f; sort(v.begin(),v.end(),c);
#else
#include <afxtempl.h>
typedef CArray<CMenu*,CMenu*> vecODMenu;
#define STL_FOR_ITERATOR(t,v) for (int i=0;i < v.GetSize();i++)
#define STL_ERASE_ALL(v) v.RemoveAll()
#define STL_GET_CURRENT(v) v.GetAt(i)
#define STL_ADD_ITEM(v,i) v.Add(i);
#define STL_EMPTY(v) v.GetSize() == 0
#define STL_SORT(v,f,c) TRACE0("Sorting with MFC\n"); is_less_than_pidl::psf = f; qsort(v.GetData(),v.GetSize(),sizeof(void*),c);
#endif
#include "PIDL.h"
class CShellContextMenu
{
LPCONTEXTMENU m_lpcm;
LPSHELLFOLDER m_psfParent;
LPITEMIDLIST m_pidl;
LPITEMIDLIST *m_ppidl;
UINT m_cidl;
CString m_sAbsPath;
HWND m_hWnd;
CMenu * m_pSendToMenu;
vecODMenu m_OwnerDrawMenus;
CSize m_szOldButtonSize;
public:
CShellContextMenu(HWND m_hWnd, const CString &sAbsPath, LPITEMIDLIST *ppidl, UINT cidl, LPSHELLFOLDER psfParent);
~CShellContextMenu();
bool IsMenuCommand(int iCmd) const;
void InvokeCommand(int iCmd) const;
void CShellContextMenu::SetMenu(CMenu *pMenu);
protected:
void AddKey(CString &sDestKey,const CString &sSrcKey) const;
CString GetExt(const CString &sPath) const;
void GetAppDetails(const CString &sAppName,CString &sDisplayName,CString &sCommand,HICON &hAppIcon) const;
void CShellContextMenu::FillSendToMenu(CMenu *pMenu,
LPSHELLFOLDER pSF, UINT &idm);
void FillOpenWithMenu(CMenu *pMenu,const CString &sExt);
};
/////////////////////////////////////////////////////////////////////////////
// Addition: Philip Oldaker
// Maybe overkill to sort the SendTo menu but could be useful
/////////////////////////////////////////////////////////////////////////////
class CShCMSort
{
public:
CShCMSort(UINT nID,LPITEMIDLIST pidl,HICON hIcon,const CString &sText,DWORD dwItemData);
CShCMSort();
~CShCMSort();
CShCMSort(const CShCMSort &rOther);
const CShCMSort &operator=(const CShCMSort &rOther);
// Properties
void SetIndent(int nIndent);
int GetIndent() const;
public:
void SetImage(int nImage);
int GetImage() const;
void SetSelImage(int nSelImage);
int GetSelImage() const;
void SetOverlayImage(int nOverlayImage);
int GetOverlayImage() const;
void SetPidl(LPITEMIDLIST pidl);
const LPITEMIDLIST GetPidl() const;
void SetIcon(HICON hIcon);
HICON GetIcon() const;
void SetItemID(UINT nID);
UINT GetItemID() const;
void SetText(const CString &sText);
const CString &GetText() const;
void SetItemData(DWORD dwItemData);
DWORD GetItemData() const;
private:
// relative pidl
LPITEMIDLIST m_pidl;
int m_nIndent;
int m_nImage;
int m_nSelImage;
int m_nOverlayImage;
HICON m_hIcon;
UINT m_ID;
CString m_sText;
DWORD m_dwItemData;
};
inline void CShCMSort::SetIndent(int nIndent)
{
m_nIndent = nIndent;
}
inline int CShCMSort::GetIndent() const
{
return m_nIndent;
}
inline void CShCMSort::SetImage(int nImage)
{
m_nImage = nImage;
}
inline int CShCMSort::GetImage() const
{
return m_nImage;
}
inline void CShCMSort::SetSelImage(int nSelImage)
{
m_nSelImage = nSelImage;
}
inline int CShCMSort::GetSelImage() const
{
return m_nSelImage;
}
inline void CShCMSort::SetOverlayImage(int nOverlayImage)
{
m_nOverlayImage = nOverlayImage;
}
inline int CShCMSort::GetOverlayImage() const
{
return m_nOverlayImage;
}
inline CShCMSort::CShCMSort()
{
m_ID = 0;
m_dwItemData = 0;
m_pidl = NULL;
m_hIcon = NULL;
m_nIndent = 0;
m_nImage = 0;
m_nSelImage = 0;
m_nOverlayImage = 0;
}
inline CShCMSort::CShCMSort(UINT nID,LPITEMIDLIST pidl,HICON hIcon,const CString &sText,DWORD dwItemData)
: m_ID(nID),
m_pidl(pidl),
m_hIcon(hIcon),
m_sText(sText),
m_dwItemData(dwItemData)
{
}
inline CShCMSort::~CShCMSort()
{
}
inline CShCMSort::CShCMSort(const CShCMSort &rOther)
: m_pidl(rOther.m_pidl),
m_hIcon(rOther.m_hIcon),
m_ID(rOther.m_ID),
m_sText(rOther.m_sText),
m_dwItemData(rOther.m_dwItemData),
m_nIndent(rOther.m_nIndent),
m_nImage(rOther.m_nImage),
m_nSelImage(rOther.m_nSelImage),
m_nOverlayImage(rOther.m_nOverlayImage)
{
}
inline const CShCMSort &CShCMSort::operator=(const CShCMSort &rOther)
{
if (this == &rOther)
return *this;
m_pidl = rOther.m_pidl;
m_hIcon = rOther.m_hIcon;
m_ID = rOther.m_ID;
m_sText = rOther.m_sText;
m_dwItemData = rOther.m_dwItemData;
m_nIndent = rOther.m_nIndent;
m_nImage = rOther.m_nImage;
m_nSelImage = rOther.m_nSelImage;
m_nOverlayImage = rOther.m_nOverlayImage;
return *this;
}
inline void CShCMSort::SetPidl(LPITEMIDLIST pidl)
{
m_pidl = pidl;
}
inline const LPITEMIDLIST CShCMSort::GetPidl() const
{
return m_pidl;
}
inline void CShCMSort::SetIcon(HICON hIcon)
{
m_hIcon = hIcon;
}
inline HICON CShCMSort::GetIcon() const
{
return m_hIcon;
}
inline void CShCMSort::SetItemID(UINT nID)
{
m_ID = nID;
}
inline UINT CShCMSort::GetItemID() const
{
return m_ID;
}
inline void CShCMSort::SetText(const CString &sText)
{
m_sText = sText;
}
inline const CString &CShCMSort::GetText() const
{
return m_sText;
}
inline void CShCMSort::SetItemData(DWORD dwItemData)
{
m_dwItemData = dwItemData;
}
inline DWORD CShCMSort::GetItemData() const
{
return m_dwItemData;
}
// STL predicate helpers
// sort by pidl
class is_less_than_pidl
{
public:
is_less_than_pidl() {}
// STL
bool operator()(const CShCMSort *x,const CShCMSort *y)
{
return ComparePidls(x,y) < 0;
}
int ComparePidls(const CShCMSort *x,const CShCMSort *y)
{
ASSERT(is_less_than_pidl::psf);
HRESULT hr = is_less_than_pidl::psf->CompareIDs(0, x->GetPidl(), y->GetPidl());
if (FAILED(hr))
return 0;
return (short)hr;
}
// MFC
static int compare(const void *x, const void *y)
{
const CShCMSort *x1 = *(const CShCMSort**)x;
const CShCMSort *y1 = *(const CShCMSort**)y;
return is_less_than_pidl().ComparePidls(x1,y1);
}
public:
CTRL_EXT_CLASS static LPSHELLFOLDER psf;
};
class is_greater_than_pidl
{
public:
is_greater_than_pidl() { }
// STL
bool operator()(const CShCMSort *x,const CShCMSort *y)
{
return ComparePidls(x,y) > 0;
}
int ComparePidls(const CShCMSort *x,const CShCMSort *y)
{
HRESULT hr = is_greater_than_pidl::psf->CompareIDs(0, x->GetPidl(), y->GetPidl());
if (FAILED (hr))
return 0;
return (short)hr;
}
// MFC
static int compare(const void *x, const void *y)
{
const CShCMSort *x1 = *(const CShCMSort**)x;
const CShCMSort *y1 = *(const CShCMSort**)y;
return is_greater_than_pidl().ComparePidls(x1,y1);
}
public:
CTRL_EXT_CLASS static LPSHELLFOLDER psf;
};
// sort by text
class is_less_than_text
{
public:
// STL
bool operator()(const CShCMSort *x,const CShCMSort *y)
{
return CompareText(x,y) < 0;
}
int CompareText(const CShCMSort *x,const CShCMSort *y)
{
return x->GetText() < y->GetText();
}
// MFC
static int compare(const void *x, const void *y)
{
const CShCMSort *x1 = *(const CShCMSort**)x;
const CShCMSort *y1 = *(const CShCMSort**)y;
return is_less_than_text().CompareText(x1,y1);
}
};
class is_greater_than_text
{
public:
// STL
bool operator()(const CShCMSort *x,const CShCMSort *y)
{
return CompareText(x,y) < 0;
}
int CompareText(const CShCMSort *x,const CShCMSort *y)
{
return x->GetText() > y->GetText();
}
// MFC
static int compare(const void *x, const void *y)
{
const CShCMSort *x1 = *(const CShCMSort**)x;
const CShCMSort *y1 = *(const CShCMSort**)y;
return is_greater_than_text().CompareText(x1,y1);
}
};
#if defined USESTL
typedef vector<CShCMSort*> vecCMSort;
#define STL_SORT_FUNC is_less_than_pidl()
#else
typedef CArray<CShCMSort*,CShCMSort*> vecCMSort;
#define STL_SORT_FUNC is_less_than_pidl::compare
#endif
/////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SHELLCONTEXTMENU_H__24BAC666_2B03_11D3_B9C1_0000861DFCE7__INCLUDED_)
@@ -1,43 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __SHELLDETAILS_H__
#define __SHELLDETAILS_H__
////////////////////////////////////////////////
// CShellDetails
////////////////////////////////////////////////
class CShellDetails
{
public:
CShellDetails(const CShellDetails &rOther);
const CShellDetails &operator=(const CShellDetails &rOther);
CShellDetails();
virtual ~CShellDetails();
// Attributes
void SetShellDetails(IUnknown *pUnk);
bool IsValidDetails();
// Operations
HRESULT GetDetailsOf(LPCITEMIDLIST pidl,UINT iColumn,LPSHELLDETAILS pDetail);
protected:
void FreeInterfaces();
private:
IUnknown *m_pUnk;
};
#endif //__SHELLDETAILS_H__
@@ -1,158 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// ShellPidl.h: interface for the CShellPidl class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)
#define AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Refresh.h"
class CTRL_EXT_CLASS CShellPidl
{
public:
CShellPidl();
virtual ~CShellPidl();
public:
virtual BOOL PopupTheMenu(HWND hwnd, LPSHELLFOLDER lpsfParent, LPITEMIDLIST *lpi, UINT cidl, LPPOINT lppt);
virtual BOOL HandleMenuMsg(HWND hwnd, LPSHELLFOLDER lpsfParent,
LPITEMIDLIST lpi, UINT uMsg, WPARAM wParam, LPARAM lParam);
#ifdef _UNICODE
STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
#else
STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
#endif
STDMETHOD(ResolveChannel)(IShellFolder* pFolder, LPCITEMIDLIST pidl, LPTSTR* lpszURL);
STDMETHOD(ResolveHistoryShortcut)(LPSHELLFOLDER pFolder,LPCITEMIDLIST *ppidl,CString &sURL);
STDMETHOD(ResolveInternetShortcut)(LPCTSTR lpszLinkFile, LPTSTR* lpszURL);
STDMETHOD(ResolveLink)(HWND hWnd,LPCTSTR lpszLinkFile, LPTSTR* lpszPath);
STDMETHOD(SHPathToPidlEx)(LPCTSTR szPath, LPITEMIDLIST* ppidl, LPSHELLFOLDER pFolder=NULL);
STDMETHOD(SHPidlToPathEx)(LPCITEMIDLIST pidl, CString &sPath, LPSHELLFOLDER pFolder=NULL,DWORD dwFlags=SHGDN_FORPARSING);
LPITEMIDLIST CopyItemIDList(LPITEMIDLIST pidl);
LPITEMIDLIST CopyItemID(LPITEMIDLIST pidl,int n=0);
LPITEMIDLIST CopyLastItemID(LPITEMIDLIST pidl);
LPITEMIDLIST CopyAbsItemID(LPITEMIDLIST pidl,int n);
LPITEMIDLIST ConcatPidl(LPITEMIDLIST pidlDest,LPITEMIDLIST pidlSrc);
LPITEMIDLIST Next(LPCITEMIDLIST pidl);
LPSHELLFOLDER GetFolder(LPITEMIDLIST pidl);
LPSHELLFOLDER GetDesktopFolder();
LPCITEMIDLIST GetEmptyPidl();
bool IsDesktopFolder(LPSHELLFOLDER psFolder);
DWORD GetDragDropAttributes(COleDataObject *pDataObject);
DWORD GetDragDropAttributes(LPTVITEMDATA ptvid);
DWORD GetDragDropAttributes(LPLVITEMDATA plvid);
DWORD GetDragDropAttributes(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl);
UINT GetSize(LPCITEMIDLIST pidl);
UINT GetCount(LPCITEMIDLIST pidl);
void GetTypeName(LPITEMIDLIST lpi,CString &sTypeName);
void GetDisplayName(LPITEMIDLIST lpi,CString &sDisplayName);
int GetIcon(LPITEMIDLIST lpi, UINT uFlags);
void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, int &iImage, int &iSelectedImage);
BOOL GetName (LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, CString &sFriendlyName);
bool ComparePidls(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2);
bool CompareMemPidls(LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2);
IMalloc *GetMalloc();
void FreePidl(LPITEMIDLIST pidl);
void Free(void *pv);
protected:
STDMETHOD(GetURL)(IDataObject *pDataObj,CString &sURL);
private:
ITEMIDLIST m_EmptyPidl;
LPMALLOC m_pMalloc;
LPSHELLFOLDER m_psfDesktop;
};
////////////////////////////////////////////////
// CShellPidlCompare
////////////////////////////////////////////////
class CShellPidlCompare
{
public:
CShellPidlCompare(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl);
CShellPidlCompare(const CShellPidlCompare &rOther);
const CShellPidlCompare &operator=(const CShellPidlCompare &rOther);
bool operator==(const CShellPidlCompare &rhs) const;
bool operator<(const CShellPidlCompare &rhs) const;
virtual ~CShellPidlCompare();
LPCITEMIDLIST GetPidl() const;
LPSHELLFOLDER GetFolder() const;
public:
protected:
private:
LPITEMIDLIST m_pidl;
LPSHELLFOLDER m_pFolder;
};
inline CShellPidlCompare::CShellPidlCompare(const CShellPidlCompare &rOther)
: m_pidl(rOther.m_pidl),
m_pFolder(rOther.m_pFolder)
{
}
inline bool CShellPidlCompare::operator==(const CShellPidlCompare &rhs) const
{
HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
return (short)hr == 0;
}
inline bool CShellPidlCompare::operator<(const CShellPidlCompare &rhs) const
{
HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
return (short)hr < 0;
}
inline const CShellPidlCompare &CShellPidlCompare::operator=(const CShellPidlCompare &rOther)
{
if (this == &rOther)
return *this;
m_pidl = rOther.m_pidl;
m_pFolder = rOther.m_pFolder;
return *this;
}
inline CShellPidlCompare::CShellPidlCompare(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl)
: m_pidl(pidl),
m_pFolder(pFolder)
{
}
inline CShellPidlCompare::~CShellPidlCompare()
{
}
inline LPCITEMIDLIST CShellPidlCompare::GetPidl() const
{
return m_pidl;
}
inline LPSHELLFOLDER CShellPidlCompare::GetFolder() const
{
return m_pFolder;
}
#endif // !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)
@@ -1,57 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __SHELLSETTINGS_H__
#define __SHELLSETTINGS_H__
////////////////////////////////////////////////
// CShellSettings
////////////////////////////////////////////////
class CShellSettings
{
public:
CShellSettings();
virtual ~CShellSettings();
public:
// attributes
bool DesktopHTML() const { return m_sfs.fDesktopHTML != 0; }
bool DontPrettyPath() const { return m_sfs.fDontPrettyPath != 0; }
bool DoubleClickInWebView() const { return m_sfs.fDoubleClickInWebView != 0; }
bool HideIcons() const { return m_sfs.fHideIcons != 0; }
bool MapNetDrvBtn() const { return m_sfs.fMapNetDrvBtn != 0; }
bool NoConfirmRecycle() const { return m_sfs.fNoConfirmRecycle != 0; }
bool ShowAllObjects() const { return m_sfs.fShowAllObjects != 0; }
bool ShowAttribCol() const { return m_sfs.fShowAttribCol != 0; }
bool ShowCompColor() const { return m_sfs.fShowCompColor != 0; }
bool ShowExtensions() const { return m_sfs.fShowExtensions != 0; }
bool ShowInfoTip() const { return m_sfs.fShowInfoTip != 0; }
bool ShowSysFiles() const { return m_sfs.fShowSysFiles != 0; }
bool Win95Classic() const { return m_sfs.fWin95Classic != 0; }
// operations
bool GetSettings();
const SHELLFLAGSTATE &GetSFS() const { return m_sfs; }
// conversions
operator const SHELLFLAGSTATE& () { return m_sfs; }
operator const SHELLFLAGSTATE* () { return &m_sfs; }
protected:
private:
SHELLFLAGSTATE m_sfs;
HINSTANCE m_hinstShell32;
};
#endif //__SHELLSETTINGS_H__
@@ -1,331 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __LINEPARSE_H__
#define __LINEPARSE_H__
#define CPP_SPACE ' '
#define CPP_TAB '\t'
#define CPP_NEWLINE '\n'
#define CPP_CRLF _T("\r\n")
#define CPP_WHITE_SPACE _T(" \t")
class CTRL_EXT_CLASS CTextParse
{
enum { MAX_BUF = 4096 };
public:
CTextParse();
CTextParse(const CTextParse &tp);
CTextParse(LPCTSTR pszLine);
~CTextParse();
public:
operator LPCTSTR() const;
operator LPTSTR();
const CTextParse& operator=(LPCTSTR lpsz);
const CTextParse& operator=(const CTextParse &tp);
LPCTSTR operator++(int);
LPTSTR &operator++();
LPCTSTR operator--(int);
LPCTSTR &operator--();
int GetMax();
void Set(LPCTSTR p);
void Reset();
void SaveCurPos();
void RestorePos();
void SetAtCurrent(int c);
void MoveForward();
void MoveBack();
void MoveForward(int nCount);
void MoveBack(int nCount);
BOOL IsVirtualFunc();
BOOL IsPrivate();
BOOL IsPublic();
BOOL IsProtected();
BOOL IsEnd();
BOOL IsClass();
BOOL IsStartBrace();
BOOL IsEndBrace();
BOOL IsAccessSpecifier();
BOOL IsMsgMap();
BOOL IsDeclareMacro();
BOOL IsStartCommentBlock();
BOOL IsEndCommentBlock();
BOOL IsConstructor(LPCTSTR pszClassName);
BOOL IsValidCPP(LPCTSTR pszText);
BOOL CharAtStart(int c);
BOOL CharAtStart(LPCTSTR strTok);
BOOL CharAtCurrent(int c);
BOOL CharAtCurrent(LPCTSTR strTok);
BOOL StringAtStart(LPCTSTR str);
BOOL StringAtCurrent(LPCTSTR str);
BOOL CharExist(int c,BOOL bForward = TRUE);
BOOL StringExist(LPCTSTR str);
BOOL StringExistInString(LPCTSTR str);
BOOL SkipWord(BOOL bForward = TRUE);
BOOL SkipWhiteSpace(BOOL bForward = TRUE);
BOOL CharExistFromCurPos(int c,BOOL bForward = TRUE);
BOOL ValidCppCharExist(int c,BOOL bForward = TRUE);
BOOL CharExist(LPCTSTR str);
BOOL FindString(LPCTSTR str);
BOOL FindChar(int c);
BOOL MoveWhileWhiteSpace(BOOL bForward = TRUE);
BOOL MoveUntilWhiteSpace(BOOL bForward = TRUE);
BOOL MoveUntilChar(int c,BOOL bForward = TRUE);
BOOL MoveUntilChar(LPCTSTR strTok,BOOL bForward = TRUE);
BOOL MoveUntilString(LPCTSTR str,BOOL bForward = TRUE);
BOOL MoveWhileChar(int c,BOOL bForward = TRUE);
BOOL MoveWhileChar(LPCTSTR strTok,BOOL bForward = TRUE);
void MoveToLastChar();
LPCTSTR CopyUntilWhiteSpace();
LPCTSTR CopyUntilChar(int c);
LPCTSTR CopyUntilString(LPCTSTR pszText);
LPCTSTR CopyUntilChar(LPCTSTR strTok);
LPCTSTR CopyWhileChar(int c);
LPCTSTR CopyWhileChar(LPCTSTR strTok);
LPCTSTR CopyFuncUntilChar(LPCTSTR strTok);
LPCTSTR CopyUntilEnd();
LPCTSTR CopyWhileWhiteSpace();
BOOL IsCommentBlock(LPCTSTR strStart,LPCTSTR strEnd);
BOOL ExtractArgs(CString &sRet,CStringArray &asArgs);
LPCTSTR ExtractDeclareMacro();
LPCTSTR ExtractConstructor();
LPCTSTR ExtractFuncName();
LPCTSTR ExtractClassName();
LPCTSTR ExtractBaseClassName();
LPCTSTR ExtractHTMLText(bool bRemoveCRLF=false);
LPCTSTR ExtractHTMLText(LPCTSTR pszUntil,bool bRemoveCRLF=false);
LPCTSTR ExtractHTMLLink();
LPCTSTR ExtractDefaultArgs();
LPCTSTR CopyWholeWord();
bool FindWholeWord(LPCTSTR pszText);
int GetWordLen();
int GetCurrentChar();
bool SkipHTMLCommand(bool bSkipCRLF=true);
void SkipHTMLCommands(bool bSkipCRLF=true);
protected:
BOOL IsToken(LPCTSTR strTok,LPCTSTR p);
BOOL IsString(LPCTSTR str);
private:
LPCTSTR m_pLine;
LPCTSTR m_pStartLine;
LPCTSTR m_pSavePos;
TCHAR m_szCopyBuf[MAX_BUF+1];
TCHAR m_szBuffer[MAX_BUF+1];
};
inline void CTextParse::MoveForward()
{
m_pLine = _tcsinc(m_pLine);
}
inline void CTextParse::MoveBack()
{
m_pLine = _tcsdec(m_pStartLine,m_pLine);
}
inline void CTextParse::MoveForward(int nCount)
{
m_pLine = _tcsninc(m_pLine,nCount);
}
inline void CTextParse::MoveBack(int nCount)
{
int i=nCount;
LPCTSTR p = m_pLine;
while (p > m_pStartLine && i > 0)
{
p = _tcsdec(m_pLine,p);
i--;
}
m_pLine = p;
}
inline CTextParse::operator LPCTSTR() const
{
return m_pStartLine;
}
inline CTextParse::operator LPTSTR()
{
Reset();
return m_szBuffer;
}
// prefix
inline LPCTSTR CTextParse::operator++(int)
{
MoveForward();
return (LPCTSTR&)*m_pLine;
}
// postfix
inline LPTSTR &CTextParse::operator++()
{
LPCTSTR p = m_pLine;
MoveForward();
return (LPTSTR&)*p;
}
inline LPCTSTR CTextParse::operator--(int)
{
MoveBack();
return m_pLine;
}
inline LPCTSTR &CTextParse::operator--()
{
LPCTSTR p = m_pLine;
MoveBack();
return (LPCTSTR&)*p;
}
inline BOOL CTextParse::IsEnd()
{
return *m_pLine == '\0';
}
inline int CTextParse::GetMax()
{
return MAX_BUF;
}
inline int CTextParse::GetCurrentChar()
{
return *m_pLine;
}
inline void CTextParse::SetAtCurrent(int c)
{
int i = m_pLine-m_szBuffer;
m_szBuffer[i] = c;
}
inline void CTextParse::Set(LPCTSTR p)
{
m_pStartLine = p;
m_pLine = p;
m_pSavePos = p;
}
inline void CTextParse::Reset()
{
m_pLine = m_pStartLine;
}
inline void CTextParse::SaveCurPos()
{
m_pSavePos = m_pLine;
}
inline void CTextParse::RestorePos()
{
m_pLine = m_pSavePos;
}
inline BOOL CTextParse::CharAtStart(int c)
{
return *m_pStartLine == c;
}
inline BOOL CTextParse::CharAtStart(LPCTSTR strTok)
{
return IsToken(strTok,m_pStartLine);
}
inline BOOL CTextParse::CharAtCurrent(int c)
{
return *m_pLine == c;
}
inline BOOL CTextParse::CharAtCurrent(LPCTSTR strTok)
{
return IsToken(strTok,m_pLine);
}
inline BOOL CTextParse::StringAtStart(LPCTSTR str)
{
return(_tcsncmp(m_pStartLine,str,_tcslen(str)) == 0);
}
inline BOOL CTextParse::StringAtCurrent(LPCTSTR str)
{
return(_tcsncmp(m_pLine,str,_tcslen(str)) == 0);
}
inline BOOL CTextParse::CharExist(int c,BOOL bForward)
{
return _tcschr(m_pStartLine,c) != NULL;
}
inline BOOL CTextParse::StringExist(LPCTSTR str)
{
return _tcsstr(m_pLine,str) != NULL;
}
inline BOOL CTextParse::StringExistInString(LPCTSTR str)
{
return _tcsstr(m_pStartLine,str) != NULL;
}
inline BOOL CTextParse::SkipWord(BOOL bForward)
{
return MoveUntilChar(CPP_WHITE_SPACE,bForward);
}
inline BOOL CTextParse::SkipWhiteSpace(BOOL bForward)
{
return MoveWhileChar(CPP_WHITE_SPACE,bForward);
}
inline BOOL CTextParse::IsString(LPCTSTR str)
{
return(_tcsncmp(m_pLine,str,_tcslen(str)) == 0);
}
inline LPCTSTR CTextParse::CopyUntilWhiteSpace()
{
return CopyUntilChar(CPP_WHITE_SPACE);
}
inline LPCTSTR CTextParse::CopyWhileWhiteSpace()
{
return CopyWhileChar(CPP_WHITE_SPACE);
}
inline BOOL CTextParse::MoveWhileWhiteSpace(BOOL bForward)
{
return MoveWhileChar(CPP_WHITE_SPACE,bForward);
}
inline BOOL CTextParse::MoveUntilWhiteSpace(BOOL bForward)
{
return MoveUntilChar(CPP_WHITE_SPACE,bForward);
}
// move to last char
inline void CTextParse::MoveToLastChar()
{
LPCTSTR p = m_pLine;
while (*p != '\0')
p = _tcsinc(p);
if (p != m_pLine)
p = _tcsdec(m_pStartLine,p);
m_pLine = p;
}
#endif
@@ -1,97 +0,0 @@
#if !defined(AFX_TEXTPROGRESSCTRL_H__4C78DBBE_EFB6_11D1_AB14_203E25000000__INCLUDED_)
#define AFX_TEXTPROGRESSCTRL_H__4C78DBBE_EFB6_11D1_AB14_203E25000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// TextProgressCtrl.h : header file
//
// Written by Chris Maunder ([email protected])
// Copyright 1998.
//
// TextProgressCtrl is a drop-in replacement for the standard
// CProgressCtrl that displays text in a progress control.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this
// notice and the authors name is included. If the source code in
// this file is used in any commercial application then an email to
// the me would be nice.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
// computer, causes your pet cat to fall ill, increases baldness or
// makes you car start emitting strange noises when you start it up.
//
// Expect bugs.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this
// file.
#include "UIData.h"
/////////////////////////////////////////////////////////////////////////////
// CTextProgressCtrl window
class CTextProgressCtrl : public CUIODColumnCtrl
{
DECLARE_DYNAMIC(CTextProgressCtrl)
// Construction
public:
CTextProgressCtrl();
// Attributes
public:
// Operations
public:
int SetPos(int nPos);
int StepIt();
void SetRange(int nLower, int nUpper);
void GetRange(int& nLower, int& nUpper) const;
int OffsetPos(int nPos);
int SetStep(int nStep);
// Attributes
void SetShowText(BOOL bShow);
COLORREF SetTextColor(COLORREF crTextClr = CLR_DEFAULT,COLORREF crSelTextClr=CLR_DEFAULT);
COLORREF GetTextColor() const;
COLORREF GetSelTextColor() const;
COLORREF SetBarColor(COLORREF crBarClr = CLR_DEFAULT,COLORREF crSelBarClr = CLR_DEFAULT);
COLORREF GetBarColor() const;
COLORREF GetSelBarColor() const;
COLORREF SetBgColor(COLORREF crBgClr = CLR_DEFAULT,COLORREF crSelBgClr = CLR_DEFAULT);
COLORREF GetBgColor() const;
COLORREF GetSelBgColor() const;
public:
// Overrides
virtual void DoPaint(CDC *PaintDC,CRect rcClient,bool bSelected);
// Implementation
public:
virtual ~CTextProgressCtrl();
// Generated message map functions
protected:
int m_nPos,
m_nStepSize,
m_nMax,
m_nMin;
CString m_strText;
BOOL m_bShowText;
int m_nBarWidth;
private:
COLORREF m_crBarClr,
m_crSelBarClr,
m_crTextClr,
m_crSelTextClr,
m_crBgClr,
m_crSelBgClr;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TEXTPROGRESSCTRL_H__4C78DBBE_EFB6_11D1_AB14_203E25000000__INCLUDED_)
@@ -1,117 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __UIAPP_H__
#define __UIAPP_H__
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
class CTRL_EXT_CLASS CUIApp : public CWinApp
{
DECLARE_DYNAMIC(CUIApp)
public:
CUIApp();
void SetStatusBarText(UINT nPaneID,LPCTSTR Text,UINT nIconID=0);
void SetStatusBarText(UINT nPaneID,LPCTSTR Text,CView *pView,UINT nIconID=0);
void SetStatusBarText(UINT nPaneID,UINT nResID,UINT nIconID=0);
void SetStatusBarText(LPCTSTR Text);
void SetStatusBarIcon(UINT nPaneID,UINT nIconID,bool bAdd);
void SetStatusBarIdleMessage();
CString GetRegAppKey();
static bool COMMessage(HRESULT hr,UINT nID);
static void ErrorMessage(UINT nID,DWORD dwError=0);
static bool COMMessage(HRESULT hr,LPCTSTR pszMess=NULL);
static void ErrorMessage(LPCTSTR pszMess=NULL,DWORD dwError=0);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUIApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
// CMultiDocTemplate* m_pWebSitesDocTemplate;
void ChangeProfile(LPCTSTR szRegistryKey,LPCTSTR szProfileName);
void RestoreProfile();
// Implementation
CFrameWnd *GetMainFrame(CWnd *pWnd);
CView *GetView(CRuntimeClass *pClass);
CDocTemplate *GetFirstDocTemplate();
CDocument *GetDocument();
protected:
bool RegisterMyClass();
BOOL FirstInstance();
//{{AFX_MSG(CUIApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CString m_strOldProfileName;
CString m_strOldRegistryKey;
CString m_sMyClassName;
UINT m_IDMyIcon;
bool m_bMyClassRegistered;
public:
void SetMyClass(const CString &sMyClassName,UINT nIconID);
LPCTSTR GetMyClass() const;
bool IsMyClassRegistered() const;
};
inline bool CUIApp::IsMyClassRegistered() const
{
return m_bMyClassRegistered;
}
inline void CUIApp::SetMyClass(const CString &sMyClassName,UINT nIconID)
{
m_sMyClassName = sMyClassName;
m_IDMyIcon = nIconID;
}
inline LPCTSTR CUIApp::GetMyClass() const
{
return m_sMyClassName;
}
/////////////////////////////////////////////////////////////////////////////
class CTRL_EXT_CLASS CAppReg
{
public:
CAppReg(CWinApp *pApp,LPCTSTR szRegistryKey,LPCTSTR szProfileName);
~CAppReg();
CString GetProfileString( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault = NULL );
BOOL WriteProfileString( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszValue );
private:
CUIApp *m_pApp;
};
inline BOOL CAppReg::WriteProfileString( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszValue )
{
return m_pApp->WriteProfileString(lpszSection,lpszEntry,lpszValue);
}
inline CString CAppReg::GetProfileString( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault)
{
return m_pApp->GetProfileString(lpszSection,lpszEntry,lpszDefault);
}
#endif //__UIAPP_H__
@@ -1,46 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __OBJLIST_H__
#define __OBJLIST_H__
#include "UIData.h"
class CTRL_EXT_CLASS CUIObjList : public CObList
{
DECLARE_SERIAL(CUIObjList)
public:
CUIObjList();
~CUIObjList();
void DeleteAll();
CUIListCtrlData* RemoveHead();
CUIListCtrlData* GetNext(POSITION& rPos);
void Append(CUIListCtrlData* pListObj);
BOOL Remove(CUIListCtrlData* pListObj);
};
inline CUIListCtrlData* CUIObjList::RemoveHead()
{
return (CUIListCtrlData*) CObList::RemoveHead();
}
inline CUIListCtrlData* CUIObjList::GetNext(POSITION& rPos)
{
return (CUIListCtrlData*) CObList::GetNext(rPos);
}
#endif // __OBJLIST_H__
@@ -1,121 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
#ifndef __COOLBAR_H
#define __COOLBAR_H
//////////////////
// CCoolBar encapsulates IE common coolbar (rebar) for MFC. To use it,
//
// * derive your own CMyCoolBar from CCoolBar
// * implement OnCreateBands to create whatever bands you want
// * instantiate CMyCoolBar in your frame window as you would a toolbar
// * create and load it, etc from CMainFrame::OnCreate
//
// See MBTest for example of how to use.
//
class CTRL_EXT_CLASS CCoolBar : public CControlBar {
public:
CCoolBar();
virtual ~CCoolBar();
BOOL Create(CWnd* pParentWnd, DWORD dwStyle,
DWORD dwAfxBarStyle = CBRS_ALIGN_TOP,
UINT nID = AFX_IDW_TOOLBAR);
// message wrappers
BOOL GetBarInfo(LPREBARINFO lp)
{ ASSERT(::IsWindow(m_hWnd));
return (BOOL)SendMessage(RB_GETBARINFO, 0, (LPARAM)lp); }
BOOL SetBarInfo(LPREBARINFO lp)
{ ASSERT(::IsWindow(m_hWnd));
return (BOOL)SendMessage(RB_SETBARINFO, 0, (LPARAM)lp); }
BOOL GetBandInfo(int iBand, LPREBARBANDINFO lp)
{ ASSERT(::IsWindow(m_hWnd));
return (BOOL)SendMessage(RB_GETBANDINFO, iBand, (LPARAM)lp); }
BOOL SetBandInfo(int iBand, LPREBARBANDINFO lp)
{ ASSERT(::IsWindow(m_hWnd));
return (BOOL)SendMessage(RB_SETBANDINFO, iBand, (LPARAM)lp); }
BOOL InsertBand(int iWhere, LPREBARBANDINFO lp)
{ ASSERT(::IsWindow(m_hWnd));
return (BOOL)SendMessage(RB_INSERTBAND, (WPARAM)iWhere, (LPARAM)lp); }
BOOL DeleteBand(int nWhich)
{ ASSERT(::IsWindow(m_hWnd));
return (BOOL)SendMessage(RB_DELETEBAND, (WPARAM)nWhich); }
int GetBandCount()
{ ASSERT(::IsWindow(m_hWnd));
return (int)SendMessage(RB_GETBANDCOUNT); }
int GetRowCount()
{ ASSERT(::IsWindow(m_hWnd));
return (int)SendMessage(RB_GETROWCOUNT); }
int GetRowHeight(int nWhich)
{ ASSERT(::IsWindow(m_hWnd));
return (int)SendMessage(RB_GETROWHEIGHT, (WPARAM)nWhich); }
// Call these handy functions from your OnCreateBands to do stuff
// more easily than the Windows way.
//
BOOL InsertBand(CWnd* pWnd, CSize szMin, int cx = 0,
LPCTSTR lpText=NULL, int iWhere=-1, BOOL bNewRow =FALSE);
void SetColors(COLORREF clrFG, COLORREF clrBG);
void SetBackgroundBitmap(CBitmap* pBitmap);
void Invalidate(BOOL bErase = TRUE); // invalidates children too
static BOOL bTRACE; // Set TRUE to see extra diagnostics in DEBUG code
protected:
// YOU MUST OVERRIDE THIS in your derived class to create bands.
virtual BOOL OnCreateBands() = 0; // return -1 if failed
// Virtual fn called when the coolbar height changes as a result of moving
// bands around. Override only if you want to do something different.
virtual void OnHeightChange(const CRect& rcNew);
// overrides to fix problems w/MFC. No need to override yourself.
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
// message handlers
afx_msg int OnCreate(LPCREATESTRUCT lpcs);
afx_msg void OnPaint();
afx_msg void OnHeightChange(NMHDR* pNMHDR, LRESULT* pRes);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CCoolBar)
};
//////////////////
// Programmer-friendly REBARINFO initializes itself.
//
class CRebarInfo : public REBARINFO {
public:
CRebarInfo() {
memset(this, 0, sizeof(REBARINFO));
cbSize = sizeof(REBARINFO);
}
};
//////////////////
// Programmer-friendly REBARBANDINFO initializes itself.
//
class CRebarBandInfo : public REBARBANDINFO {
public:
CRebarBandInfo() {
memset(this, 0, sizeof(REBARBANDINFO));
cbSize = sizeof(REBARBANDINFO);
}
};
#endif
@@ -1,174 +0,0 @@
////////////////////////////////////////////////////////////////
// 199 Microsoft Systems Journal.
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// ==========================================================================
// HISTORY:
// ==========================================================================
// 1.01 13 Aug 1998 - Andrew Bancroft [[email protected]] - Since we've already
// added the entire toolbar to the imagelist we need to
// increment nNextImage even if we didn't add this button to
// m_mapIDtoImage in the LoadToolbar() method.
// 1.01a 13 Aug 1998 - Peter Tewkesbury - Added AddSingleBitmap(...)
// method for adding a single bitmap to a pulldown
// menu item.
// 1.02 13 Aug 1998 - Omar L Francisco - Fixed bug with lpds->CtlType
// and lpds->itemData item checking.
// 1.03 12 Nov 1998 - Fixes debug assert in system menu. - Wang Jun
// 1.04 17 Nov 1998 - Fixes debug assert when you maximize a view - Wang Jun
// window, then try to use the system menu for the view.
// 1.05 09 Jan 1998 - Seain B. Conover [[email protected]] - Fix for virtual
// key names.
// 1.06 24 Feb 1999 - Michael Lange [[email protected]] - Fix for memory
// leak in CMyItemData structure, added a destructor that
// calls text.Empty().
// - Boris Kartamishev [[email protected]] - Fix for resource
// ID bug.
// - Jeremy Horgan [[email protected]] - During
// accelerator key processing OnInitMenuPopup() calls
// ConvertMenu() which allocates a new CMyItemData for each
// menu item. This is memory is normally freed by a call to
// OnMenuSelect(), which is not called when processing
// accelerator keys. This results in a memory leak. This was
// fixed by modifying the ~CCoolMenuManager() destructor.
// 1.07 24 Feb 1999 - Koji MATSUNAMI [[email protected]] - Fixed problem with
// popup menus being drawn correctly as cool menus.
// ==========================================================================
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __COOLMENU_H__
#define __COOLMENU_H__
#include "UISubClass.h"
//////////////////
// CCoolMenuManager implements "cool" menus with buttons in them. To use:
//
// * Instantiate in your CMainFrame.
// * Call Install to install it
// * Call LoadToolbars or LoadToolbar to load toolbars
//
// Don't forget to link with CoolMenu.cpp, Subclass.cpp and DrawTool.cpp!
//
class CTRL_EXT_CLASS CCoolMenuManager : public CSubclassWnd
{
public:
DECLARE_DYNAMIC(CCoolMenuManager)
CCoolMenuManager();
~CCoolMenuManager();
// You can set these any time
BOOL m_bShowButtons; // use to control whether buttons are shown
BOOL m_bAutoAccel; // generate auto accelerators
BOOL m_bUseDrawState; // use ::DrawState for disabled buttons
BOOL m_bDrawDisabledButtonsInColor; // draw disabled buttons in color
// (only if m_bUseDrawState = FALSE)
// public functions to use
void Install(CWnd* pFrame); // connect to main frame
void Uninstall(); // disconnect from main frame
BOOL LoadToolbars(const UINT* arIDs, int n); // load multiple toolbars
BOOL LoadToolbar(UINT nID); // load one toolbar
CSize SetButtonSize(CSize &sz=CSize(0,0)); // Set up button sizes if not using toolbar
BOOL AddSingleBitmap(UINT nBitmapID, UINT n, UINT *nID);
// O.S. - item access
static void *SetItemData(HMENU hMenu, void *pData, UINT uItem, BOOL bByPosition = FALSE);
static void *GetItemData(HMENU hMenu, UINT uItem, BOOL bByPosition = FALSE);
static HICON SetItemIcon(HMENU hMenu, HICON hIcon, UINT uItem, BOOL bByPosition = FALSE);
static HICON GetItemIcon(HMENU hMenu, UINT uItem, BOOL bByPosition = FALSE);
// O.S. -- stuff for submenus
void SetSubMenuIcon(HMENU hSubMenu, int nID); // nID == -1 -> never convert this submenu
void UnmanageSubMenu(HMENU hSubMenu);
// shell menu functions
void SetShellContextMenu(LPCONTEXTMENU lpcm,UINT nIDFirst,UINT nIDLast);
void AddShellContextMenu(CMenu *pMenu, LPCONTEXTMENU lpm, int iIndex);
// Conversion routines
// Switch between MyItemData and their item data
DWORD SwitchContextItemData(CMenu *pMenu, int iCmd, DWORD dwItemData=0, BOOL bByPosition=TRUE);
void ConvertMenu(CMenu *pMenu);
void UnconvertMenu(CMenu *pMenu);
void ConvertMenuItem(CMenu *pMenu, int iIndex, bool bRecurse = true,
bool bUnconvert = false);
// should never need to call:
virtual void Destroy(); // destroys everything--to re-load new toolbars?
virtual void Refresh(); // called when system colors, etc change
static HBITMAP GetMFCDotBitmap(); // get..
static void FixMFCDotBitmap(); // and fix MFC's dot bitmap
static BOOL bTRACE; // Set TRUE to see extra diagnostics in DEBUG code
protected:
CWnd* m_pFrame; // frame window I belong to
CUIntArray m_arToolbarID; // array of toolbar IDs loaded
CImageList m_ilButtons; // image list for all buttons
CImageList m_ilTemp; // image list for all buttons
CMapWordToPtr m_mapIDtoImage;// maps command ID -> image list index
CMapWordToPtr m_mapIDtoAccel;// maps command ID -> ACCEL*
CMapPtrToWord m_mapHMENUtoID;
HACCEL m_hAccel; // current accelerators, if any
ACCEL* m_pAccel; // ..and table in memory
CPtrList m_menuList; // list of HMENU's initialized
CSize m_szBitmap; // size of button bitmap
CSize m_szButton; // size of button (including shadow)
CFont m_fontMenu; // menu font
///////////////////////////
// Addition: Philip Oldaker
// Shell helpers to show help string on the status bar
UINT m_idShellMenuFirst;
UINT m_idShellMenuLast;
LPCONTEXTMENU m_lpcm;
//////////////////////////
void ConvertMenu(CMenu* pMenu,UINT nIndex,BOOL bSysMenu,BOOL bShowButtons);
// helpers
void DestroyAccel();
void DrawMenuText(CDC& dc, CRect rc, CString text, COLORREF color);
BOOL Draw3DCheckmark(CDC& dc, const CRect& rc, BOOL bSelected,
HBITMAP hbmCheck=NULL);
void LoadAccel(HACCEL hAccel);
CString GetVirtualKeyName( const CString strVirtKey ) const;
BOOL AppendAccelName(CString& sItemName, UINT nID);
CFont* GetMenuFont();
// Get button index for given command ID, or -1 if not found
int GetButtonIndex(WORD nID) {
void* val;
return m_mapIDtoImage.Lookup(nID, val) ? (int)val : -1;
}
// Get ACCEL structure associated with a given command ID
ACCEL* GetAccel(WORD nID) {
void* val;
return m_mapIDtoAccel.Lookup(nID, val) ? (ACCEL*)val : NULL;
}
// window proc to hook frame using CCoolMenuSubclassWnd implementation
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
// CCoolMenuSubclassWnd message handlers
virtual void OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu);
virtual BOOL OnMeasureItem(LPMEASUREITEMSTRUCT lpms);
virtual BOOL OnDrawItem(LPDRAWITEMSTRUCT lpds);
virtual LONG OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
virtual void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
};
// the one and only manager
extern CCoolMenuManager g_CoolMenuManager;
//////////////////
// Friendly version of MENUITEMINFO initializes itself
//
struct CMenuItemInfo : public MENUITEMINFO {
CMenuItemInfo()
{ memset(this, 0, sizeof(MENUITEMINFO));
cbSize = sizeof(MENUITEMINFO);
}
};
#endif // __COOLMENU_H__
@@ -1,300 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __LISTCTRLDATA_H__
#define __LISTCTRLDATA_H__
////////////////////////////////////////////////
// CUIODColumnCtrl
// Interface for an owner draw control in a list control column
////////////////////////////////////////////////
class CUIODColumnCtrl : public CObject
{
DECLARE_DYNAMIC(CUIODColumnCtrl);
public:
CUIODColumnCtrl();
virtual ~CUIODColumnCtrl();
public:
virtual void DoPaint(CDC *PaintDC,CRect rcClient,bool bSelected)=0;
protected:
private:
};
inline CUIODColumnCtrl::CUIODColumnCtrl()
{
}
inline CUIODColumnCtrl::~CUIODColumnCtrl()
{
}
// Internal extension data for each row in the list control
// if you wish to override the default behaviour
// a class should be derived from this one and the GetListCtrlData method
// should be overridden in the list control class
class CTRL_EXT_CLASS CUIListCtrlData : public CObject
{
public:
DECLARE_DYNAMIC(CUIListCtrlData)
CUIListCtrlData(int nCols=1);
~CUIListCtrlData();
void Init(int nCols);
// functions to change the color of each row
COLORREF GetTextColor(int nCol=0) const;
COLORREF GetBkColor(int nCol=0) const;
const CFont *GetFont(int nCol=0) const;
void SetBkColor(COLORREF BkColor,int nCol=-1);
void SetTextColor(COLORREF TextColor,int nCol=-1);
void SetDefaultBkColor(int nCol=-1);
void SetDefaultTextColor(int nCol=-1);
void SetFont(CFont *pFont,int nCol=-1);
void SetCtrl(CUIODColumnCtrl *pCtrl,int nCol);
void DestroyCtrl(int nCol);
// emulate the CListCtrl class by allowing user defined extension data
DWORD GetExtData() const;
void SetExtData(DWORD dwExtData);
BOOL IsFontSet(int nCol=-1) const;
protected:
void DestroyFonts();
void DestroyCtrls();
void CreateNewFont(int nCol,LOGFONT &lf);
// Get/Set Methods
public:
void SetAutoDelete(bool bAutoDelete);
bool GetAutoDelete() const;
int GetCtrlCount() const;
CUIODColumnCtrl *GetCtrl(int nCol) const;
void SetDeleted(bool bDeleted);
bool IsDeleted() const;
private:
CDWordArray m_arBkColors;
CDWordArray m_arTextColors;
CObArray m_arFonts;
DWORD m_dwExtData;
CObArray m_arCtrl;
bool m_bAutoDelete;
bool m_bDeleted;
};
inline int CUIListCtrlData::GetCtrlCount() const
{
int nCount=0;
for(int i=0;i < m_arCtrl.GetSize();i++)
{
if (m_arCtrl.GetAt(i) != NULL)
{
nCount++;
}
}
return nCount;
}
inline CUIODColumnCtrl *CUIListCtrlData::GetCtrl(int nCol) const
{
CUIODColumnCtrl *pCtrl = (CUIODColumnCtrl*)m_arCtrl.GetAt(nCol);
return pCtrl;
}
inline void CUIListCtrlData::DestroyCtrl(int nCol)
{
CUIODColumnCtrl *pOldCtrl = (CUIODColumnCtrl*)m_arCtrl[nCol];
delete pOldCtrl;
m_arCtrl[nCol] = NULL;
}
inline void CUIListCtrlData::SetCtrl(CUIODColumnCtrl *pCtrl,int nCol)
{
DestroyCtrl(nCol);
ASSERT_KINDOF(CUIODColumnCtrl,pCtrl);
m_arCtrl[nCol] = pCtrl;
}
inline void CUIListCtrlData::SetAutoDelete(bool bAutoDelete)
{
m_bAutoDelete = bAutoDelete;
}
inline bool CUIListCtrlData::GetAutoDelete() const
{
return m_bAutoDelete;
}
inline void CUIListCtrlData::SetDeleted(bool bDeleted)
{
m_bDeleted = bDeleted;
}
inline bool CUIListCtrlData::IsDeleted() const
{
return m_bDeleted;
}
inline const CFont *CUIListCtrlData::GetFont(int nCol) const
{
return (const CFont*)m_arFonts[nCol];
}
inline COLORREF CUIListCtrlData::GetTextColor(int nCol) const
{
return m_arTextColors[nCol];
}
inline COLORREF CUIListCtrlData::GetBkColor(int nCol) const
{
return m_arBkColors[nCol];
}
inline DWORD CUIListCtrlData::GetExtData() const
{
return m_dwExtData;
}
inline void CUIListCtrlData::SetBkColor(COLORREF BkColor,int nCol)
{
if (nCol == -1)
{
for(int i=0;i < m_arBkColors.GetSize();i++)
{
m_arBkColors[i] = BkColor;
}
}
else
m_arBkColors[nCol] = BkColor;
}
inline void CUIListCtrlData::SetTextColor(COLORREF TextColor,int nCol)
{
if (nCol == -1)
{
for(int i=0;i < m_arTextColors.GetSize();i++)
{
m_arTextColors[i] = TextColor;
}
}
else
m_arTextColors[nCol] = TextColor;
}
inline void CUIListCtrlData::SetDefaultTextColor(int nCol)
{
SetTextColor(::GetSysColor(COLOR_WINDOWTEXT),nCol);
}
inline void CUIListCtrlData::SetDefaultBkColor(int nCol)
{
SetBkColor(::GetSysColor(COLOR_WINDOW),nCol);
}
inline void CUIListCtrlData::SetExtData(DWORD dwExtData)
{
m_dwExtData = dwExtData;
}
// for ODBC databases
class CTRL_EXT_CLASS CUIDBListCtrlData : public CUIListCtrlData
{
public:
CUIDBListCtrlData(int nCols) : CUIListCtrlData(nCols) { }
DECLARE_DYNAMIC(CUIDBListCtrlData)
const GetRecNum() { return m_nRecNum; }
void SetRecNum(long nRecNum) { m_nRecNum = nRecNum; }
private:
long m_nRecNum; // for ODBC connection to record sets
};
// used by the Ownerdraw combo box
class CTRL_EXT_CLASS CUIComboBoxData : public CUIListCtrlData
{
DECLARE_DYNAMIC(CUIComboBoxData)
public:
CUIComboBoxData(int nCols) : CUIListCtrlData(nCols), m_nImageIndex(-1) {}
CString GetText(int nCol = -1) const;
int GetImageIndex() const { return m_nImageIndex; }
void SetText(LPCTSTR szText) { m_strText = szText; }
void SetImageIndex(int nImageIndex) { m_nImageIndex = nImageIndex; }
private:
CString m_strText; // for displaying text in OD combo boxes with columns
int m_nImageIndex;
};
// keep our own copy of strings in the list control to ease sorting
class CTRL_EXT_CLASS CUIStrListCtrlData : public CUIListCtrlData
{
public:
DECLARE_DYNAMIC(CUIStrListCtrlData)
CUIStrListCtrlData(int nColumns);
CUIStrListCtrlData();
LPTSTR GetString(int nCol);
const CString &GetExtraString() const;
void AddExtraString(LPCTSTR pszExtraText);
int GetStringLen(int nCol) const;
BOOL AddString(int nCol,LPCTSTR szText);
private:
CStringArray m_StringArray;
CString m_strExtraText;
};
inline int CUIStrListCtrlData::GetStringLen(int nCol) const
{
return m_StringArray[nCol].GetLength();
}
inline void CUIStrListCtrlData::AddExtraString(LPCTSTR pszExtraText)
{
m_strExtraText = pszExtraText;
}
inline const CString &CUIStrListCtrlData::GetExtraString() const
{
return m_strExtraText;
}
// Used internally to help sorting
class CUIODListCtrlSortInfo : public CObject
{
public:
CUIODListCtrlSortInfo(int nSubItem,int ColType,BOOL bSortAscending);
BOOL Ascending() const;
int GetColumn() const;
int GetColType() const;
private:
BOOL m_bSortAscending;
int m_nSubItem;
int m_ColType;
};
inline CUIODListCtrlSortInfo::CUIODListCtrlSortInfo(int nSubItem,int ColType,BOOL bSortAscending)
: m_nSubItem(nSubItem),m_ColType(ColType),m_bSortAscending(bSortAscending)
{
}
inline BOOL CUIODListCtrlSortInfo::Ascending() const
{
return m_bSortAscending;
}
inline int CUIODListCtrlSortInfo::GetColumn() const
{
return m_nSubItem;
}
inline int CUIODListCtrlSortInfo::GetColType() const
{
return m_ColType;
}
#endif // __LISTCTRLDATA_H__
@@ -1,180 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_)
#define AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// DragDropTree.h : header file
//
#include "UIImageDropTarget.h"
// ///////////////////////////////////////////////////////////////////////////
class CUI_TreeDropTarget : public CUI_ImageDropTarget
{
public:
virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
virtual void OnDragLeave( CWnd* pWnd);
protected:
DWORD m_dwKeyboardState;
DWORD m_dwEnterKeyboardState;
};
/////////////////////////////////////////////////////////////////////////////
// CUIDragDropTree window
class CTRL_EXT_CLASS CUIDragDropTree : public CTreeCtrl
{
friend class CUI_TreeDropTarget;
// Construction
public:
DECLARE_DYNAMIC(CUIDragDropTree)
CUIDragDropTree(bool bDragDrop=true);
// Attributes
public:
enum CopyMode
{
eDDNull,
eDDMove,
eDDCopy,
eDDCancel
};
enum SCROLLMODE
{
SCROLL_UP_SLOW,
SCROLL_DOWN_SLOW,
SCROLL_UP_NORMAL,
SCROLL_DOWN_NORMAL
};
const COleDropTarget &GetDropTarget();
// Operations
public:
void RegisterDropTarget();
void SetDragTimer();
void KillDragTimer();
virtual DROPEFFECT SelectCurrentTarget(CDD_OleDropTargetInfo *pInfo);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUIDragDropTree)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CUIDragDropTree();
protected:
HTREEITEM GetDragItem();
HTREEITEM GetDropItem();
virtual BOOL IsChildNodeOf(HTREEITEM hitemChild, HTREEITEM hitemSuspectedParent);
virtual BOOL NeedToScroll( CPoint ptMouse );
virtual SCROLLMODE RefineScrollMode( CPoint ptMouse );
virtual BOOL TransferItem(HTREEITEM hitem, HTREEITEM hNewParent);
virtual void OnButtonUp(bool bMove);
virtual void OnDropFile(HTREEITEM hItem,LPCTSTR pszFile,UINT nFlags);
virtual void NewTransferItem(HTREEITEM hNewItem);
virtual BOOL StartDragDrop(NM_TREEVIEW* pNMTreeView);
virtual bool GetRDragMenu(CMenu *pMenu);
virtual void EndDragging();
// Generated message map functions
protected:
//{{AFX_MSG(CUIDragDropTree)
afx_msg BOOL OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnBeginRDrag(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnDestroy();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDropFiles( HDROP hDropInfo);
afx_msg void OnDDMove();
afx_msg void OnDDCopy();
afx_msg void OnDDCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
bool m_bDragDrop;
bool m_bDropFiles;
CImageList* m_pImageList;
BOOL m_bDragging;
HTREEITEM m_hitemDrag;
HTREEITEM m_hitemDrop;
UINT m_nTimerID;
int m_nSlowScrollTimeout;
int m_nUpperYCoor;
int m_nLowerYCoor;
int m_nScrollBarSize;
CUI_TreeDropTarget m_OleDropTarget;
COleDataSource m_OleDataSource;
protected:
CopyMode m_CopyMode;
public:
void SetDragDrop(bool bDragDrop);
bool GetDragDrop();
void SetDropFiles(bool bDropFiles);
bool GetDropFiles();
};
inline void CUIDragDropTree::SetDragDrop(bool bDragDrop)
{
m_bDragDrop = bDragDrop;
}
inline bool CUIDragDropTree::GetDragDrop()
{
return m_bDragDrop;
}
inline void CUIDragDropTree::SetDropFiles(bool bDropFiles)
{
m_bDropFiles = bDropFiles;
}
inline bool CUIDragDropTree::GetDropFiles()
{
return m_bDropFiles;
}
inline const COleDropTarget &CUIDragDropTree::GetDropTarget()
{
return m_OleDropTarget;
}
inline HTREEITEM CUIDragDropTree::GetDragItem()
{
return m_hitemDrag;
}
inline HTREEITEM CUIDragDropTree::GetDropItem()
{
return m_hitemDrop;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_)
@@ -1,77 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_EXPLORERFRAMEWND_H__13CAB7C3_D316_11D1_8693_000000000000__INCLUDED_)
#define AFX_EXPLORERFRAMEWND_H__13CAB7C3_D316_11D1_8693_000000000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// EXPLORERFRAMEWND.h : header file
//
#include "UIFrameWnd.h"
#include "UITabSplitterWnd.h"
class CTRL_EXT_CLASS CUIExplorerFrameWnd : public CUIFrameWnd
{
DECLARE_DYNAMIC(CUIExplorerFrameWnd)
protected:
CUIExplorerFrameWnd(); // protected constructor used by dynamic creation
// Attributes
public:
void SetExplorerView(CRuntimeClass *pClass);
CTabSplitterWnd &GetSplitterWnd();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUIExplorerFrameWnd)
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CUIExplorerFrameWnd();
// Generated message map functions
//{{AFX_MSG(CUIExplorerFrameWnd)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
protected:
private:
CTabSplitterWnd m_wndSplitter;
CRuntimeClass *m_pExplorerView;
};
inline void CUIExplorerFrameWnd::SetExplorerView(CRuntimeClass *pClass)
{
m_pExplorerView = pClass;
}
inline CTabSplitterWnd &CUIExplorerFrameWnd::GetSplitterWnd()
{
return m_wndSplitter;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_EXPLORERFRAMEWND_H__13CAB7C3_D316_11D1_8693_000000000000__INCLUDED_)
@@ -1,64 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
#ifndef __FIXTB_H
#define __FIXTB_H
//////////////////
// This class fixes the sizing bugs in MFC that calculates the
// size of toolbars incorrectly for modern toobars (comctl32 version >= 4.71)
// It also contains a number of wrappers for function that CToolBar doesn't
// have (so you don't have to use GetToolBarCtrl).
//
// Generally, you should use CFlatToolBar instead of CFixMFCToolBar (even
// if you're not using the flat style), but you can use CFixMFCToolBar if
// all you want is the sizing fix for MFC tooblars.
//
class CTRL_EXT_CLASS CFixMFCToolBar : public CToolBar {
public:
CFixMFCToolBar();
virtual ~CFixMFCToolBar();
static int iVerComCtl32; // version of commctl32.dll (eg 471)
// There is a bug in comctl32.dll, version 4.71+ that causes it to
// draw vertical separators in addition to horizontal ones, when the
// toolbar is vertically docked. If the toolbar has no dropdown buttons,
// this is not a problem because the separators are ignored when calculating
// the width of the toolbar. If, however, you have dropdown buttons, then the
// width of a vertically docked toolbar will be too narrow to show the
// dropdown arrow. This is in fact what happens in Visual Studio. If you
// want to show the dropdown arrow when vertical, set this to TRUE
// (default = FALSE)
//
BOOL m_bShowDropdownArrowWhenVertical;
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
CSize CalcLayout(DWORD nMode, int nLength = -1);
CSize CalcSize(TBBUTTON* pData, int nCount);
int WrapToolBar(TBBUTTON* pData, int nCount, int nWidth);
void SizeToolBar(TBBUTTON* pData, int nCount, int nLength,
BOOL bVert = FALSE);
virtual void OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle);
virtual CSize GetButtonSize(TBBUTTON* pData, int iButton);
// MFC has versions of these that are protected--but why?
//
void GetButton(int nIndex, TBBUTTON* pButton) const;
void SetButton(int nIndex, TBBUTTON* pButton);
protected:
LRESULT OnSizeHelper(CSize& sz, LPARAM lp);
afx_msg LRESULT OnSetBitmapSize(WPARAM, LPARAM);
afx_msg LRESULT OnSetButtonSize(WPARAM, LPARAM);
afx_msg LRESULT OnSettingChange(WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CFixMFCToolBar)
};
#endif
@@ -1,195 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
#ifndef __FLATBAR_H
#define __FLATBAR_H
#ifndef TB_SETEXTENDEDSTYLE
#error FlatBar.h requires a newer version of the SDK than you have!
#error Please update your SDK files.
#endif
#ifndef countof
#define countof(x) (sizeof(x)/sizeof(x[0]))
#endif
#ifndef _tsizeof
#define _tsizeof(s) sizeof(s)/sizeof(TCHAR)
#endif
#include "UIFixTB.h"
// fwd ref
struct DROPDOWNBUTTON;
#define CFlatToolBarBase CFixMFCToolBar
//////////////////
// CFlatToolbar is a drop-in replacement for CToolBar that supports
// flat-style buttons and gripper handles. Use instead of CToolBar in your
// CMainFrame. CFlatTooBar's don'tK actually have to have the flat style,
// but they do by default. If you don't want the flat look, you can call
// ModifyStyle(TBSTYLE_FLAT, 0);
//
// CFlatToolBar overcomes various MFC drawing bugs that cause it not to work
// with flat-style buttons. CFlatToolBar Can also used inside a coolbar
// (unlike CToolBar).
//
// CFlatToolBar has other good stuff too, like an easy way to handle drop-down
// buttons--See MBTest for example how to use.
//
class CTRL_EXT_CLASS CFlatToolBar : public CFlatToolBarBase {
public:
CFlatToolBar();
virtual ~CFlatToolBar();
static BOOL bTRACE; // to see TRACE diagnostics
// set these before creation:
BOOL m_bDrawDisabledButtonsInColor; // draw disabled buttons in color
BOOL m_bInCoolBar; // set if flatbar is inside coolbar
// You must call one of these to get the flat look; if not, you must
// set TBSTYLE_FLAT yourself.
BOOL LoadToolBar(LPCTSTR lpszResourceName);
BOOL LoadToolBar(UINT nIDResource)
{ return LoadToolBar(MAKEINTRESOURCE(nIDResource)); }
// call to add drop-down buttons
BOOL AddDropDownButton(UINT nIDButton, UINT nIDMenu, BOOL bArrow);
// Use these to get/set the flat style. By default, LoadToolBar calls
// SetFlatStyle(TRUE); if you create some other way, you must call it
// yourself.
BOOL SetFlatStyle(BOOL bFlat) {
return ModifyStyle(bFlat ? 0 : TBSTYLE_FLAT, bFlat ? TBSTYLE_FLAT : 0);
}
BOOL GetFlatStyle() {
return (GetStyle() & TBSTYLE_FLAT)!=0;
}
// silly function to fake out compiler with const-ness
LRESULT SendMessageC(UINT m, WPARAM wp=0, LPARAM lp=0) const
{ return ((CFixMFCToolBar*)this)->SendMessage(m, wp, lp); }
// Wrappers that are not in MFC but should be;
// I copied these from CToolBarCtrl
BOOL EnableButton(int nID, BOOL bEnable)
{ return SendMessage(TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); }
BOOL CheckButton(int nID, BOOL bCheck)
{ return SendMessage(TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); }
BOOL PressButton(int nID, BOOL bPress)
{ return SendMessage(TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); }
BOOL HideButton(int nID, BOOL bHide)
{ return SendMessage(TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); }
BOOL Indeterminate(int nID, BOOL bIndeterminate)
{ return SendMessage(TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); }
BOOL IsButtonEnabled(int nID) const
{ return SendMessageC(TB_ISBUTTONENABLED, nID); }
BOOL IsButtonChecked(int nID) const
{ return SendMessageC(TB_ISBUTTONCHECKED, nID); }
BOOL IsButtonPressed(int nID) const
{ return SendMessageC(TB_ISBUTTONPRESSED, nID); }
BOOL IsButtonHidden(int nID) const
{ return SendMessageC(TB_ISBUTTONHIDDEN, nID); }
BOOL IsButtonIndeterminate(int nID) const
{ return SendMessageC(TB_ISBUTTONINDETERMINATE, nID); }
BOOL SetState(int nID, UINT nState)
{ return SendMessage(TB_SETSTATE, nID, MAKELPARAM(nState, 0)); }
int GetState(int nID) const
{ return SendMessageC(TB_GETSTATE, nID); }
BOOL AddButtons(int nNumButtons, LPTBBUTTON lpButtons)
{ return SendMessage(TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); }
BOOL InsertButton(int nIndex, LPTBBUTTON lpButton)
{ return SendMessage(TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); }
BOOL DeleteButton(int nIndex)
{ return SendMessage(TB_DELETEBUTTON, nIndex); }
int GetButtonCount() const
{ return SendMessageC(TB_BUTTONCOUNT); }
UINT CommandToIndex(UINT nID) const
{ return SendMessageC(TB_COMMANDTOINDEX, nID); }
void Customize()
{ SendMessage(TB_CUSTOMIZE, 0, 0L); }
int AddStrings(LPCTSTR lpszStrings)
{ return SendMessage(TB_ADDSTRING, 0, (LPARAM)lpszStrings); }
void SetButtonStructSize(int nSize)
{ SendMessage(TB_BUTTONSTRUCTSIZE, nSize); }
BOOL SetButtonSize(CSize sz)
{ return SendMessage(TB_SETBUTTONSIZE, 0, MAKELPARAM(sz.cx, sz.cy)); }
BOOL SetBitmapSize(CSize sz)
{ return SendMessage(TB_SETBITMAPSIZE, 0, MAKELPARAM(sz.cx, sz.cy)); }
void AutoSize()
{ SendMessage(TB_AUTOSIZE); }
CToolTipCtrl* GetToolTips() const
{ return (CToolTipCtrl*)CWnd::FromHandle((HWND)SendMessageC(TB_GETTOOLTIPS)); }
void SetToolTips(CToolTipCtrl* pTip)
{ SendMessage(TB_SETTOOLTIPS, (WPARAM)pTip->m_hWnd); }
// NO!!!--this is not the same as the MFC owner
// void SetOwner(CWnd* pWnd)
// { SendMessage(TB_SETPARENT, (WPARAM)pWnd->m_hWnd); }
void SetRows(int nRows, BOOL bLarger, LPRECT lpRect)
{ SendMessage(TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); }
int GetRows() const
{ return (int) SendMessageC(TB_GETROWS); }
BOOL SetCmdID(int nIndex, UINT nID)
{ return SendMessage(TB_SETCMDID, nIndex, nID); }
UINT GetBitmapFlags() const
{ return (UINT) SendMessageC(TB_GETBITMAPFLAGS); }
// Wrappers for some of the newer messages--not complete
BOOL SetIndent(int indent)
{ return SendMessage(TB_SETINDENT, indent); }
HIMAGELIST GetImageList() const
{ return (HIMAGELIST)SendMessageC(TB_GETIMAGELIST); }
HIMAGELIST SetImageList(HIMAGELIST hImgList)
{ return (HIMAGELIST)SendMessage(TB_SETIMAGELIST, 0, (LPARAM)hImgList); }
int GetBitmap(UINT nIdButton) const
{ return SendMessageC(TB_GETBITMAP, nIdButton); }
DWORD SetExtendedStyle(DWORD dwStyle)
{ return SendMessage(TB_SETEXTENDEDSTYLE, 0, dwStyle); }
BOOL GetRect(UINT nIdButton, RECT& rc) const
{ return SendMessageC(TB_GETRECT, nIdButton, (LPARAM)&rc); }
DWORD GetToolbarStyle() const
{ return SendMessageC(TB_GETSTYLE); }
void SetToolbarStyle(DWORD dwStyle)
{ SendMessage(TB_SETSTYLE, 0, dwStyle); }
int HitTest(CPoint p) const
{ return SendMessageC(TB_HITTEST, 0, (LPARAM)&p); }
int GetHotItem() const
{ if (GetSafeHwnd()) return SendMessageC(TB_GETHOTITEM); return 0; }
void SetHotItem(int iHot)
{ if (GetSafeHwnd()) SendMessage(TB_SETHOTITEM, iHot); }
BOOL MapAccelerator(TCHAR ch, UINT& nID) const
{ return SendMessageC(TB_MAPACCELERATOR, (WPARAM)ch, (LPARAM)&nID); }
CSize GetPadding() const
{ return SendMessageC(TB_GETPADDING); }
CSize SetPadding(CSize sz)
{ return SendMessage(TB_SETPADDING, 0, MAKELPARAM(sz.cx,sz.cy)); }
protected:
CRect m_rcOldPos; // used when toolbar is moved
DROPDOWNBUTTON* m_pDropDownButtons; // list of dropdown button/menu pairs
BOOL m_bNoEntry; // implementation hack
// override to do your own weird drop-down buttons
virtual void OnDropDownButton(const NMTOOLBAR& nmtb, UINT nID, CRect rc);
DROPDOWNBUTTON* FindDropDownButton(UINT nID);
// helpers
virtual void InvalidateOldPos(const CRect& rcInvalid);
afx_msg int OnCreate(LPCREATESTRUCT lpcs);
afx_msg void OnTbnDropDown(NMHDR* pNMHDR, LRESULT* pRes);
afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
afx_msg void OnWindowPosChanged(LPWINDOWPOS lpWndPos);
afx_msg void OnNcCalcSize(BOOL bCalc, NCCALCSIZE_PARAMS* pncp );
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpcs);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CFlatToolBar)
};
#endif
@@ -1,47 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __UI_FOLDER_REFRESH_H__
#define __UI_FOLDER_REFRESH_H__
class CTRL_EXT_CLASS CRefresh : public CObject
{
DECLARE_DYNAMIC(CRefresh)
public:
CRefresh(HTREEITEM hItem,LPARAM lParam) : m_hItem(hItem), m_lParam(lParam) {};
~CRefresh() {};
LPARAM GetExtData() const { return m_lParam; }
HTREEITEM GetItem() const { return m_hItem; }
private:
LPARAM m_lParam;
HTREEITEM m_hItem;
};
class CTRL_EXT_CLASS CRefreshCategory : public CRefresh
{
DECLARE_DYNAMIC(CRefreshCategory)
public:
CRefreshCategory(HTREEITEM hItem,LPARAM lParam,long nCategory=0)
: m_nCategory(nCategory),CRefresh(hItem,lParam)
{}
public:
long GetCategory() const { return m_nCategory; }
private:
long m_nCategory;
};
#endif //__UI_FOLDER_REFRESH_H__
@@ -1,134 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_SPAWNFRAMEWND_H__13CAB7C3_D316_11D1_8693_000000000000__INCLUDED_)
#define AFX_SPAWNFRAMEWND_H__13CAB7C3_D316_11D1_8693_000000000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// SpawnFrameWnd.h : header file
//
#include "UIStatusBar.h"
#include "UIFlatBar.h"
#include "UICoolMenu.h"
#include "UICoolBar.h"
#include "UIMenuBar.h"
#include "IEShellComboBox.h"
/////////////////////////////////////////////////////////////////////////////
// CUIFrameWnd frame
class CTRL_EXT_CLASS CToolBarComboBox : public CIEShellComboBox
{
public:
protected:
DECLARE_MESSAGE_MAP()
private:
};
class CTRL_EXT_CLASS CReallyCoolBar : public CCoolBar
{
protected:
DECLARE_DYNAMIC(CReallyCoolBar)
CFlatToolBar m_wndToolBar; // toolbar
CMenuBar m_wndMenuBar; // menu bar
virtual BOOL OnCreateBands(); // fn to create the bands
void SetToolBarID(UINT IDToolbar);
protected:
UINT m_IDToolbar;
};
class CTRL_EXT_CLASS CWebBrowserCoolBar : public CReallyCoolBar
{
protected:
DECLARE_DYNAMIC(CWebBrowserCoolBar)
CFlatToolBar m_wndBrowserBar; // toolbar
virtual BOOL OnCreateBands(); // fn to create the bands
CToolBarComboBox &GetComboBox() { return m_wndCombo; }
protected:
CToolBarComboBox m_wndCombo;
CString m_sCBValue;
};
class CTRL_EXT_CLASS CUIFrameWnd : public CFrameWnd
{
DECLARE_DYNAMIC(CUIFrameWnd)
protected:
CUIFrameWnd(); // protected constructor used by dynamic creation
// Attributes
public:
// COOLMENU SUPPORT
// END COOLMENU SUPPORT
CDialogBar m_wndFieldChooser;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUIFrameWnd)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void GetMessageString( UINT nID, CString& rMessage ) const;
//}}AFX_VIRTUAL
virtual CUIStatusBar &GetStatusBar();
virtual CReallyCoolBar &GetCoolBar();
virtual CCoolMenuManager &GetMenuManager();
virtual void RestoreWindow(UINT nCmdShow);
// Implementation
protected:
virtual ~CUIFrameWnd();
virtual void CreateCoolBar();
void SetReportCtrl(bool bSet);
// Generated message map functions
//{{AFX_MSG(CUIFrameWnd)
afx_msg void OnClose();
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
//}}AFX_MSG
afx_msg LRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnCBIESelChange(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnCBIEPopulate(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnCBIEHitEnter(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnCBIESetEditText(WPARAM wParam,LPARAM lParam);
DECLARE_MESSAGE_MAP()
protected:
UINT m_IDToolbar;
CReallyCoolBar *m_pwndCoolBar;
private:
CUIStatusBar m_wndStatusBar;
CCoolMenuManager m_menuManager; // cool (bitmap button) menus
bool m_bReportCtrl;
static LPCTSTR szMainFrame;
};
inline void CUIFrameWnd::SetReportCtrl(bool bSet)
{
m_bReportCtrl = bSet;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SPAWNFRAMEWND_H__13CAB7C3_D316_11D1_8693_000000000000__INCLUDED_)
@@ -1,141 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_HTMLMSGVIEW_H__4A8E5045_F2AC_47AE_A24D_584CB7D9D084__INCLUDED_)
#define AFX_HTMLMSGVIEW_H__4A8E5045_F2AC_47AE_A24D_584CB7D9D084__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// HtmlMsgView.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CUIHtmlView html view
interface IHTMLDocument2;
interface IHTMLElement;
interface IHTMLImgElement;
interface IHTMLObjectElement;
#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
#include <afxhtml.h>
#include <comdef.h>
class CTRL_EXT_CLASS CUIHtmlView : public CHtmlView
{
protected:
CUIHtmlView(); // protected constructor used by dynamic creation
DECLARE_DYNAMIC(CUIHtmlView)
// html Data
public:
//{{AFX_DATA(CUIHtmlView)
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Attributes
public:
void SetNotifyWnd(HWND hwnd);
bool IsWorking() { return m_pHTMLDocument2 == NULL; }
IHTMLDocument2 *GetHTMLDocument();
void GetElement(LPCTSTR pszID,IHTMLElement **pElement);
CString GetBodyText();
// Operations
public:
virtual bool ExecScript(LPCTSTR pszScript,LPCTSTR pszLang=NULL,_variant_t *pvt=NULL);
virtual bool SetElementText(LPCTSTR pszElemID,LPCTSTR pszText);
virtual bool SetElementHTML(LPCTSTR pszElemID,LPCTSTR pszText);
virtual bool SetElementValue(LPCTSTR pszElemID,LPCTSTR pszText);
virtual bool SetImageSource(LPCTSTR pszElemID,LPCTSTR pszText);
virtual bool AddOptionString(LPCTSTR pszElemID,LPCTSTR pszText,LPCTSTR pszValue,bool bSelect=false);
virtual bool SetOptionString(LPCTSTR pszElemID,LPCTSTR pszText);
virtual bool GetOptionString(LPCTSTR pszElemID,CString &sText,CString &sValue);
virtual CString GetElementText(LPCTSTR pszElemID);
virtual CString GetElementHTML(LPCTSTR pszElemID);
virtual CString GetElementValue(LPCTSTR pszElemID);
virtual void ParseDocument();
protected:
virtual void DocumentReady();
virtual void ActiveXControl(IHTMLObjectElement *pObj);
virtual void ImageElement(IHTMLImgElement *pImg);
virtual void Element(IHTMLElement *pElement);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUIHtmlView)
public:
virtual void OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel);
virtual void OnCommandStateChange(long nCommand, BOOL bEnable);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void DocumentComplete(LPDISPATCH pDisp, VARIANT* URL);
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
virtual void OnTitleChange(LPCTSTR lpszText);
virtual void OnDocumentComplete(LPCTSTR lpszUrl);
//}}AFX_VIRTUAL
// Implementation
protected:
void ReleaseDocument();
virtual ~CUIHtmlView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(CUIHtmlView)
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnBrowserGoBack();
afx_msg void OnBrowserGoForward();
afx_msg void OnBrowserGoHome();
afx_msg void OnBrowserRefresh();
afx_msg void OnBrowserStop();
afx_msg void OnUpdateBrowserGoBack(CCmdUI *pUI);
afx_msg void OnUpdateBrowserGoForward(CCmdUI *pUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
IHTMLDocument2 *m_pHTMLDocument2;
BOOL m_bDocumentComplete;
BOOL m_bGoBack;
BOOL m_bGoForward;
HWND m_hNotifyWnd;
bool m_bSetCursor;
};
inline void CUIHtmlView::SetNotifyWnd(HWND hwnd)
{
m_hNotifyWnd = hwnd;
}
inline IHTMLDocument2 *CUIHtmlView::GetHTMLDocument()
{
ASSERT(m_pHTMLDocument2);
return m_pHTMLDocument2;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_HTMLMSGVIEW_H__4A8E5045_F2AC_47AE_A24D_584CB7D9D084__INCLUDED_)
@@ -1,106 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_IM_OLEIMAGEDROPTARGET_H__BC21D3A1_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)
#define AFX_IM_OLEIMAGEDROPTARGET_H__BC21D3A1_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// IM_OleImageDropTarget.h : header file
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CUI_ImageDropTarget window
#include "UIDragDropCtrl.h"
class CDragDropImage;
class CUI_ImageDropTarget : public COleDropTarget
{
// Construction
public:
CUI_ImageDropTarget();
// Attributes
public:
inline UINT GetClipboardFormat() const;
inline BOOL ImageSetup() const;
// Operations
public:
// Overrides
virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
virtual void OnDragLeave( CWnd* pWnd);
// Implementation
public:
virtual ~CUI_ImageDropTarget();
void EraseOldImage();
void SetImageWin(CWnd *pWnd);
protected:
const CDragDropImage *GetDropImage();
CWnd *GetImageWin(CWnd *pWnd);
private:
int m_nImage;
CRect m_rcTotalItem;
CPoint m_ptItem;
CPoint m_ptPrevPos;
CPoint m_ptOldImage;
CSize m_sizeDelta;
CDragDropImage *m_pImage;
UINT m_nCFFormat;
CWnd *m_pWnd;
};
inline UINT CUI_ImageDropTarget::GetClipboardFormat() const
{
return m_nCFFormat;
}
inline const CDragDropImage *CUI_ImageDropTarget::GetDropImage()
{
return m_pImage;
}
inline void CUI_ImageDropTarget::SetImageWin(CWnd *pWnd)
{
m_pWnd = pWnd;
}
inline CWnd *CUI_ImageDropTarget::GetImageWin(CWnd *pWnd)
{
// use main frame window as default
if (m_pWnd == NULL)
m_pWnd = pWnd;
ASSERT(m_pWnd);
return m_pWnd;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IM_OLEIMAGEDROPTARGET_H__BC21D3A1_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)
@@ -1,93 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_UILISTVIEW__6016F537_2DF1_11D2_A412_E0317E000000__INCLUDED_)
#define AFX_UILISTVIEW__6016F537_2DF1_11D2_A412_E0317E000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/////////////////////////////////////////////////////////////////////////////
// CUIListView view
#include "UICtrl.h"
class CTRL_EXT_CLASS CUIListView : public CView
{
protected:
CUIListView(UINT nID); // protected constructor used by dynamic creation
DECLARE_DYNAMIC(CUIListView)
// Attributes
public:
virtual CUIODListCtrl &GetListCtrl();
virtual void CreateListCtrl();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUIListView)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
protected:
void SetDragDrop(bool bDragDrop);
bool IsDragDrop();
virtual ~CUIListView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CUIListView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
afx_msg LRESULT OnAppUpdateAllViews( WPARAM wParam, LPARAM lParam );
DECLARE_MESSAGE_MAP()
protected:
CUIODListCtrl *m_pListCtrl;
UINT m_Style;
UINT m_nID;
private:
bool m_bDragDrop;
};
inline void CUIListView::SetDragDrop(bool bDragDrop)
{
m_bDragDrop = bDragDrop;
}
inline bool CUIListView::IsDragDrop()
{
return m_bDragDrop;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_UILISTVIEW__6016F537_2DF1_11D2_A412_E0317E000000__INCLUDED_)
@@ -1,125 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
#ifndef __MENUBAR_H
#define __MENUBAR_H
#include "UIsubclass.h"
#include "UIFlatBar.h"
//////////////////
// CMenuBar uses this private class to intercept messages on behalf
// of its owning frame, as well as the MDI client window. Conceptually,
// these should be two different hooks, but I want to save code.
//
class CMenuBarFrameHook : public CSubclassWnd {
protected:
friend class CMenuBar;
CMenuBar* m_pMenuBar;
CMenuBarFrameHook();
~CMenuBarFrameHook();
BOOL Install(CMenuBar* pMenuBar, HWND hWndToHook);
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
};
//////////////////
// CMenuBar implements an Office 97-style menu bar. Use it the way you would
// a CToolBar, only you need not call LoadToolbar. All you have to do is
//
// * Create the CMenuBar from your OnCreate or OnCreateBands handler.
//
// * Call LoadMenu to load a menu. This will set your frame's menu to NULL.
//
// * Implemenent your frame's PreTranslateMessage function, to call
// CMenuBar::TranslateFrameMessage.
//
class CTRL_EXT_CLASS CMenuBar : public CFlatToolBar {
public:
BOOL m_bAutoRemoveFrameMenu; // set frame's menu to NULL
CMenuBar();
~CMenuBar();
// You must call this from your frame's PreTranslateMessage fn
virtual BOOL TranslateFrameMessage(MSG* pMsg);
HMENU LoadMenu(HMENU hmenu); // load menu
HMENU LoadMenu(LPCTSTR lpszMenuName); // ...from resource file
HMENU LoadMenu(UINT nID) {
return LoadMenu(MAKEINTRESOURCE(nID));
}
HMENU GetMenu() { return m_hmenu; } // get current menu
enum TRACKINGSTATE { // menubar has three states:
TRACK_NONE = 0, // * normal, not tracking anything
TRACK_BUTTON, // * tracking buttons (F10/Alt mode)
TRACK_POPUP // * tracking popups
};
TRACKINGSTATE GetTrackingState(int& iPopup) {
iPopup = m_iPopupTracking; return m_iTrackingState;
}
static BOOL bTRACE; // set TRUE to see TRACE msgs
protected:
friend class CMenuBarFrameHook;
CMenuBarFrameHook m_frameHook; // hooks frame window messages
CStringArray m_arStrings; // array of menu item names
HMENU m_hmenu; // the menu
// menu tracking stuff:
int m_iPopupTracking; // which popup I'm tracking if any
int m_iNewPopup; // next menu to track
BOOL m_bProcessRightArrow; // process l/r arrow keys?
BOOL m_bProcessLeftArrow; // ...
BOOL m_bEscapeWasPressed; // user pressed escape to exit menu
CPoint m_ptMouse; // mouse location when tracking popup
HMENU m_hMenuTracking; // current popup I'm tracking
TRACKINGSTATE m_iTrackingState; // current tracking state
// helpers
void RecomputeToolbarSize();
void RecomputeMenuLayout();
void UpdateFont();
int GetNextOrPrevButton(int iButton, BOOL bPrev);
void SetTrackingState(TRACKINGSTATE iState, int iButton=-1);
void TrackPopup(int iButton);
void ToggleTrackButtonMode();
void CancelMenuAndTrackNewOne(int iButton);
void OnMenuSelect(HMENU hmenu, UINT nItemID);
CPoint ComputeMenuTrackPoint(const CRect& rcButn, TPMPARAMS& tpm);
BOOL IsValidButton(int iButton) const
{ return 0 <= iButton && iButton < GetButtonCount(); }
virtual BOOL OnMenuInput(MSG& m); // handle popup menu input
// overrides
virtual void OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle);
int HitTest(CPoint p) const;
// command/message handlers
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnUpdateMenuButton(CCmdUI* pCmdUI);
afx_msg LRESULT OnSetMenuNull(WPARAM wp, LPARAM lp);
static LRESULT CALLBACK MenuInputFilter(int code, WPARAM wp, LPARAM lp);
DECLARE_DYNAMIC(CMenuBar)
DECLARE_MESSAGE_MAP()
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};
#endif
@@ -1,68 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// General
#define WM_APP_UPDATE_ALL_VIEWS WM_APP+1001
#define WM_APP_UPDATE_STATUS WM_APP+1002
#define WM_APP_RESIZE WM_APP+1003
#define WM_APP_SHELL_INIT_POPUP WM_APP+1004
#define WM_APP_CB_IE_HIT_ENTER WM_APP+1005
#define WM_APP_CB_IE_POPULATE WM_APP+1006
#define WM_APP_CB_IE_SEL_CHANGE WM_APP+1007
#define WM_APP_CB_IE_SET_EDIT_TEXT WM_APP+1008
#define WM_UPDATEHEADERWIDTH WM_APP+1020
#define WM_HEADERWIDTHCHANGED WM_APP+1021
// Keyboard
#define WM_APP_ON_CONTEXT_MENU_KEY WM_APP+1100
#define WM_APP_ON_BACKSPACE_KEY WM_APP+1101
#define WM_APP_ON_EDIT_KEY WM_APP+1102
#define WM_APP_ON_REFRESH_KEY WM_APP+1103
#define WM_APP_ON_DELETE_KEY WM_APP+1104
#define WM_APP_ON_PROPERTIES_KEY WM_APP+1105
// Internet
#define WM_APP_INET_PAGE_READY WM_APP+1501
#define WM_APP_INET_STATUS WM_APP+1502
// OLE drag and drop
#define WM_APP_OLE_DD_ENTER WM_APP+2001
#define WM_APP_OLE_DD_LEAVE WM_APP+2002
#define WM_APP_OLE_DD_DROP WM_APP+2003
#define WM_APP_OLE_DD_OVER WM_APP+2004
#define WM_APP_OLE_DD_DODRAGDROP WM_APP+2005
// Tab views
#define WM_APP_TAB_SEL_CHANGE WM_APP+3001
#define WM_APP_TAB_UPDATE_VIEWS WM_APP+3002
// Tree control
#define WM_APP_DD_ADD_FOLDER_ITEMS WM_APP+4001
#define WM_APP_DD_NEW_FOLDER_ITEM WM_APP+4002
#define WM_APP_NEW_FOLDER WM_APP+4003
#define WM_APP_DIR_CHANGE_EVENT WM_APP+4006
#define WM_APP_TIMER_SEL_CHANGE WM_APP+4007
#define WM_APP_POPULATE_TREE WM_APP+4008
// List Control
#define WM_APP_FILE_CHANGE_EVENT WM_APP+5001
#define WM_APP_FILE_CHANGE_NEW_PATH WM_APP+5002
// Tray Icon
#define WM_APP_TRAY_NOTIFY WM_APP+6001
// Hints for UpdateAllViews
#define HINT_BASE_CTRL_EXT 1000
#define HINT_TREE_SEL_CHANGED HINT_BASE_CTRL_EXT+1
#define HINT_TREE_INTERNET_FOLDER_SELECTED HINT_BASE_CTRL_EXT+2
#define HINT_SHELL_FILE_CHANGED HINT_BASE_CTRL_EXT+3
#define HINT_SHELL_DIR_CHANGED HINT_BASE_CTRL_EXT+4
#define HINT_STATUS_BAR_TEXT HINT_BASE_CTRL_EXT+5
@@ -1,64 +0,0 @@
////////////////////////////////////////////////////////////////
// 1998 Microsoft Systems Journal
//
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
#ifndef __MODULEVER_H
#define __MODULEVER_H
//#undef _INC_SHLWAPI
//#undef NOSHLWAPI
#include <shlwapi.h>
// tell linker to link with version.lib for VerQueryValue, etc.
#pragma comment(linker, "/defaultlib:version.lib")
#ifndef DLLVER_PLATFORM_WINDOWS
#error ModuleVer.h requires a newer version of the SDK than you have!
#error Please update your SDK files.
#endif
//////////////////
// This class loads a library. Destructor frees for automatic cleanup.
//
class CTRL_EXT_CLASS CLoadLibrary {
private:
HINSTANCE m_hinst;
public:
CLoadLibrary(LPCTSTR lpszName) : m_hinst(LoadLibrary(lpszName)) { }
~CLoadLibrary() { FreeLibrary(m_hinst); }
operator HINSTANCE () { return m_hinst; } // cast operator
};
//////////////////
// CModuleVersion version info about a module.
// To use:
//
// CModuleVersion ver
// if (ver.GetFileVersionInfo("_T("mymodule))) {
// // info is in ver, you can call GetValue to get variable info like
// CString s = ver.GetValue(_T("CompanyName"));
// }
//
// You can also call the static fn DllGetVersion to get DLLVERSIONINFO.
//
class CTRL_EXT_CLASS CModuleVersion : public VS_FIXEDFILEINFO {
protected:
BYTE* m_pVersionInfo; // all version info
struct TRANSLATION {
WORD langID; // language ID
WORD charset; // character set (code page)
} m_translation;
public:
CModuleVersion();
virtual ~CModuleVersion();
BOOL GetFileVersionInfo(LPCTSTR modulename);
CString GetValue(LPCTSTR lpKeyName);
static BOOL DllGetVersion(LPCTSTR modulename, DLLVERSIONINFO& dvi);
};
#endif
@@ -1,307 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __STATUSBAROPTIONS_H__
#define __STATUSBAROPTIONS_H__
// CStatusBarPane holds the information required for each pane
// if m_bActive is false the pane will not be shown
typedef CList<int,int> CListImages;
class CStatusBarPane : public CObject
{
DECLARE_SERIAL(CStatusBarPane)
public:
CStatusBarPane();
CStatusBarPane(UINT nID,BOOL bActive);
CStatusBarPane(const CStatusBarPane &rOther);
virtual ~CStatusBarPane();
BOOL IsPaneActive() const;
UINT GetCommandID() const;
UINT GetStyle() const;
void SetPaneActive(BOOL bActive);
void AddImage(int nIndex);
void SetStyle(UINT nStyle);
void RemoveImage(int nIndex);
bool FindImage(int nIndex);
void RemoveAllImages();
CListImages &GetImageIndex();
CStatusBarPane &operator=(const CStatusBarPane &rOther);
// Overrides
virtual void Serialize(CArchive &ar);
private:
void DoCopy(const CStatusBarPane &rOther);
private:
UINT m_nID;
UINT m_nStyle;
BOOL m_bActive;
// Icons
CListImages m_listImageIndex;
};
inline CStatusBarPane::CStatusBarPane()
{
}
inline CStatusBarPane::CStatusBarPane(UINT nID,BOOL bActive)
: m_nID(nID),
m_bActive(bActive)
{
m_nStyle = SBPS_NORMAL;
}
inline CStatusBarPane::~CStatusBarPane()
{
}
inline void CStatusBarPane::SetStyle(UINT nStyle)
{
m_nStyle = nStyle;
}
inline UINT CStatusBarPane::GetStyle() const
{
return m_nStyle;
}
inline void CStatusBarPane::SetPaneActive(BOOL bActive)
{
m_bActive = bActive;
}
inline bool CStatusBarPane::FindImage(int nIndex)
{
return m_listImageIndex.Find(nIndex) != NULL;
}
// index into an ImageList
inline void CStatusBarPane::AddImage(int nIndex)
{
m_listImageIndex.AddHead(nIndex);
}
inline void CStatusBarPane::RemoveAllImages()
{
m_listImageIndex.RemoveAll();
}
inline void CStatusBarPane::RemoveImage(int nIndex)
{
POSITION pos = m_listImageIndex.Find(nIndex);
if (pos != NULL)
{
m_listImageIndex.RemoveAt(pos);
}
}
inline CListImages &CStatusBarPane::GetImageIndex()
{
return m_listImageIndex;
}
inline BOOL CStatusBarPane::IsPaneActive() const
{
return m_bActive;
}
inline UINT CStatusBarPane::GetCommandID() const
{
return m_nID;
}
// A configurable status bar that will show its own popup menu to configure it.
// You initially add all the panes and then by using the popup menu you can show or
// hide individual panes. The state can be saved to the registry.
class CTRL_EXT_CLASS CUIStatusBar : public CStatusBar
{
DECLARE_SERIAL(CUIStatusBar)
public:
// Construction
CUIStatusBar();
~CUIStatusBar();
void Init();
void Reset();
void Load();
void Save();
void AddPane(UINT nID,BOOL bActive);
BOOL IsValidPaneID(UINT nID) const;
BOOL IsPaneActive(UINT nID) const;
CStatusBarPane *GetPane(UINT nPaneID) const;
BOOL SetPanes(BOOL bSave);
int GetPaneIndex(UINT nID) const;
UINT GetPaneID(int nPaneIndex);
UINT GetStyle(UINT nID) const;
void TogglePane(UINT nID);
void SetImageList(UINT nBitmapID);
void SetImageList(CImageList *pImageList);
void CreateImageList();
void AddIcon(UINT nPaneID,UINT nImageID,bool bUpdate=true);
void RemoveIcon(UINT nPaneID,UINT nImageID,bool bUpdate=true);
void SetStyle(UINT nID,UINT nStyle);
void Clear();
void CopyBar(const CUIStatusBar &rOtherBar);
BOOL IsPanes();
void UpdatePane(int nIndex);
void SetText(UINT nPaneID,LPCTSTR szText,bool bUpdate);
void RemoveAllIcons(UINT nPaneID);
// Overrides
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual void Serialize(CArchive& ar);
protected:
void RemoveIcon(UINT nImageID,CStatusBarPane *pPane,bool bUpdate);
void AddImageIndex(UINT nPaneID,int nIndex,bool bUpdate);
int AddIcon(UINT nID);
int AddIcon(HICON hIcon);
void SetTextPane(const CStatusBarPane *pPane,LPCTSTR szText,bool bUpdate=true);
public:
// Main Pane
UINT m_nStatusPane1ID;
UINT m_nStatusPane1Style;
INT m_nStatusPane1Width;
BOOL m_bMenuSelect;
private:
static LPCTSTR szSection;
static LPCTSTR szPaneEntry;
CList<CStatusBarPane*,CStatusBarPane*> m_PaneList;
CImageList *m_pImageList;
//{{AFX_MSG(CUIStatusBar)
afx_msg void OnContextMenu(CWnd *pWnd, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CUIStatusBar &operator=(const CUIStatusBar &rOther);
CMap<UINT,UINT,int,int> m_mapImageIndex;
};
inline BOOL CUIStatusBar::IsPanes()
{
return !m_PaneList.IsEmpty();
}
inline void CUIStatusBar::CopyBar(const CUIStatusBar &rOtherBar)
{
*this = rOtherBar;
}
inline void CUIStatusBar::SetStyle(UINT nID,UINT nStyle)
{
CStatusBarPane *pPane = GetPane(nID);
ASSERT(pPane);
int nIndex = GetPaneIndex(nID);
UINT nOldStyle;
int nWidth;
GetPaneInfo(nIndex,nID,nOldStyle,nWidth);
SetPaneInfo(nIndex,nID,nStyle,nWidth);
pPane->SetStyle(nStyle);
}
inline UINT CUIStatusBar::GetStyle(UINT nID) const
{
const CStatusBarPane *pPane = GetPane(nID);
ASSERT(pPane);
return pPane->GetStyle();
}
inline int CUIStatusBar::GetPaneIndex(UINT nID) const
{
int nIndex = CommandToIndex(nID);
return nIndex;
}
inline BOOL CUIStatusBar::IsPaneActive(UINT nID) const
{
const CStatusBarPane *pPane = GetPane(nID);
ASSERT(pPane);
return pPane ? pPane->IsPaneActive() : FALSE;
}
inline UINT CUIStatusBar::GetPaneID(int nPaneIndex)
{
UINT nID,nStyle;
int nWidth;
GetPaneInfo(nPaneIndex,nID,nStyle,nWidth);
return nID;
}
inline BOOL CUIStatusBar::IsValidPaneID(UINT nID) const
{
if (nID == ID_SEPARATOR)
return FALSE;
const CStatusBarPane *pPane = GetPane(nID);
return pPane != NULL;
}
/////////////////////////////////////////////////////////////////////////////
// CProgressBar - status bar progress control
class CTRL_EXT_CLASS CProgressBar : public CProgressCtrl
// Creates a ProgressBar in the status bar
{
public:
CProgressBar();
CProgressBar(int nPaneID, CUIStatusBar *pStatusBar, int MaxValue = 100);
~CProgressBar();
BOOL Create(int nPaneID, CUIStatusBar *pStatusBar, int MaxValue=100);
DECLARE_DYNCREATE(CProgressBar)
// operations
public:
void SetRange(int nLower, int nUpper, int nStep = 1);
void SetSize(int nSize);
int SetPos(int nPos);
int OffsetPos(int nPos);
int SetStep(int nStep);
int StepIt();
void Clear();
// Overrides
//{{AFX_VIRTUAL(CProgressBar)
//}}AFX_VIRTUAL
// implementation
protected:
void Resize();
// Generated message map functions
protected:
//{{AFX_MSG(CProgressBar)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CUIStatusBar *m_pStatusBar;
int m_nPaneIndex;
};
inline void CProgressBar::SetSize(int nSize)
{
Resize();
}
#endif
@@ -1,61 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
#ifndef _SUBCLASSW_H
#define _SUBCLASSW_H
//////////////////
// Generic class to hook messages on behalf of a CWnd.
// Once hooked, all messages go to CSubclassWnd::WindowProc before going
// to the window. Specific subclasses can trap messages and do something.
//
// To use:
//
// * Derive a class from CSubclassWnd.
//
// * Override CSubclassWnd::WindowProc to handle messages. Make sure you call
// CSubclassWnd::WindowProc if you don't handle the message, or your
// window will never get messages. If you write seperate message handlers,
// you can call Default() to pass the message to the window.
//
// * Instantiate your derived class somewhere and call HookWindow(pWnd)
// to hook your window, AFTER it has been created.
// To unhook, call HookWindow(NULL).
//
// This is a very important class, crucial to many of the widgets Window
// widgets implemented in PixieLib. To see how it works, look at the HOOK
// sample program.
//
class CTRL_EXT_CLASS CSubclassWnd : public CObject {
public:
DECLARE_DYNAMIC(CSubclassWnd);
CSubclassWnd();
~CSubclassWnd();
// Subclass a window. Hook(NULL) to unhook (automatic on WM_NCDESTROY)
BOOL HookWindow(HWND hwnd);
BOOL HookWindow(CWnd* pWnd) { return HookWindow(pWnd->GetSafeHwnd()); }
BOOL IsHooked() { return m_hWnd!=NULL; }
friend LRESULT CALLBACK HookWndProc(HWND, UINT, WPARAM, LPARAM);
friend class CSubclassWndMap;
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
HWND m_hWnd; // the window hooked
WNDPROC m_pOldWndProc; // ..and original window proc
CSubclassWnd* m_pNext; // next in chain of hooks for this window
// Override this to handle messages in specific handlers
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
LRESULT Default(); // call this at the end of handler fns
};
#endif // _SUBCLASSW_H
@@ -1,79 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __TABSPLITTERWND_H__
#define __TABSPLITTERWND_H__
// This splitter bar is persistent and will restore the previous
// position and will also set the focus back to the previous pane
// after the bar has been respositioned
class CTRL_EXT_CLASS CTabSplitterWnd : public CSplitterWnd
{
DECLARE_DYNAMIC(CTabSplitterWnd)
public:
CTabSplitterWnd();
// for registry
void SetSection(LPCTSTR szSection);
// for workspace
void SetPropertyItem(CRuntimeClass *pPropertyItemClass);
void SetSize(int nCur,int nMin);
void Apply();
BOOL IsEmpty();
virtual void SaveSize();
virtual CWnd *GetActiveWnd();
public:
// Overrides
virtual void Serialize(CArchive& ar);
virtual BOOL CreateView( int row, int col, CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext );
virtual void ActivateNext(BOOL bPrev);
protected:
virtual void StopTracking(BOOL bAccept);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
// Generated message map functions
protected:
//{{AFX_MSG(CTabSplitterWnd)
afx_msg void OnClose();
afx_msg void OnDestroy();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
//}}AFX_MSG
LRESULT OnAppSplitterMouseWheel(WPARAM wParam,LPARAM lParam);
DECLARE_MESSAGE_MAP()
protected:
CString m_strSection;
int m_nCurRow;
int m_nCurCol;
int m_cxCur;
int m_cyCur;
int m_cxMin;
int m_cyMin;
private:
static LPCTSTR szSplitterSection;
static LPCTSTR szPaneWidthCurrent;
static LPCTSTR szPaneWidthMinimum;
static LPCTSTR szPaneHeightCurrent;
static LPCTSTR szPaneHeightMinimum;
};
inline CTabSplitterWnd::IsEmpty()
{
return m_nCols == 0 && m_nRows == 0;
}
#endif //__TABSPLITTERWND_H__
@@ -1,173 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_URLTREECTRL_H__9743E546_1F3A_11D2_A40D_9CB186000000__INCLUDED_)
#define AFX_URLTREECTRL_H__9743E546_1F3A_11D2_A40D_9CB186000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// URLTreeCtrl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CUITreeCtrl window
#include "UIFolderRefresh.h"
#include "UIDragDropTree.h"
#include "UIData.h"
class CTRL_EXT_CLASS CUITreeCtrl : public CUIDragDropTree
{
DECLARE_DYNAMIC(CUITreeCtrl)
// Construction
public:
CUITreeCtrl(bool bDragDrop=true);
// Attributes
public:
virtual void UpdateCurrentSelection();
void SetStyle(UINT nStyle);
void AddStyle(UINT nStyle);
DWORD GetItemData(HTREEITEM hItem) const;
BOOL SetItemData(HTREEITEM hItem,DWORD dwData,bool bAutoDelete=false);
void SetDefaultTextColor(HTREEITEM hItem);
void SetDefaultBkColor(HTREEITEM hItem);
void SetTextColor(HTREEITEM hItem,COLORREF TextColor);
void SetBkColor(HTREEITEM hItem,COLORREF BkColor);
void SetItemFont(HTREEITEM hItem,CFont *pFont);
void SetItemBold(HTREEITEM hItem,bool bBold);
// Operations
public:
virtual void Init();
virtual HTREEITEM AddAnItem(HTREEITEM hParent, LPCTSTR szText, LPARAM lParam, HTREEITEM hInsAfter,int iImage = 0,int iSelImage = 0,int nChildren = 0);
void SetPopupID(UINT nID);
void SetPopupWnd(CWnd *pWnd);
protected:
virtual void OnDeleteItemData(DWORD dwData);
virtual CUIListCtrlData *GetNewListCtrlData(DWORD dwData,HTREEITEM hParent);
virtual CUIListCtrlData *GetListCtrlData(HTREEITEM hItem) const;
virtual void ItemPostPaint(LPNMTVCUSTOMDRAW lptvcd,LRESULT *pResult);
virtual void ItemPrePaint(LPNMTVCUSTOMDRAW lptvcd,LRESULT *pResult);
virtual bool EndLabelEdit(HTREEITEM hItem,LPCTSTR pszText);
virtual HTREEITEM GetHitItem(CPoint *pt);
virtual UINT GetMenuID();
virtual CWnd *GetMenuWnd();
virtual bool Expanding(NM_TREEVIEW *nmtvw);
virtual bool Collapsing(NM_TREEVIEW *nmtvw);
virtual void UpdateEvent(LPARAM lHint,CObject *pHint);
virtual UINT GetIconID();
virtual UINT GetOpenIconID();
virtual void DoubleClick(HTREEITEM hItem);
virtual void SelectionChanged(HTREEITEM hItem,LPARAM lParam);
virtual CRefresh *CreateRefreshObject(HTREEITEM hItem,LPARAM lParam);
// OLE Drag and Drop
// This called when a drop source is dropped on the list control
virtual bool DragDrop(CDD_OleDropTargetInfo *pInfo);
// This called when a drop source is currently over the list control
// This called when a drop source is currently over the list control
virtual bool DragOver(CDD_OleDropTargetInfo *pInfo);
virtual bool DragEnter(CDD_OleDropTargetInfo *pInfo);
virtual bool DragLeave(CDD_OleDropTargetInfo *pInfo);
// This called when the user initiates a OLE drag and drop
virtual DROPEFFECT DoDragDrop(NM_TREEVIEW* pNMTreeView,COleDataSource *pOleDataSource);
virtual void DeleteKey(HTREEITEM hItem);
virtual void ShowPopupMenu(HTREEITEM hItem,CPoint point);
virtual void ShowProperties(HTREEITEM hItem);
virtual void Refresh();
virtual void GoBack(HTREEITEM hItem);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUITreeCtrl)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CUITreeCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CUITreeCtrl)
afx_msg BOOL OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnReturn(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnItemExpanded(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnItemExpanding(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnRclick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnDeleteItem(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnKeydownFolder(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg LRESULT OnTVMGetItem(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnTVMSetItem(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnTVMInsertItem(WPARAM wParam,LPARAM lParam);
//}}AFX_MSG
afx_msg LRESULT OnAppPropertiesKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppDeleteKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppRefreshKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppBackspaceKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppContextMenuKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppEditKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnTimerSelChange(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDragDrop(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDragOver(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDragEnter(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDragLeave(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDDDoDragDrop(WPARAM wParam,LPARAM lParam);
DECLARE_MESSAGE_MAP()
protected:
int m_idxClosed;
int m_idxOpen;
WORD m_vkeydown;
private:
CImageList m_ImageList;
NM_TREEVIEW m_NMTreeView;
LPARAM m_lParam;
UINT m_IDTimer;
UINT m_style;
HFONT m_hOrigFont;
bool m_bMe;
protected:
CWnd *m_pPopupWnd;
UINT m_PopupID;
};
inline void CUITreeCtrl::SetStyle(UINT nStyle)
{
m_style = nStyle;
}
inline void CUITreeCtrl::AddStyle(UINT nStyle)
{
m_style |= nStyle;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_URLTREECTRL_H__9743E546_1F3A_11D2_A40D_9CB186000000__INCLUDED_)
@@ -1,82 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_UITREEVIEW__6016F537_2DF1_11D2_A412_E0317E000000__INCLUDED_)
#define AFX_UITREEVIEW__6016F537_2DF1_11D2_A412_E0317E000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/////////////////////////////////////////////////////////////////////////////
// CUITreeView view
#include "UITreeCtrl.h"
class CTRL_EXT_CLASS CUITreeView : public CView
{
protected:
CUITreeView(UINT nID); // protected constructor used by dynamic creation
DECLARE_DYNAMIC(CUITreeView)
// Attributes
public:
virtual CUITreeCtrl &GetTreeCtrl();
virtual void CreateTreeCtrl();
protected:
virtual void SelectionChanged(const CRefresh &Refresh);
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUITreeView)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CUITreeView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CUITreeView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
afx_msg LRESULT OnAppUpdateAllViews( WPARAM wParam, LPARAM lParam );
DECLARE_MESSAGE_MAP()
protected:
CUITreeCtrl *m_pTreeCtrl;
private:
UINT m_Style;
UINT m_nID;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_UITREEVIEW__6016F537_2DF1_11D2_A412_E0317E000000__INCLUDED_)
@@ -1,95 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
#define IDB_DOMAIN 201
#define IDB_MACHINE 202
#define IDB_NETWORK 203
#define IDR_POPUPMENU_LISTCTRL 204
#define IDR_POPUPMENU_HEADERCTRL 205
#define IDI_CHECKMARK 206
#define IDB_MENUCHK 207
#define IDR_POPUPMENU_DRAGDROP 208
#define IDR_POPUPMENU_TREE_FOLDER 209
#define IDB_COLDTOOLBAR 210
#define IDB_HOTTOOLBAR 211
#define IDI_FOLDER_CLOSED 212
#define IDC_NODROP 213
#define IDB_REPORT 214
#define IDC_COLUMNLIST 215
#define ID_VIEW_FIELDCHOOSER 216
#define CG_IDC_PROGDLG_PROGRESS1 217
#define CG_IDC_PROGDLG_PROGRESS2 218
#define CG_IDC_PROGDLG_PERCENT1 219
#define CG_IDC_PROGDLG_PERCENT2 220
#define CG_IDC_PROGDLG_STATUS 221
#define IDC_FOP_LIST_ICONS 222
#define IDC_NETWORK 223
#define IDC_EDIT_NEW_CATEGORY 224
#define IDD_NEW_CATEGORY 225
#define IDC_UIOD_HAND 226
#define IDC_LIST_SEARCH 227
#define IDC_TREE_SHELL 228
#define IDC_LIST_SHELL 229
#define IDC_CB_IE_ADDRESS 230
#define CG_IDD_PROGRESS 1001
#define IDD_FILEOPENPREVIEW_ICON 1002
#define IDD_MACHINES 1003
#define IDD_FIELDCHOOSER 1004
#define IDC_IMAGE 1005
#define IDD_FILEOPENPREVIEW_IMAGE 1006
#define IDC_BUTT_SEARCH 1010
#define IDC_STATIC_STATUS 1011
#define IDC_BUTT_OPEN 1012
#define IDD_FILEOPENPREVIEW_SEARCH 1013
#define ID_SHELL_POPUP_FIRST 42500
#define ID_SHELL_POPUP_LAST 42600
#define ID_POPUP_DD_MOVE 42768
#define ID_POPUP_DD_COPY 42769
#define ID_POPUP_DD_CANCEL 42770
#define ID_UI_VIEW_LARGE_ICONS 42771
#define ID_UI_VIEW_SMALL_ICONS 42772
#define ID_UI_VIEW_DETAILS 42773
#define ID_UI_VIEW_LIST 42774
#define ID_UI_VIEW_GRIDLINES 42775
#define ID_UI_VIEW_FULL_SELECTION 42776
#define ID_UI_VIEW_CHECKBOXES 42777
#define ID_UI_VIEW_COLUMN_ORDERING 42778
#define ID_UI_VIEW_FULL_ROW_SELECTION 42779
#define ID_UI_VIEW_TRACK_SELECT 42780
#define ID_UI_VIEW_COLUMN_SIZING 42781
#define ID_HEADER_REMOVE_COL 42782
#define ID_HEADER_EDIT_TEXT 42783
#define ID_HEADER_RESET 42784
#define ID_UI_VIEW_EDIT_COLUMN 42786
#define ID_BROWSER_GO_BACK 42787
#define ID_BROWSER_GO_FORWARD 42788
#define ID_BROWSER_GO_HOME 42789
#define ID_BROWSER_REFRESH 42790
#define ID_BROWSER_STOP 42791
#define ID_BROWSER_SEARCH 42792
#define ID_BROWSER_FAVORITES 42793
#define IDS_BROWSER_GO_BACK 42794
#define IDS_BROWSER_GO_FORWARD 42795
#define IDS_BROWSER_GO_HOME 42796
#define IDS_BROWSER_REFRESH 42797
#define IDS_BROWSER_STOP 42798
#define IDS_BROWSER_SEARCH 42799
#define IDS_BROWSER_FAVORITES 42800
#define ID_POPUP_TF_NEW_FOLDER 42801
#define CG_IDS_PROGRESS_CAPTION 42801
#define ID_POPUP_TF_DELETE_FOLDER 42802
#define IDS_ICON_FILTER 42802
#define ID_POPUP_TF_REFRESH 42803
#define IDS_ICON_CAPTION 42803
#define IDS_SEARCH_CAPTION 42804
#define IDS_SEARCH_FILTER 42805
#define IDS_FILE_SELECT_APP 42806
#define IDS_FILE_SELECT_ICON 42807
#define IDS_FILE_SELECT_EXEC 42808
#define IDS_FILE_SELECT_HTML 42809
#define IDS_FILE_SELECT_COM 42810
#define IDS_FILE_SELECT_SCRIPT 42811
#define IDS_FILE_SELECT_APP_EXT 42812
#define IDS_FILE_SELECT_IMAGES 42813
#define IDS_FILE_SELECT_AUDIO 42814
#define IDS_IMAGE_CAPTION 42815
#define IDS_NO_ITEMS_MESS 42816
@@ -1,652 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#ifndef __ODLISTCTRL_H__
#define __ODLISTCTRL_H__
#define NUM_BITMAPS 2
#define MAX_TEXT MAX_PATH
#include "UICont.h"
#include "UIDropTarget.h"
#include "UIMessages.h"
#include "LocaleInfo.h"
class CInPlaceEdit;
class CTextProgressCtrl;
//////////////////////////////////////////////////////////
//CODHeaderCtrl
//////////////////////////////////////////////////////////
class CTRL_EXT_CLASS CODHeaderCtrl : public CHeaderCtrl
{
public:
CODHeaderCtrl();
~CODHeaderCtrl();
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
int SetSortImage(int nCol, BOOL bAsc);
protected:
int m_nSortCol;
BOOL m_bSortAsc;
};
//////////////////////////////////////////////////////////////////////////
// CUIODListCtrl
// Extension of the MFC class that enacapsulates the windows list control
// makes some things simpler some things harder and some things better.
//////////////////////////////////////////////////////////////////////////
class CTRL_EXT_CLASS CUIODListCtrl : public CListCtrl
{
public:
enum eColTypes
{
e_Text,
e_Numeric,
e_NumericFormat,
e_NumericFormatComma,
e_NumericFormatTime,
e_Double,
e_DoubleFormat,
e_DoubleFormatComma,
e_DoubleFormatTime,
e_DateTime
};
DECLARE_SERIAL(CUIODListCtrl)
public:
CUIODListCtrl(bool bDragDrop=true);
virtual ~CUIODListCtrl();
// Attributes
const COleDropTarget &GetDropTarget();
// Operations
public:
void RegisterDropTarget();
virtual void SetRowFont(int nRow,CFont *pFont);
virtual void SetRowBold(int nRow,BOOL bBold=TRUE);
virtual void SetColFont(int nRow,int nCol,CFont *pFont);
virtual void SetColBold(int nRow,int nCol,BOOL bBold=TRUE);
virtual BOOL SetColumnFormat(int nCol,int fmt);
virtual void Serialize(CArchive& ar);
// called from CUIListView::OnCreate
virtual void ChangeStyle(UINT &dwStyle);
virtual void Init();
virtual void UpdateEvent(LPARAM lHint,CObject *pHint);
// Initialize the list control
// The first parameter is a pointer to an array or single icon
// that will be added to an image list
// The second parameter will create the columns and add the heading
// but must be in this format Column1|Column2 delimited by the or sign
// This MUST BE CALLED first unless you use CListCtrl or API methods to add columns
// then you use AddTextItem to add a row passing the returned row number every time
virtual int InitListCtrl(const UINT *pIconIDs,LPCTSTR szHeadings,LPCTSTR pszProfile=NULL);
virtual int InitListCtrl(UINT IconID,LPCTSTR szHeadings,LPCTSTR pszProfile=NULL);
virtual int InitListCtrl(LPCTSTR szHeadings,LPCTSTR pszProfile=NULL);
// used to add strings after a text row has been created
virtual BOOL AddString(int nRow,int nCol,LPCTSTR szText,CUIODListCtrl::eColTypes type=CUIODListCtrl::e_Text);
virtual BOOL AddString(int nRow,int nCol,int nValue,CUIODListCtrl::eColTypes type=CUIODListCtrl::e_NumericFormatComma);
virtual BOOL AddString(int nRow,int nCol,double dValue,CUIODListCtrl::eColTypes type=CUIODListCtrl::e_DoubleFormatComma);
virtual BOOL AddString(int nRow,int nCol,COleDateTime &dtValue,CUIODListCtrl::eColTypes type=CUIODListCtrl::e_DateTime);
// Refreshes the row after a row has changed after a call to addstring
virtual void UpdateString(int nRow);
// add a new column will return index or -1 on failure
virtual void AddExtraString(int nRow,LPCTSTR pszExtraText);
// Adds a new column
virtual int AddColumn(LPCTSTR szText);
// Change the the window that receives the popup command messages
// default is the control
void SetPopupWnd(CWnd *pPopupWnd);
// Use your own popup menu
void SetPopupID(UINT nPopupID);
// Use your own popup menu when multiple item have been selected
void SetMultiPopupID(UINT nMultiPopupID);
// find a column index by text
int FindColumn(LPCTSTR pszText);
// same as the list control
DWORD GetItemData(int nIndex) const;
// add a row with data on demand see 'GetDispInfo' method
int AddCallBackItem(DWORD dwData=0,int nImage=0);
// add a text row where you supply the string
int AddTextItem(int nImage=0);
// same as list control with extra flag
BOOL SetItemData(int nIndex,DWORD dwData,bool bAutoDelete=false);
// Sets the item data but will also delete the pointer(so make sure it is one)
// be careful with this one
BOOL SetItemDataAutoDelete(int nIndex,CObject *pObj);
void SetDefaultTextColor( int nRow, int nCol);
void SetDefaultBkColor( int nRow, int nCol);
// set the row color (only works with ownerdraw control)
void SetTextColor( int nRow, int nCol, COLORREF TextColor);
// set the row color (only works with ownerdraw control)
void SetBkColor( int nRow, int nCol, COLORREF BkColor);
// toggle between large and small icon
void SetIconSize(int nImageList);
// set the icon passing an ICON id from the resources
int SetIcon(int nRow,UINT nIconID);
// set the icon passing the image index into the internal image list
int SetIcon(int nRow,int nImage);
// find an item by extension data
int FindItem(DWORD dwExtData);
// set the current selection
int SetCurSel(int nSelect);
void SetDragDrop(bool bDragDrop);
void SetDropFiles(bool bDropFiles);
void SetEditSubItems(bool bEdit);
// toggles the column sizing permission
void SetColumnSizing(bool bSet);
void SetToolTips(bool bSet);
BOOL SetGridLines(bool bSet);
BOOL SetTrackSelect(bool bSet);
BOOL SetCheckBoxes(bool bSet);
BOOL SetHeaderDragDrop(bool bSet);
void SetFullRowSel(bool bSet);
// changes the view type between LVS_ICON, LVS_SMALLICON, LVS_REPORT, etc
BOOL SetEditLabels(bool bSet);
void ToggleColumnSizing();
void ToggleToolTips();
// toggles grid lines(IE3.0 controls only)
BOOL ToggleGridLines();
// toggles hot tracking lines(IE3.0 controls only)
BOOL ToggleTrackSelect();
// toggles check boxes (IE3.0 controls only)
BOOL ToggleCheckBoxes();
// toggles between moving columns by dragging the header (IE3.0 controls only)
BOOL ToggleHeaderDragDrop();
// toggles full row selection lines(IE3.0 controls only)
void ToggleFullRowSel();
// changes the view type between LVS_ICON, LVS_SMALLICON, LVS_REPORT, etc
BOOL ToggleEditLabels();
BOOL SetViewType(DWORD dwViewType,UINT nFlags=0);
BOOL GetFullRowSel() const;
DWORD GetViewType() const;
// (IE3.0 controls only)
// set the extended style for the new IE3.0 common controls
BOOL SetExStyle(UINT nStyle,BOOL bModify=TRUE);
DWORD GetExStyle();
int GetIconSize() const;
// call this first to get the current or first selection
// returns -1 if no selection
int GetCurSel() const;
// used to get multiple selection
// returns -1 if no selection
int GetNextSel(int item) const;
// number of rows
int GetCount() const;
// number of columns
int GetColumnCount() const;
// allow the right mouse click to toggle between icons sizes
void SetRCLickChangeIconSize(BOOL bSize);
int HitTestEx(CPoint &point, int *col) const;
CEdit* EditSubLabel( int nItem, int nCol );
CTextProgressCtrl *AddProgressBar(int nItem,int nCol,int nMin,int nMax);
virtual void UpdateProgressBar(int nRow,int nCol,int nPos);
void DeleteProgressBar(int nItem,int nCol);
// Add an icon to the image list and return the index into the list
int AddIcon(UINT nIconID);
int AddIcon(HICON hIcon,UINT nIconID=0);
int AddIcon(LPCTSTR pszIcon);
// set the column data type primarily for sorting
void SetColType(int nCol,eColTypes ColType);
void SetSection(LPCTSTR pszSection);
void SetSortHeader();
void SetSortColumn(int nCol,BOOL bAsc);
// sort by column
virtual void Sort();
// save our profiles
virtual void SaveProfile();
virtual void LoadProfile();
void DelayPaint(bool bDelay);
static CString StripNonNumeric(LPCTSTR pszOldNum,CUIODListCtrl::eColTypes type);
//////////////////
// Overrides
public:
virtual DROPEFFECT SelectCurrentTarget(CDD_OleDropTargetInfo *pInfo);
// ovwner draw
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// ovwner draw
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItem);
virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
protected:
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void ConvertToTime(CString &str);
virtual void AddThousandSeps(CString &str);
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
// override if you added a callback row and fill in the structure
virtual PFNLVCOMPARE GetCompareFunc();
virtual BOOL GetDispInfo(LV_DISPINFO *pDispInfo);
virtual BOOL ColumnClick(NM_LISTVIEW* pNMListView);
virtual BOOL DoubleClick(NM_LISTVIEW* pNMListView);
virtual BOOL OnEnter(NM_LISTVIEW* pNMListView);
virtual BOOL OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
virtual BOOL OnSelChanged(int nItem, LRESULT* pResult);
// return true to delete the item from the list control
virtual bool DeleteKey(int nRow);
// called when the user has pressed ALt-Enter
virtual void ShowProperties(int nRow);
// called when the user has pressed F5
virtual void Refresh();
// called when the user has pressed the backspace key
virtual void GoBack(int nRow);
// called when the user has has finshed editing a column
virtual bool EndLabelEdit(int nRow,int nCol,LPCTSTR pszText);
virtual void PostNcDestroy();
virtual int OnToolHitTest(CPoint point,TOOLINFO *pTI) const;
virtual void PreSubclassWindow();
virtual int CellRectFromPoint(CPoint & point, RECT * cellrect, int * col) const;
virtual void AllItemsDeleted();
virtual void GetImageLists(CImageList **pILSmall,CImageList **pILLarge);
virtual void CreateImageLists();
// callback called when a new row is added passing the extension data and row index
// not valid for AddTextItem only AddCallbackItem
virtual CUIListCtrlData *GetNewListCtrlData(DWORD dwData,int nItem);
// option to show context menu if user uses keyboard or mouse(point in client co-ords)
virtual void ShowPopupMenu(int nRow,int nCol,CPoint point);
virtual BOOL PopupMenuItem(int nItem,int nCol,CMenu *pPopup,CPoint point);
virtual BOOL ItemPrePaint(LPNMLVCUSTOMDRAW lplvcd,LRESULT *pResult);
virtual BOOL ItemPostPaint(LPNMLVCUSTOMDRAW lplvcd,LRESULT *pResult);
virtual BOOL SubItemPrePaint(LPNMLVCUSTOMDRAW lplvcd,LRESULT *pResult);
virtual BOOL SubItemPostPaint(LPNMLVCUSTOMDRAW lplvcd,LRESULT *pResult);
//WM_DROPFILES
virtual void OnDropFile(int nRow,LPCTSTR pszFile,UINT nFlags);
// OLE Drag and Drop
// This called when a drop source is dropped on the tree control
virtual bool DragDrop(CDD_OleDropTargetInfo *pInfo);
// This called when a drop source is currently over the tree control
virtual bool DragOver(CDD_OleDropTargetInfo *pInfo);
// This called when the user entered the window with a drop source
virtual bool DragEnter(CDD_OleDropTargetInfo *pInfo);
// This called when the user leaves the window with a drop source
virtual bool DragLeave(CDD_OleDropTargetInfo *pInfo);
// This called when the user initiates a OLE drag and drop
virtual DROPEFFECT DoDragDrop(int *npRows,COleDataSource *pOleDataSource);
virtual void Empty();
void SetNoItemsMess(const CString &strNoItemsMess);
CString GetNoItemsMess() const;
bool IsDragDrop();
bool IsDropFiles();
void OnRClickHeader(CPoint point,int nColIndex);
// return a pointer to an extension data object
CUIListCtrlData *GetListCtrlData(int nItem) const;
int GetHeaderText(CHeaderCtrl *pHeader,int nPos,CString &strText);
void ReplaceString(CString &rStr,LPCTSTR pszOldText,LPCTSTR pszNewText);
// owner draw
BOOL CalcStringEllipsis(HDC hdc, LPTSTR lpszString, int cchMax, UINT uColWidth);
// owner draw
void DrawItemColumn(LPDRAWITEMSTRUCT lpDrawItemStruct, int nSubItem, LPRECT prcClip);
LPCTSTR GetThousandSep() const;
LPCTSTR GetDecimalSep() const;
LPCTSTR GetNegativeSign() const;
LPCTSTR GetTimeSep() const;
LPCTSTR GetDateSep() const;
LPCTSTR GetSection() const;
BOOL InsertItem(LPTSTR szText,LPARAM lParam,int nImage);
void ChangeIconSize();
int GetImageIndex(UINT nIconID);
// owner draw
static LPCTSTR MakeShortString(CDC* pDC, LPCTSTR lpszLong, int nColumnLen, int nOffset);
void RepaintSelectedItems();
void DoOleDrag(NM_LISTVIEW* pNMListView,bool bRightMenu);
// for sorting
protected:
COLORREF m_clrBkgnd;
COLORREF m_clrTextBk;
COLORREF m_clrText;
int m_cxClient;
int m_cxStateImageOffset;
int m_nImageList;
BOOL m_bFullRowSel;
BOOL m_bClientWidthSel;
BOOL m_bColumnSizing;
BOOL m_bHasFocus;
BOOL m_bRClickChangeIconSize;
BOOL m_bSortAscending;
BOOL m_bToolTips;
CUIObjList m_objList;
int m_nColClicked;
int m_nSortColumn;
int m_nImage;
int m_nItems;
int m_nSubItems;
int m_cxSmallIcon;
int m_cySmallIcon;
int m_cxLargeIcon;
int m_cyLargeIcon;
int *m_pColWidths;
int *m_pColOrder;
int *m_pColTypes;
DWORD m_dwExStyle;
DWORD m_dwViewType;
CImageList m_ImageSmall;
CImageList m_ImageLarge;
CString m_strHeadings;
CPoint m_PopupPoint;
HFONT m_hOrigFont;
CString m_strSection;
CMap<UINT,UINT,int,int> m_mapImageIndex;
CMap<CString,LPCTSTR,int,int> m_mapImageFile;
CODHeaderCtrl m_HeaderCtrl;
afx_msg LRESULT OnGetItemText(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetImageList(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetTextColor(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetTextBkColor(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetBkColor(WPARAM wParam, LPARAM lParam);
///* * Generated message map functions
//{{AFX_MSG(CUIODListCtrl)
afx_msg LRESULT OnSetColumnWidth(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDeleteAllItems(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDeleteItem(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDeleteColumn(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnUpdateHeaderWidth(WPARAM wParam,LPARAM lParam);
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu,UINT nIndex,BOOL bSysMenu);
afx_msg void OnContextMenu(CWnd*,CPoint point);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnPaint();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnViewLargeIcons();
afx_msg void OnViewSmallIcons();
afx_msg void OnViewDetails();
afx_msg void OnViewList();
afx_msg void OnViewFullRowSelection();
afx_msg void OnViewColumnOrdering();
afx_msg void OnViewColumnSizing();
afx_msg void OnViewGridlines();
afx_msg void OnViewCheckboxes();
afx_msg void OnViewTrackSelect();
afx_msg void OnViewEditColumn();
afx_msg void OnHeaderRemoveColumn();
afx_msg void OnHeaderEditText();
afx_msg void OnHeaderReset();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg BOOL OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnBeginRDrag(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg BOOL OnToolTipText(UINT id,NMHDR *pNMHDR,LRESULT *pResult);
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg LRESULT OnAppPropertiesKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppDeleteKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppRefreshKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppBackspaceKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppContextMenuKey(WPARAM wParam, LPARAM lParam );
afx_msg LRESULT OnAppEditKey(WPARAM wParam, LPARAM lParam );
//}}AFX_MSG
afx_msg LRESULT OnDragDrop(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDragOver(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDragEnter(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDragLeave(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnDDDoDragDrop(WPARAM wParam,LPARAM lParam);
DECLARE_MESSAGE_MAP()
private:
static LPCTSTR szEntryHeadings;
static LPCTSTR szEntryStyle;
static LPCTSTR szEntryRowSel;
static LPCTSTR szEntryViewType;
static LPCTSTR szEntryColumnSizing;
static LPCTSTR szEntrySortColumn;
static LPCTSTR szEntrySubItems;
static LPCTSTR szEntryColOrder;
static LPCTSTR szEntryColWidths;
CListDropTarget m_OleDropTarget;
COleDataSource m_OleDataSource;
CString m_sToolTipText;
CString m_strNoItemsMess;
bool m_bDelayPaint;
int m_iItemDrop;
bool m_bDragDrop;
bool m_bDropFiles;
bool m_bEditSubItems;
CWnd *m_pPopupWnd;
protected:
UINT m_PopupID;
UINT m_MultiPopupID;
};
/////////////////////
// inlines
/////////////////////
inline void CUIODListCtrl::SetEditSubItems(bool bEdit)
{
m_bEditSubItems = bEdit;
}
inline void CUIODListCtrl::SetNoItemsMess(const CString &strNoItemsMess)
{
m_strNoItemsMess = strNoItemsMess;
}
inline CString CUIODListCtrl::GetNoItemsMess() const
{
return m_strNoItemsMess;
}
inline void CUIODListCtrl::SetPopupWnd(CWnd *pPopupWnd)
{
m_pPopupWnd = pPopupWnd;
}
inline void CUIODListCtrl::SetPopupID(UINT nPopupID)
{
m_PopupID = nPopupID;
}
inline void CUIODListCtrl::SetMultiPopupID(UINT nMultiPopupID)
{
m_MultiPopupID = nMultiPopupID;
}
inline bool CUIODListCtrl::IsDragDrop()
{
return m_bDragDrop;
}
inline bool CUIODListCtrl::IsDropFiles()
{
return m_bDropFiles;
}
inline void CUIODListCtrl::SetDragDrop(bool bDragDrop)
{
m_bDragDrop = bDragDrop;
}
inline void CUIODListCtrl::SetDropFiles(bool bDropFiles)
{
m_bDropFiles = bDropFiles;
}
inline const COleDropTarget &CUIODListCtrl::GetDropTarget()
{
return m_OleDropTarget;
}
inline int CUIODListCtrl::GetIconSize() const
{
return m_nImageList;
}
inline int CUIODListCtrl::GetCurSel() const
{
return GetNextItem(-1,LVNI_SELECTED);
}
inline int CUIODListCtrl::GetNextSel(int item) const
{
return GetNextItem(item,LVNI_SELECTED);
}
inline int CUIODListCtrl::GetCount() const
{
return GetItemCount();
}
inline void CUIODListCtrl::SetRCLickChangeIconSize(BOOL bSize)
{
m_bRClickChangeIconSize = bSize;
}
inline void CUIODListCtrl::SetColumnSizing(bool bSet)
{
m_bColumnSizing = !bSet;
SaveProfile();
}
inline void CUIODListCtrl::ToggleColumnSizing()
{
m_bColumnSizing = !m_bColumnSizing;
SaveProfile();
}
inline void CUIODListCtrl::ToggleFullRowSel()
{
SetFullRowSel(!m_bFullRowSel);
}
inline BOOL CUIODListCtrl::ToggleHeaderDragDrop()
{
return SetHeaderDragDrop(!(GetExStyle() & LVS_EX_HEADERDRAGDROP));
}
inline BOOL CUIODListCtrl::SetHeaderDragDrop(bool bSet)
{
return SetExStyle(LVS_EX_HEADERDRAGDROP,bSet);
}
inline BOOL CUIODListCtrl::ToggleGridLines()
{
return SetGridLines(!(GetExStyle() & LVS_EX_GRIDLINES));
}
inline BOOL CUIODListCtrl::SetGridLines(bool bSet)
{
return SetExStyle(LVS_EX_GRIDLINES,bSet);
}
inline BOOL CUIODListCtrl::ToggleTrackSelect()
{
return SetTrackSelect(!(GetExStyle() & LVS_EX_TRACKSELECT));
}
inline BOOL CUIODListCtrl::SetTrackSelect(bool bSet)
{
return SetExStyle(LVS_EX_TRACKSELECT,bSet);
}
inline BOOL CUIODListCtrl::ToggleCheckBoxes()
{
return SetCheckBoxes(!(GetExStyle() & LVS_EX_CHECKBOXES));
}
inline BOOL CUIODListCtrl::SetCheckBoxes(bool bSet)
{
return SetExStyle(LVS_EX_CHECKBOXES,bSet);
}
inline BOOL CUIODListCtrl::ToggleEditLabels()
{
return SetEditLabels(!(GetStyle() & LVS_EDITLABELS));
}
inline BOOL CUIODListCtrl::SetEditLabels(bool bSet)
{
return bSet ? ModifyStyle(0,LVS_EDITLABELS) : ModifyStyle(LVS_EDITLABELS,0);
}
inline void CUIODListCtrl::ToggleToolTips()
{
m_bToolTips = !m_bToolTips;
SetToolTips(m_bToolTips == TRUE);
}
inline void CUIODListCtrl::SetToolTips(bool bSet)
{
m_bToolTips = bSet;
EnableToolTips(m_bToolTips);
}
inline void CUIODListCtrl::SetColType(int nCol,eColTypes ColType)
{
ASSERT(nCol < m_nSubItems);
ASSERT(m_pColTypes);
m_pColTypes[nCol] = ColType;
}
inline int CUIODListCtrl::GetColumnCount() const
{
return m_nSubItems;
}
inline LPCTSTR CUIODListCtrl::GetDecimalSep() const
{
return CLocaleInfo::Instance()->GetDecimalSep();
}
inline LPCTSTR CUIODListCtrl::GetThousandSep() const
{
return CLocaleInfo::Instance()->GetThousandSep();
}
inline LPCTSTR CUIODListCtrl::GetNegativeSign() const
{
return CLocaleInfo::Instance()->GetNegativeSign();
}
inline LPCTSTR CUIODListCtrl::GetTimeSep() const
{
return CLocaleInfo::Instance()->GetTimeSep();
}
inline LPCTSTR CUIODListCtrl::GetDateSep() const
{
return CLocaleInfo::Instance()->GetDateSep();
}
inline void CUIODListCtrl::DelayPaint(bool bDelay)
{
m_bDelayPaint = bDelay;
}
////////////////////////////////////////////////
// CChangeViewType
////////////////////////////////////////////////
class CChangeViewType
{
public:
CChangeViewType(CUIODListCtrl *pLC,DWORD dwType);
virtual ~CChangeViewType();
public:
protected:
private:
CUIODListCtrl *m_pLC;
DWORD m_dwType;
};
#endif
@@ -1,165 +0,0 @@
#ifndef __W2KFIX_H__
#define __W2KFIX_H__
#if (_WIN32_IE < 0x0501)
typedef struct _SHELLDETAILS
{
int fmt; // LVCFMT_* value (header only)
int cxChar; // Number of "average" characters (header only)
STRRET str; // String information
} SHELLDETAILS, *LPSHELLDETAILS;
// {93F2F68C-1D1B-11d3-A30E-00C04F79ABD1}
DEFINE_GUID(IID_IShellFolder2, 0x93f2f68c, 0x1d1b, 0x11d3, 0xa3, 0xe, 0x0, 0xc0, 0x4f, 0x79, 0xab, 0xd1);
#define SHCDF_UPDATEITEM 0x00000001 // this flag is a hint that the file has changed since the last call to GetItemData
typedef struct {
GUID fmtid;
DWORD pid;
} SHCOLUMNID, *LPSHCOLUMNID;
typedef const SHCOLUMNID* LPCSHCOLUMNID;
typedef struct {
ULONG dwFlags ; // combination of SHCDF_ flags.
DWORD dwFileAttributes ; // file attributes.
ULONG dwReserved ; // reserved for future use.
WCHAR* pwszExt ; // address of file name extension
WCHAR wszFile[MAX_PATH] ; // Absolute path of file.
} SHCOLUMNDATA, *LPSHCOLUMNDATA ;
typedef const SHCOLUMNDATA* LPCSHCOLUMNDATA ;
#define MAX_COLUMN_NAME_LEN 80
#define MAX_COLUMN_DESC_LEN 128
typedef struct {
ULONG dwFlags ; // initialization flags
ULONG dwReserved ; // reserved for future use.
WCHAR wszFolder[MAX_PATH]; // fully qualified folder path (or empty if multiple folders)
} SHCOLUMNINIT, *LPSHCOLUMNINIT;
typedef const SHCOLUMNINIT* LPCSHCOLUMNINIT;
typedef struct {
SHCOLUMNID scid; // OUT the unique identifier of this column
VARTYPE vt; // OUT the native type of the data returned
DWORD fmt; // OUT this listview format (LVCFMT_LEFT, usually)
UINT cChars; // OUT the default width of the column, in characters
DWORD csFlags; // OUT SHCOLSTATE flags
WCHAR wszTitle[MAX_COLUMN_NAME_LEN]; // OUT the title of the column
WCHAR wszDescription[MAX_COLUMN_DESC_LEN]; // OUT full description of this column
} SHCOLUMNINFO, *LPSHCOLUMNINFO ;
typedef const SHCOLUMNINFO* LPCSHCOLUMNINFO ;
//-------------------------------------------------------------------------
//
// IEnumExtraSearch interface
//
// IShellFolder2::EnumSearches member returns an IEnumExtraSearch object.
//
//-------------------------------------------------------------------------
typedef struct tagEXTRASEARCH
{
GUID guidSearch;
WCHAR wszFriendlyName[80];
WCHAR wszUrl[2084];
}EXTRASEARCH, *LPEXTRASEARCH;
typedef struct IEnumExtraSearch *LPENUMEXTRASEARCH;
#undef INTERFACE
#define INTERFACE IEnumExtraSearch
DECLARE_INTERFACE_(IEnumExtraSearch, IUnknown)
{
// *** IUnknown methods ***
STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// *** IEnumExtraSearch methods ***
STDMETHOD(Next) (THIS_ ULONG celt, EXTRASEARCH *rgelt, ULONG *pceltFetched) PURE;
STDMETHOD(Skip) (THIS_ ULONG celt) PURE;
STDMETHOD(Reset) (THIS) PURE;
STDMETHOD(Clone) (THIS_ IEnumExtraSearch **ppenum) PURE;
};
//--------------------------------------------------------------------------
// IShellFolder2
//
// [member functions]
//
// IShellFolder2::GetDefaultSearchGUID(LPGUID pGuid)
// Returns the guid of the search that is to be invoked when user clicks
// on the search toolbar button
//
// IShellFolder2::EnumSearches(IEnumExtraSearch **ppenum)
// gives an enumerator of the searches to be added to the search menu
//--------------------------------------------------------------------------
// IShellFolder2::GetDefaultColumnState values
typedef enum {
SHCOLSTATE_TYPE_STR = 0x00000001,
SHCOLSTATE_TYPE_INT = 0x00000002,
SHCOLSTATE_TYPE_DATE = 0x00000003,
SHCOLSTATE_TYPEMASK = 0x0000000F,
SHCOLSTATE_ONBYDEFAULT = 0x00000010, // should on by default in details view
SHCOLSTATE_SLOW = 0x00000020, // will be slow to compute, do on a background thread
SHCOLSTATE_EXTENDED = 0x00000040, // provided by a handler, not the folder
SHCOLSTATE_SECONDARYUI = 0x00000080, // not displayed in context menu, but listed in the "More..." dialog
SHCOLSTATE_HIDDEN = 0x00000100, // not displayed in the UI
} SHCOLSTATE;
#undef INTERFACE
#define INTERFACE IShellFolder2
DECLARE_INTERFACE_(IShellFolder2, IShellFolder)
{
// *** IUnknown methods ***
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppv) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
// *** IShellFolder methods ***
STDMETHOD(ParseDisplayName)(THIS_ HWND hwnd, LPBC pbc, LPOLESTR pszDisplayName,
ULONG *pchEaten, LPITEMIDLIST *ppidl, ULONG *pdwAttributes) PURE;
STDMETHOD(EnumObjects)(THIS_ HWND hwnd, DWORD grfFlags, IEnumIDList **ppenumIDList) PURE;
STDMETHOD(BindToObject)(THIS_ LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv) PURE;
STDMETHOD(BindToStorage)(THIS_ LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv) PURE;
STDMETHOD(CompareIDs)(THIS_ LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) PURE;
STDMETHOD(CreateViewObject)(THIS_ HWND hwnd, REFIID riid, void **ppv) PURE;
STDMETHOD(GetAttributesOf)(THIS_ UINT cidl, LPCITEMIDLIST * apidl, ULONG * drgfInOut) PURE;
STDMETHOD(GetUIObjectOf)(THIS_ HWND hwnd, UINT cidl, LPCITEMIDLIST * apidl,
REFIID riid, UINT * prgfInOut, void **ppv) PURE;
STDMETHOD(GetDisplayNameOf)(THIS_ LPCITEMIDLIST pidl, DWORD uFlags, STRRET *psr) PURE;
STDMETHOD(SetNameOf)(THIS_ HWND hwnd, LPCITEMIDLIST pidl, LPCOLESTR pszName,
DWORD uFlags, LPITEMIDLIST *ppidl) PURE;
// *** IShellFolder2 methods ***
STDMETHOD(GetDefaultSearchGUID)(THIS_ GUID *pguid) PURE;
STDMETHOD(EnumSearches)(THIS_ IEnumExtraSearch **ppenum) PURE;
STDMETHOD(GetDefaultColumn) (THIS_ DWORD dwRes, ULONG *pSort, ULONG *pDisplay) PURE;
STDMETHOD(GetDefaultColumnState)(THIS_ UINT iColumn, DWORD *pcsFlags) PURE;
STDMETHOD(GetDetailsEx)(THIS_ LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv) PURE;
STDMETHOD(GetDetailsOf)(THIS_ LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd) PURE;
STDMETHOD(MapColumnToSCID)(THIS_ UINT iColumn, SHCOLUMNID *pscid) PURE;
};
#undef INTERFACE
#define INTERFACE IShellDetails
DECLARE_INTERFACE_(IShellDetails, IUnknown)
{
// *** IUnknown methods ***
STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// *** IShellDetails methods ***
STDMETHOD(GetDetailsOf)(THIS_ LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *pDetails) PURE;
STDMETHOD(ColumnClick)(THIS_ UINT iColumn) PURE;
};
#endif
#endif //__W2KFIX_H__
@@ -1,30 +0,0 @@
// MSJ
// It it works contact Paul DiLascia
// if not you're own your own
#ifndef __WINDOWPLACEMENT_H__
#define __WINDOWPLACEMENT_H__
// CWindowPlacement reads and writes WINDOWPLACEMENT
// Helper for restoring the app size and placement.
class CTRL_EXT_CLASS CWindowPlacement : public WINDOWPLACEMENT {
public:
CWindowPlacement();
~CWindowPlacement();
// Read/write to app profile
BOOL GetProfileWP(LPCTSTR lpKeyName);
void WriteProfileWP(LPCTSTR lpKeyName);
// Save/restore window pos (from app profile)
void Save(LPCTSTR lpKeyName, CWnd* pWnd);
BOOL Restore(LPCTSTR lpKeyName, CWnd* pWnd);
// Save/restore from archive
friend CArchive& operator<<(CArchive& ar, const CWindowPlacement& wp);
friend CArchive& operator>>(CArchive& ar, CWindowPlacement& wp);
private:
int m_showCmd;
};
#endif
@@ -1,320 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_IMSELECTION_H__BE28E652_2B85_11d1_9B50_006008284B53__INCLUDED_)
#define AFX_IMSELECTION_H__BE28E652_2B85_11d1_9B50_006008284B53__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef DROPEFFECT_ALL
#define DROPEFFECT_ALL DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK
#endif
//////////////////////////////////////////
class CTRL_EXT_CLASS CCF_App : public CObject
{
public:
CCF_App() : m_hWnd(NULL) {};
void SetHwnd(HWND hWnd);
HANDLE GetHwnd();
virtual void Serialize(CArchive &ar);
private:
HWND m_hWnd;
DECLARE_SERIAL(CCF_App)
};
inline void CCF_App::SetHwnd(HWND hWnd)
{
m_hWnd = hWnd;
}
inline HANDLE CCF_App::GetHwnd()
{
return m_hWnd;
}
//////////////////////////////////////////
class CTRL_EXT_CLASS CCF_FolderType : public CObject
{
public:
CCF_FolderType(LPCTSTR pszParentCategory,long nCategory,LPCTSTR pszCategory);
CCF_FolderType() { m_nCategory=0; };
~CCF_FolderType();
public:
CCF_FolderType(const CCF_FolderType &WebSite);
const CCF_FolderType &operator=(const CCF_FolderType &rThat);
// virtual
virtual void Serialize(CArchive &ar);
// inline
CString GetParentCategory();
long GetCategory();
CString GetCategoryName();
protected:
long m_nCategory;
CString m_strParentCategory;
CString m_strCategory;
DECLARE_SERIAL(CCF_FolderType)
};
inline CString CCF_FolderType::GetParentCategory()
{
return m_strParentCategory;
}
inline long CCF_FolderType::GetCategory()
{
return m_nCategory;
}
inline CString CCF_FolderType::GetCategoryName()
{
return m_strCategory;
}
//////////////////////////////////////////
class CTRL_EXT_CLASS CCF_ShellIDList : public CObject
{
public:
CCF_ShellIDList();
virtual ~CCF_ShellIDList();
public:
// virtual
virtual void Serialize(CArchive &ar);
virtual void AddPidl(LPCITEMIDLIST pidl);
virtual LPCITEMIDLIST GetPidl(UINT nIndex) const;
virtual UINT GetCount() const;
LPCITEMIDLIST operator[](UINT nIndex) const;
protected:
DECLARE_SERIAL(CCF_ShellIDList)
private:
typedef CArray<LPCITEMIDLIST,LPCITEMIDLIST> arItemIDList;
arItemIDList m_pidls;
};
//////////////////////////////////////////
class CTRL_EXT_CLASS CCF_WebSite : public CObject
{
public:
CCF_WebSite() {};
CCF_WebSite(LPCTSTR pszURL,LPCTSTR pszTitle);
~CCF_WebSite();
public:
CCF_WebSite(const CCF_WebSite &WebSite);
const CCF_WebSite &operator=(const CCF_WebSite &rThat);
// virtual
virtual void Serialize(CArchive &ar);
// inline
virtual LPCTSTR GetURL();
virtual LPCTSTR GetTitle();
protected:
CString m_strURL;
CString m_strTitle;
//
DECLARE_SERIAL(CCF_WebSite)
};
inline LPCTSTR CCF_WebSite::GetURL()
{
return m_strURL;
}
inline LPCTSTR CCF_WebSite::GetTitle()
{
return m_strTitle;
}
class CTRL_EXT_CLASS CCF_DBFolderList : public CList<CCF_FolderType,CCF_FolderType&>
{
public:
CCF_DBFolderList(HWND hWnd=NULL) { m_App.SetHwnd(hWnd); };
~CCF_DBFolderList() {};
void SetDatabase(const CString &strDatabase);
CString GetDatabase() const;
virtual void Serialize(CArchive &ar);
public:
CCF_App m_App;
protected:
CString m_strDatabase;
DECLARE_SERIAL(CCF_DBFolderList)
};
inline void CCF_DBFolderList::SetDatabase(const CString &strDatabase)
{
m_strDatabase = strDatabase;
}
inline CString CCF_DBFolderList::GetDatabase() const
{
return m_strDatabase;
}
// template CCF_DBFolderList
/////////////////////////////////////
template<> void CTRL_EXT_CLASS AFXAPI SerializeElements <CCF_FolderType>(CArchive& ar, CCF_FolderType *pWebSiteCategory, int nCount );
template<> void CTRL_EXT_CLASS AFXAPI DestructElements<CCF_FolderType>(CCF_FolderType *pElements, int nCount);
template<> void CTRL_EXT_CLASS AFXAPI ConstructElements<CCF_FolderType>(CCF_FolderType *pElements, int nCount);
// template CList
/////////////////////////////////////
typedef CList<CCF_WebSite,CCF_WebSite&> CListWebSites;
template<> void CTRL_EXT_CLASS AFXAPI SerializeElements <CCF_WebSite>(CArchive& ar, CCF_WebSite *pWebSite, int nCount );
template<> void CTRL_EXT_CLASS AFXAPI DestructElements<CCF_WebSite>(CCF_WebSite *pElements, int nCount);
template<> void CTRL_EXT_CLASS AFXAPI ConstructElements<CCF_WebSite>(CCF_WebSite *pElements, int nCount);
/////////////////////////////////////
class CTRL_EXT_CLASS CCF_WebSites : public CObject
{
public:
CCF_WebSites(HWND hWnd=NULL) { m_App.SetHwnd(hWnd); };
~CCF_WebSites() {};
CListWebSites &GetListWebSites();
POSITION GetHeadPosition();
CCF_WebSite &GetNext(POSITION &pos);
virtual void Serialize(CArchive &ar);
protected:
CCF_App m_App;
CListWebSites m_listWebSites;
DECLARE_SERIAL(CCF_WebSites)
};
inline CCF_WebSite &CCF_WebSites::GetNext(POSITION &pos)
{
return m_listWebSites.GetNext(pos);
}
inline POSITION CCF_WebSites::GetHeadPosition()
{
return m_listWebSites.GetHeadPosition();
}
inline CListWebSites &CCF_WebSites::GetListWebSites()
{
return m_listWebSites;
}
//////////////////////////////////////////
class CTRL_EXT_CLASS CCF_String : public CObject
{
public:
CCF_String() {};
CCF_String(LPCTSTR pszText);
~CCF_String();
public:
// virtual
virtual void Serialize(CArchive &ar);
virtual LPCTSTR GetString();
void SetString(LPCTSTR pszText);
DECLARE_SERIAL(CCF_String)
private:
CString m_sText;
};
class CTRL_EXT_CLASS CCF_RightMenu : public CObject
{
public:
CCF_RightMenu() { m_bRightDrag = false; };
~CCF_RightMenu() {};
public:
void SetRightDrag(bool bRightDrag);
// virtual
virtual void Serialize(CArchive &ar);
virtual bool IsRightDrag();
DECLARE_SERIAL(CCF_RightMenu)
private:
bool m_bRightDrag;
};
class CTRL_EXT_CLASS CCF_FileGroupDescriptor : public CObject
{
public:
CCF_FileGroupDescriptor();
~CCF_FileGroupDescriptor();
public:
CString GetFileName(UINT nItem);
CString GetTitle(UINT nItem);
void SetTitle(const CString &sTitle);
LPFILEDESCRIPTOR GetFileDescriptor(UINT nItem);
// virtual
virtual void Serialize(CArchive &ar);
DECLARE_SERIAL(CCF_FileGroupDescriptor)
private:
CString m_sTitle;
UINT m_nItems;
LPFILEDESCRIPTOR m_pFileDescrs;
};
//////////////////////////////////
class CTRL_EXT_CLASS CCF_HDROP : public CObject
{
public:
CCF_HDROP();
~CCF_HDROP();
public:
UINT GetCount() { return m_sFileNames.GetSize(); }
CString GetFileName(UINT nItem);
void AddFileName(LPCTSTR pszFileName);
void AddDropPoint(CPoint &pt,BOOL bfNC=FALSE);
// virtual
virtual void Serialize(CArchive &ar);
DECLARE_SERIAL(CCF_HDROP)
private:
CStringArray m_sFileNames;
int m_nFiles;
CPoint m_pt;
BOOL m_fNC;
};
class CTRL_EXT_CLASS CWDClipboardData : public CObject
{
public:
enum eCBFormats
{
e_cfString,
e_cfHDROP,
e_cfWebSiteURL,
e_cfWebSite,
e_cfHTMLFormat,
e_cfFolder,
e_cfRightMenu,
e_cfFileGroupDesc,
e_cfShellIDList,
e_cfMax
};
CWDClipboardData();
~CWDClipboardData();
public:
void SetData(COleDataSource *pDataSource,CObject *pObj,eCBFormats format,LPFORMATETC lpFormatEtc=NULL);
bool GetData(COleDataObject *pDataObject,CObject *pObj,eCBFormats format);
CLIPFORMAT GetClipboardFormat(eCBFormats format);
bool IsDataAvailable(COleDataObject *pDataObject);
static CWDClipboardData *Instance();
protected:
bool IsValidFormat(CLIPFORMAT cfFormat);
private:
CLIPFORMAT m_aFormatIDs[e_cfMax];
};
#endif // BE28E652-2B85-11d1-9B50-006008284B53
@@ -1,189 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)
#define AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// DragDropCtrl.h : header file
//
class CDD_OleDropTargetInfo : public CObject
{
DECLARE_DYNAMIC(CDD_OleDropTargetInfo)
public:
CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject);
CDD_OleDropTargetInfo(HWND hWnd);
// Operations
void SetItem(HTREEITEM hItem);
void SetItem(int nItem);
void SetDropEffect(DROPEFFECT dropEffect);
void SetKeyboardState(DWORD dwKeyboardState);
// Attributes
HWND GetSafeHwnd() const;
CPoint GetPoint() const;
DWORD GetKeyboardState() const;
const COleDataObject *GetDataObject() const;
COleDataObject *GetDataObject();
HTREEITEM GetTreeItem() const;
int GetListItem() const;
DROPEFFECT GetDropEffect() const;
protected:
void InitInfo(HWND hWnd,
const CPoint *pPoint=NULL,
COleDataObject *pDataObject=NULL,
DROPEFFECT dropeEffect=DROPEFFECT_NONE,
DWORD dwKeyState=0,
HTREEITEM hItem=NULL,
int iItem=-1);
private:
HWND m_hWnd; // window mouse currently over
CPoint m_point; // mouse position in client coordinates
DROPEFFECT m_dropEffect; // The type of drop anticipated
COleDataObject *m_pDataObject; // The OLE data that was cached at startup
DWORD m_dwKeyState; // keyboard state when message was received
HTREEITEM m_hDropItem; // tree item the mouse is over or currently selected (NULL if source not a tree control)
int m_nDropItem; // list control item the mouse is over (-1 if source not a list control)
};
inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject)
{
InitInfo(hWnd,&point,pDataObject);
}
inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd)
{
InitInfo(hWnd);
}
inline void CDD_OleDropTargetInfo::InitInfo(HWND hWnd,
const CPoint *pPoint,
COleDataObject *pDataObject,
DROPEFFECT dropEffect,
DWORD dwKeyState,
HTREEITEM hItem,
int iItem)
{
m_hWnd = hWnd;
if (pPoint)
m_point = *pPoint;
else
m_point = CPoint();
m_pDataObject = pDataObject;
m_dropEffect = dropEffect;
m_dwKeyState = dwKeyState;
m_hDropItem = hItem;
m_nDropItem = iItem;
}
inline void CDD_OleDropTargetInfo::SetItem(int nItem)
{
m_nDropItem = nItem;
}
inline void CDD_OleDropTargetInfo::SetItem(HTREEITEM hItem)
{
m_hDropItem = hItem;
}
inline void CDD_OleDropTargetInfo::SetDropEffect(DROPEFFECT dropEffect)
{
m_dropEffect = dropEffect;
}
inline void CDD_OleDropTargetInfo::SetKeyboardState(DWORD dwKeyboardState)
{
m_dwKeyState = dwKeyboardState;
}
inline DROPEFFECT CDD_OleDropTargetInfo::GetDropEffect() const
{
return m_dropEffect;
}
inline HWND CDD_OleDropTargetInfo::GetSafeHwnd() const
{
return m_hWnd;
}
inline CPoint CDD_OleDropTargetInfo::GetPoint() const
{
return m_point;
}
inline DWORD CDD_OleDropTargetInfo::GetKeyboardState() const
{
return m_dwKeyState;
}
inline const COleDataObject *CDD_OleDropTargetInfo::GetDataObject() const
{
return m_pDataObject;
}
inline COleDataObject *CDD_OleDropTargetInfo::GetDataObject()
{
return m_pDataObject;
}
inline HTREEITEM CDD_OleDropTargetInfo::GetTreeItem() const
{
return m_hDropItem;
}
inline int CDD_OleDropTargetInfo::GetListItem() const
{
return m_nDropItem;
}
/////////////////////////////////////////////////////////////////////////////
// CDragDropCtrl window
class CTRL_EXT_CLASS CDragDropCtrl : public COleDropTarget
{
// Construction
public:
CDragDropCtrl();
// Attributes
public:
// Operations
public:
// Overrides
virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
virtual void OnDragLeave( CWnd* pWnd);
// Implementation
public:
virtual ~CDragDropCtrl();
private:
DWORD m_dwKeyboardState;
DWORD m_dwEnterKeyboardState;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)
@@ -1,90 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_WIDGBASE_H__877329CA_C22E_11D0_B2D8_444553540000__INCLUDED_)
#define AFX_WIDGBASE_H__877329CA_C22E_11D0_B2D8_444553540000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/////////////////////////////////////////////////////////////////////////////
// CDragDropImage command target
class CDragDropItem : public CObject
{
public:
CDragDropItem(LPCRECT prcItem,LPCRECT prcIcon);
CRect m_rcItem;
CRect m_rcIcon;
};
inline CDragDropItem::CDragDropItem(LPCRECT prcItem,LPCRECT prcIcon) : m_rcItem(prcItem),m_rcIcon(prcIcon)
{
}
struct DD_ImageData
{
CRect m_rcItem;
CRect m_rcIcon;
CPoint m_ptDrag;
};
class CDragDropImage : public CCmdTarget
{
DECLARE_DYNCREATE(CDragDropImage)
protected:
CDragDropImage();// protected constructor used by dynamic creation
public:
CDragDropImage(int nSelected,int nType);
virtual ~CDragDropImage();
// Attributes
public:
// Operations
public:
void AddItem(LPCRECT prcItem,LPCRECT prcIcon);
virtual void DrawDragImage (CDC *pDC,POINT point,POINT ActionPoint);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDragDropImage)
//}}AFX_VIRTUAL
// Implementation
protected:
void DrawItemImage(CDC *pDC, POINT point,const CRect &rcItem,const CRect &rcIcon);
int m_nSelected;
int m_nType;
CTypedPtrList<CObList,CDragDropItem*> m_itemList;
// Generated message map functions
//{{AFX_MSG(CDragDropImage)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WIDGBASE_H__877329CA_C22E_11D0_B2D8_444553540000__INCLUDED_)
@@ -1,53 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#if !defined(AFX_DRAGDROPLIST_H__A4325D31_FF52_11D0_ADBF_0000E81B9EF1__INCLUDED_)
#define AFX_DRAGDROPLIST_H__A4325D31_FF52_11D0_ADBF_0000E81B9EF1__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// DragDropList.h : header file
//
#include "UIImageDropTarget.h"
class CListDropTarget : public CUI_ImageDropTarget
{
public:
CListDropTarget();
virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
virtual void OnDragLeave( CWnd* pWnd);
protected:
DWORD m_dwKeyboardState;
};
inline CListDropTarget::CListDropTarget()
{
m_dwKeyboardState = 0;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DRAGDROPLIST_H__A4325D31_FF52_11D0_ADBF_0000E81B9EF1__INCLUDED_)
@@ -1,178 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// LocaleInfo.cpp: implementation of the CLocaleInfo class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "LocaleInfo.h"
#include "TextParse.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
// static
CLocaleInfo *CLocaleInfo::Instance()
{
static CLocaleInfo data;
return &data;
}
CLocaleInfo::CLocaleInfo()
{
m_pszNegativeSign = NULL;
m_pszDecimalSep = NULL;
m_pszThousandSep = NULL;
m_pszLongDate = NULL;
m_pszShortDate = NULL;
m_pszShortTime = NULL;
m_pszLongTime = NULL;
m_pszDateSep = NULL;
m_pszTimeSep = NULL;
GetAllLocaleInfo();
}
CLocaleInfo::~CLocaleInfo()
{
delete []m_pszNegativeSign;
delete []m_pszDecimalSep;
delete []m_pszThousandSep;
delete []m_pszLongDate;
delete []m_pszShortDate;
delete []m_pszShortTime;
delete []m_pszLongTime;
delete []m_pszDateSep;
delete []m_pszTimeSep;
}
void CLocaleInfo::GetAllLocaleInfo()
{
m_pszShortTime = new TCHAR[MAX_PATH];
lstrcpy(m_pszShortTime,_T("H:mm"));
AllocLocaleInfo(LOCALE_STIMEFORMAT,&m_pszLongTime);
AllocLocaleInfo(LOCALE_SSHORTDATE,&m_pszShortDate);
AllocLocaleInfo(LOCALE_SLONGDATE,&m_pszLongDate);
AllocLocaleInfo(LOCALE_SDATE,&m_pszDateSep);
AllocLocaleInfo(LOCALE_STIME,&m_pszTimeSep);
AllocLocaleInfo(LOCALE_SNEGATIVESIGN,&m_pszNegativeSign);
AllocLocaleInfo(LOCALE_SDECIMAL,&m_pszDecimalSep);
AllocLocaleInfo(LOCALE_STHOUSAND,&m_pszThousandSep);
}
void CLocaleInfo::AllocLocaleInfo(LCTYPE lctype,LPTSTR *pszInfo)
{
int nLen = GetLocaleInfo(LOCALE_USER_DEFAULT,lctype,NULL,0);
if (nLen)
{
*pszInfo = new TCHAR[nLen];
GetLocaleInfo(LOCALE_USER_DEFAULT,lctype,*pszInfo,nLen);
}
}
CString CLocaleInfo::FormatDateTime(const COleDateTime &oleDateTime)
{
CString sDate, sTime;
sDate = oleDateTime.Format(ConvertStdToWinFormat(GetShortDate()));
sTime = oleDateTime.Format(ConvertStdToWinFormat(GetLongTime()));
return sDate + _T(" ") + sTime;
}
CString CLocaleInfo::FormatDateTime(const FILETIME &ft)
{
COleDateTime oleDateTime(ft);
return FormatDateTime(oleDateTime);
}
static struct FormatCodes
{
LPCTSTR szWinFormat;
LPCTSTR szStdFormat;
} FC[] = {
{ _T("M"), _T("%#m") },
{ _T("MM"),_T("%m") },
{ _T("MMM"),_T("%b") },
{ _T("MMMM"),_T("%B") },
{ _T("d"),_T("%#d") },
{ _T("dd"),_T("%d") },
{ _T("dddd"),_T("%A") },
{ _T("yy"),_T("%y") },
{ _T("yyyy"),_T("%Y") },
{ _T("H"),_T("%#H") },
{ _T("HH"),_T("%H") },
{ _T("h"),_T("%#I") },
{ _T("hh"),_T("%I") },
{ _T("mm"),_T("%M") },
{ _T("ss"),_T("%S") },
{ _T("tt"),_T("%p") },
{ NULL, NULL }
};
// Short Format
// M/d/yyyy
// M/d/yy
// MM/dd/yy
// MM/dd/yyyy
// yy/MM/dd
// yyyy-MM-dd
// dd-MMM-yy
// Long Format
// dddd, MMMM dd, yyyy
// MMMM dd, yyyy
// dddd, dd MMMM, yyyy
// dd MMMM, yyyy
// Time
// H:mm:ss
// h:mm:ss tt
// hh:mm:ss tt
// HH:mm:ss
CString CLocaleInfo::ConvertStdToWinFormat(LPCTSTR pszFormat)
{
CString sCode;
CString sWinFormat;
CTextParse parse(pszFormat);
CString sSeparators(_T(" -/,.:"));
while (!parse.IsEnd())
{
if (parse.CharAtCurrent(sSeparators))
{
sCode = parse.CopyWhileChar(sSeparators);
}
else
{
sCode = parse.CopyUntilChar(sSeparators);
}
StdToWinFormatCode(sCode);
sWinFormat += sCode;
}
return sWinFormat;
}
void CLocaleInfo::StdToWinFormatCode(CString &sCode)
{
for(int i=0;FC[i].szWinFormat != NULL;i++)
{
if (sCode == FC[i].szWinFormat)
{
sCode = FC[i].szStdFormat;
break;
}
}
}
@@ -1,250 +0,0 @@
////////////////////////////////////////////////////////////////////
// PIDL.cpp: implementation of the CPIDL class.
//
// By Oz Solomonovich ([email protected])
#include "stdafx.h"
#include <atlbase.h>
#include "PIDL.h"
LPSHELLFOLDER CPIDL::m_sfDesktop = NULL; // cached destkop folder
LPMALLOC CPIDL::m_pAllocator = NULL; // cached system allocator
CPIDL::pidl_initializer CPIDL::m_initializer; // automatic init. obj
////////////////////////////////////////////////////////////////////
// Initialization object
////////////////////////////////////////////////////////////////////
// pidl_initializer is used to initialize the static data. The
// constructor and destructor are automatically called for us when
// the program starts/ends.
CPIDL::pidl_initializer::pidl_initializer()
{
SHGetDesktopFolder(&m_sfDesktop); // cache d'top folder obj ptr
SHGetMalloc(&m_pAllocator); // cache sys allocator obj ptr
}
CPIDL::pidl_initializer::~pidl_initializer()
{
m_sfDesktop->Release();
m_pAllocator->Release();
}
////////////////////////////////////////////////////////////////////
// CPIDL Implementation
////////////////////////////////////////////////////////////////////
CPIDL::CPIDL(LPCTSTR szPath, LPSHELLFOLDER psf) :
m_pidl(NULL)
{
Set(szPath, psf);
}
CPIDL::~CPIDL()
{
Free(); // just free used memory
}
////////////////////////////////////////////////////////////////////
// Assignment Functions
HRESULT CPIDL::Set(const CPIDL& cpidl)
{
return MakeCopyOf(cpidl.m_pidl);
}
HRESULT CPIDL::Set(LPITEMIDLIST pidl)
{
Free();
m_pidl = pidl;
return ERROR_SUCCESS;
}
HRESULT CPIDL::Set(LPCTSTR szPath, LPSHELLFOLDER psf)
{
OLECHAR olePath[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
Free();
#ifndef _UNICODE
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1,
olePath, MAX_PATH);
#else
lstrcpy(olePath,szPath);
#endif
return psf->ParseDisplayName(NULL, NULL, olePath, &chEaten,
&m_pidl, &dwAttributes);
}
HRESULT CPIDL::MakeCopyOf(LPITEMIDLIST pidl)
{
Free();
if (pidl) {
UINT sz = m_pAllocator->GetSize((LPVOID)pidl);
AllocMem(sz);
CopyMemory((LPVOID)m_pidl, (LPVOID)pidl, sz);
}
return ERROR_SUCCESS;
}
HRESULT CPIDL::MakeAbsPIDLOf(LPSHELLFOLDER psf, LPITEMIDLIST pidl)
{
USES_CONVERSION;
STRRET str;
HRESULT hr = psf->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &str);
if (SUCCEEDED(hr)) {
ExtractCStr(str);
hr = Set(A2T(str.cStr));
}
return hr;
}
////////////////////////////////////////////////////////////////////
// CPIDL Operations
void CPIDL::Free()
{
if (m_pidl) {
m_pAllocator->Free(m_pidl);
m_pidl = NULL;
}
}
#define CB_SIZE (sizeof(piid->cb)) // size of termination item
UINT CPIDL::GetSize() const
{
UINT cbTotal = 0;
LPSHITEMID piid = GetFirstItemID();
if (piid) {
do {
cbTotal += piid->cb;
GetNextItemID(piid);
} while (piid->cb);
cbTotal += CB_SIZE; // count the terminator
}
return cbTotal;
}
void CPIDL::Split(CPIDL& parent, CPIDL& obj) const
{
int size = 0;
SHITEMID *piid, *piidLast;
// find last item-id and calculate total size of pidl
piid = piidLast = &m_pidl->mkid;
while (piid->cb)
{
piidLast = piid;
size += (piid->cb);
piid = (SHITEMID *)((LPBYTE)piid + (piid->cb));
}
// copy parent folder portion
size -= piidLast->cb; // don't count "object" item-id
if (size > 0)
{
parent.AllocMem(size + CB_SIZE);
CopyMemory(parent.m_pidl, m_pidl, size);
ZeroMemory((LPBYTE)parent.m_pidl + size, CB_SIZE); // terminator
}
// copy "object" portion
size = piidLast->cb + CB_SIZE;
if (size > 0)
{
obj.AllocMem(size);
CopyMemory(obj.m_pidl, piidLast, size);
}
}
CPIDL CPIDL::operator + (CPIDL& pidl) const
{
CPIDL ret;
Concat(*this, pidl, ret);
return ret;
}
void CPIDL::Concat(const CPIDL &a, const CPIDL& b, CPIDL& result)
{
result.Free();
// both empty->empty | a empty->return b | b empty->return a
if (a.m_pidl == NULL && b.m_pidl == NULL) return;
if (a.m_pidl == NULL) { result.Set(b); return; }
if (a.m_pidl == NULL) { result.Set(a); return; }
UINT cb1 = a.GetSize() - sizeof(a.m_pidl->mkid.cb);
UINT cb2 = b.GetSize();
result.AllocMem(cb1 + cb2); // allocate enough memory
CopyMemory(result.m_pidl, a.m_pidl, cb1); // 1st
CopyMemory(((LPBYTE)result.m_pidl) + cb1, b.m_pidl, cb2); // 2nd
}
HRESULT CPIDL::GetUIObjectOf(REFIID riid, LPVOID *ppvOut,
HWND hWnd /*= NULL*/, LPSHELLFOLDER psf /*= m_sfDesktop*/)
{
CPIDL parent, obj;
LPSHELLFOLDER psfParent;
HRESULT hr=S_OK;
Split(parent, obj);
// if no idl the use desktop folder
if (parent.m_pidl == NULL || parent.m_pidl->mkid.cb == 0)
{
psfParent = psf;
psfParent->AddRef();
}
else
{
// otherwise get the parent
hr = psf->BindToObject(parent, NULL, IID_IShellFolder,
(LPVOID *)&psfParent); // get the IShellFolder of the parent
}
if (SUCCEEDED(hr))
{
hr = psfParent->GetUIObjectOf(hWnd, 1, obj, riid, 0, ppvOut);
psfParent->Release();
}
return hr;
}
void CPIDL::ExtractCStr(STRRET& strRet) const
{
switch (strRet.uType)
{
case STRRET_WSTR:
{
// pOleStr points to a WCHAR string - convert it to ANSI
LPWSTR pOleStr = strRet.pOleStr;
WideCharToMultiByte(CP_ACP, 0, pOleStr, -1,
strRet.cStr, MAX_PATH, NULL, NULL);
m_pAllocator->Free(pOleStr);
break;
}
case STRRET_OFFSET:
// The string lives inside the pidl, so copy it out.
strncpy(strRet.cStr, (LPSTR)
((LPBYTE)m_pidl + strRet.uOffset), MAX_PATH);
break;
}
}
////////////////////////////////////////////////////////////////////
// CPIDL Private Operations
void CPIDL::AllocMem(int iAllocSize)
{
Free();
m_pidl = (LPITEMIDLIST)m_pAllocator->Alloc(iAllocSize);
}
@@ -1,600 +0,0 @@
/***************************************************************************/
/* NOTE: */
/* This document is copyright (c) by Oz Solomonovich. All non-commercial */
/* use is allowed, as long as this document is not altered in any way, and */
/* due credit is given. */
/***************************************************************************/
// ShellContextMenu.cpp : implementation file
//
// Handles the creation of the shell context menu, including the "Send To..."
// sub-menu.
// Personal note: I think that MS should have made the code to populate and
// handle the "Send To..." sub-menu a part of the shell context menu code.
// But they didn't, so now we're forced to write a whole lot of spaghetti COM
// code to do what should have been a trivial part of the OS. See the code
// below and judge for yourself.
//
// ==========================================================================
// HISTORY:
// ==========================================================================
// 1.01 7 Jul 2000 - Philip Oldaker [[email protected]] - Fixed a problem
// with the SendTo menu now checking for menu id.
// Added support for the new OpenWith menu.
// The SendTo Menu is now sorted.
#include "stdafx.h"
#include "ShellContextMenu.h"
#include "UICoolMenu.h"
#include <atlbase.h>
#include "PIDL.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define IDM_SHELLCTXFIRST 20000
#define IDM_SHELLCTXLAST 29999
#define IDM_SENDTOFIRST 30000
#define IDM_SENDTOLAST 32000
#define IDM_OPENWITHFIRST 32001
#define IDM_OPENWITHLAST 32767
#define IDM_SENDTOID 20028
#define IDM_OPENWITHID1 20127
#define IDM_OPENWITHID2 20128
LPSHELLFOLDER is_less_than_pidl::psf;
LPSHELLFOLDER is_greater_than_pidl::psf;
// OpenWith menu registry keys
static LPCTSTR szAppKey = _T("Applications");
static LPCTSTR szOpenWithListKey = _T("OpenWithList");
static LPCTSTR szShellKey = _T("shell");
static LPCTSTR szCommandKey = _T("command");
static LPCTSTR szFileExtKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts");
// OpenWith menu entries
static LPCTSTR szMRUListEntry = _T("MRUList");
static LPCTSTR szDisplayNameEntry = _T("FriendlyCache");
static class CShCMInitializer
{
public:
CShCMInitializer();
~CShCMInitializer();
static LPSHELLFOLDER m_sfDesktop;
static LPSHELLFOLDER m_sfSendTo;
static CImageList * m_pShellImageList;
static CPIDL m_pidlSendTo;
} stat_data;
LPSHELLFOLDER CShCMInitializer::m_sfDesktop = NULL;
LPSHELLFOLDER CShCMInitializer::m_sfSendTo = NULL;
CImageList * CShCMInitializer::m_pShellImageList = NULL;
CPIDL CShCMInitializer::m_pidlSendTo;
CShCMInitializer::CShCMInitializer()
{
HRESULT hr;
SHFILEINFO sfi;
SHGetDesktopFolder(&m_sfDesktop);
hr = SHGetSpecialFolderLocation(NULL, CSIDL_SENDTO, m_pidlSendTo);
if (SUCCEEDED(hr))
{
hr = m_sfDesktop->BindToObject(m_pidlSendTo, NULL, IID_IShellFolder,
(LPVOID *)&m_sfSendTo);
if (!SUCCEEDED(hr))
{
m_sfSendTo = NULL;
}
}
else
{
m_sfSendTo = NULL;
}
m_pShellImageList = CImageList::FromHandle((HIMAGELIST)
SHGetFileInfo((LPCTSTR)_T("C:\\"), 0, &sfi, sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON));
}
CShCMInitializer::~CShCMInitializer()
{
m_sfSendTo->Release();
m_sfDesktop->Release();
}
CShellContextMenu::CShellContextMenu(HWND hWnd,const CString &sAbsPath, LPITEMIDLIST *ppidl, UINT cidl, LPSHELLFOLDER psfParent)
: m_hWnd(hWnd),
m_sAbsPath(sAbsPath),
m_psfParent(psfParent),
m_ppidl(ppidl),
m_cidl(cidl),
m_pSendToMenu(NULL)
{
m_lpcm = NULL;
m_pidl = *ppidl;
// Initialize button sizes
m_szOldButtonSize = g_CoolMenuManager.SetButtonSize();
}
CShellContextMenu::~CShellContextMenu()
{
if (m_lpcm) m_lpcm->Release();
if (m_pSendToMenu)
{
int i = IDM_SENDTOFIRST;
void * pData;
pData = CCoolMenuManager::GetItemData(*m_pSendToMenu, i);
while (pData)
{
CPIDL toFree((LPITEMIDLIST)pData);
pData = CCoolMenuManager::GetItemData(*m_pSendToMenu, ++i);
}
g_CoolMenuManager.UnconvertMenu(m_pSendToMenu);
m_pSendToMenu = NULL;
}
// Clean up owner draw menus
STL_FOR_ITERATOR(vecODMenu,m_OwnerDrawMenus)
{
g_CoolMenuManager.UnconvertMenu(STL_GET_CURRENT(m_OwnerDrawMenus));
}
STL_ERASE_ALL(m_OwnerDrawMenus);
g_CoolMenuManager.SetButtonSize(m_szOldButtonSize);
//////////////////////////////
}
/////////////////////////////
// Addition: Philip Oldaker
/////////////////////////////
CString CShellContextMenu::GetExt(const CString &sPath) const
{
TCHAR szDir[_MAX_PATH];
TCHAR szDrive[_MAX_DRIVE];
TCHAR szFileName[_MAX_FNAME];
TCHAR szExt[_MAX_EXT];
szDir[0] = szDrive[0] = szFileName[0] = szExt[0] = 0;
_tsplitpath(sPath,szDrive,szDir,szFileName,szExt);
return szExt;
}
// A bunch of registry nonsense to return all relevant details
// but especially the application icon
void CShellContextMenu::GetAppDetails(const CString &sAppName,CString &sDisplayName,CString &sCommand,HICON &hIconApp) const
{
hIconApp = NULL;
sDisplayName.Empty();
sCommand.Empty();
CString sAppKey(szAppKey);
AddKey(sAppKey,sAppName);
AddKey(sAppKey,szShellKey);
HKEY hKey;
if (RegOpenKeyEx(HKEY_CLASSES_ROOT,sAppKey,0,KEY_READ,&hKey) != ERROR_SUCCESS)
return;
BYTE szDisplayName[_MAX_PATH];
DWORD dwSize=sizeof(szDisplayName);
DWORD dwType=REG_SZ;
LONG nRet = RegQueryValueEx(hKey,szDisplayNameEntry,NULL,&dwType,szDisplayName,&dwSize);
if (nRet != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return;
}
sDisplayName = szDisplayName;
TCHAR szSubKey[_MAX_PATH];
TCHAR szClass[_MAX_PATH];
DWORD dwSizeSubKey = sizeof(szSubKey)-1;
DWORD dwSizeClass = sizeof(szClass)-1;
ZeroMemory(szSubKey,sizeof(szSubKey));
ZeroMemory(szClass,sizeof(szClass));
FILETIME ftLastWriteTime;
HKEY hCmdKey=NULL;
CString sCmdKey;
// Search for a key that contains the "command" key as it may not be under "open"
for(DWORD dwIndex=0;RegEnumKeyEx(hKey,dwIndex,
szSubKey,
&dwSizeSubKey,
NULL,
szClass,
&dwSizeClass,
&ftLastWriteTime) == ERROR_SUCCESS;dwIndex++)
{
sCmdKey = szSubKey;
AddKey(sCmdKey,szCommandKey);
if (RegOpenKeyEx(hKey,sCmdKey,0,KEY_READ,&hCmdKey) == ERROR_SUCCESS)
{
break;
}
dwSizeSubKey = sizeof(szSubKey)-1;
dwSizeClass = sizeof(szClass)-1;
}
RegCloseKey(hKey);
hKey = NULL;
if (hCmdKey == NULL)
return;
dwType=REG_SZ | REG_EXPAND_SZ;
BYTE szCommand[_MAX_PATH];
dwSize=sizeof(szCommand);
nRet = RegQueryValueEx(hCmdKey,NULL,NULL,&dwType,szCommand,&dwSize);
if (nRet != ERROR_SUCCESS)
return;
TCHAR szPath[MAX_PATH];
sCommand = szCommand;
if (ExpandEnvironmentStrings(sCommand,szPath,sizeof(szPath)))
sCommand = szPath;
CString sIconPath(sCommand);
sIconPath.MakeLower();
// Only extract icons from exe's at the moment
int nPos = sIconPath.Find(_T(".exe"));
if (nPos == -1)
return;
sIconPath = sIconPath.Left(nPos+4);
// Remove auy quotes
if (sIconPath.Left(1) == '\"')
sIconPath = sIconPath.Right(sIconPath.GetLength()-1);
if (sIconPath.Right(1) == '\"')
sIconPath = sIconPath.Left(sIconPath.GetLength()-1);
ExtractIconEx(sIconPath, 0, NULL, &hIconApp, 1);
RegCloseKey(hCmdKey);
}
// reg helper
void CShellContextMenu::AddKey(CString &sDestKey,const CString &sSrcKey) const
{
if (sDestKey.Right(1) != '\\')
sDestKey += '\\';
sDestKey += sSrcKey;
}
////////////////////////////////////////
bool CShellContextMenu::IsMenuCommand(int iCmd) const
{
return (
(IDM_SENDTOFIRST <= iCmd && iCmd <= IDM_SENDTOLAST) ||
(IDM_SHELLCTXFIRST <= iCmd && iCmd <= IDM_SHELLCTXLAST)
);
}
void CShellContextMenu::InvokeCommand(int iCmd) const
{
if (!iCmd)
return;
USES_CONVERSION;
/////////////////////////////
if (IDM_SENDTOFIRST <= iCmd && iCmd <= IDM_SENDTOLAST)
{
// "Send To..." item
CPIDL pidlFile(m_sAbsPath), pidlDrop;
LPDROPTARGET pDT;
LPDATAOBJECT pDO;
HRESULT hr;
hr = pidlFile.GetUIObjectOf(IID_IDataObject, (LPVOID *)&pDO,
m_hWnd);
if (SUCCEEDED(hr))
{
pidlDrop.Set((LPITEMIDLIST)
CCoolMenuManager::GetItemData(*m_pSendToMenu, iCmd));
hr = pidlDrop.GetUIObjectOf(IID_IDropTarget,
(LPVOID *)&pDT, m_hWnd);
if (SUCCEEDED(hr))
{
// do the drop
POINTL pt = { 0, 0 };
DWORD dwEffect =
DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK;
hr = pDT->DragEnter(pDO, MK_LBUTTON, pt, &dwEffect);
if (SUCCEEDED(hr) && dwEffect)
{
hr = pDT->Drop(pDO, MK_LBUTTON, pt, &dwEffect);
}
else
{
hr = pDT->DragLeave();
}
pDT->Release();
}
pidlDrop.m_pidl = NULL;
}
}
else
{
DWORD dwItemData=0;
CMenu *pMenu=NULL;
STL_FOR_ITERATOR(vecODMenu,m_OwnerDrawMenus)
{
pMenu = STL_GET_CURRENT(m_OwnerDrawMenus);
if (pMenu && pMenu->GetMenuItemCount() > 0)
{
// switch to original item data
if ((UINT)iCmd >= pMenu->GetMenuItemID(0) && (UINT)iCmd <= pMenu->GetMenuItemID(pMenu->GetMenuItemCount()-1))
{
dwItemData = g_CoolMenuManager.SwitchContextItemData(pMenu,iCmd,0,FALSE);
break;
}
}
}
CWaitCursor w;
// Shell command
CMINVOKECOMMANDINFO cmi;
cmi.cbSize = sizeof(cmi);
cmi.fMask = 0;
cmi.hwnd = m_hWnd;
cmi.lpVerb = T2CA(MAKEINTRESOURCE(iCmd - IDM_SHELLCTXFIRST));
cmi.lpParameters = NULL;
cmi.lpDirectory = NULL;
cmi.nShow = SW_SHOWNORMAL;
cmi.dwHotKey = 0;
cmi.hIcon = NULL;
m_lpcm->InvokeCommand(&cmi);
// switch back to our item data
if (dwItemData)
{
g_CoolMenuManager.SwitchContextItemData(pMenu,iCmd,dwItemData,FALSE);
}
}
}
// retrieves the shell context menu for a file
void CShellContextMenu::SetMenu(CMenu *pMenu)
{
if (m_sAbsPath.IsEmpty())
return;
ASSERT(m_psfParent);
HRESULT hr = m_psfParent->GetUIObjectOf(m_hWnd, m_cidl, (LPCITEMIDLIST*)m_ppidl, IID_IContextMenu, NULL, (LPVOID *)&m_lpcm);
// NOTE: Slight change to return here but change it back if you want: PO
if (FAILED(hr))
return;
g_CoolMenuManager.UnconvertMenu(pMenu);
g_CoolMenuManager.SetShellContextMenu(m_lpcm,IDM_SHELLCTXFIRST,IDM_SHELLCTXLAST);
pMenu->DeleteMenu(0, MF_BYPOSITION);
hr = m_lpcm->QueryContextMenu(*pMenu, 0, IDM_SHELLCTXFIRST,
IDM_SHELLCTXLAST, CMF_EXPLORE);
/////////////////////////////
// Additions Philip Oldaker
// Check for IContextMenu2 used by owner draw menus
CMenu *pSubMenu;
int count = pMenu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CMenuItemInfo mii;
mii.fMask = MIIM_TYPE | MIIM_ID;
pMenu->GetMenuItemInfo(i,&mii,TRUE);
if (mii.fType & MFT_OWNERDRAW)
{
TRACE(_T("OwnerDraw menu item found in CShellContextMenu\n"));
g_CoolMenuManager.AddShellContextMenu(pMenu,m_lpcm,i);
STL_ADD_ITEM(m_OwnerDrawMenus,pMenu);
}
pSubMenu = pMenu->GetSubMenu(i);
/////////////////////////////
// Additions Philip Oldaker
// Search for owner draw menus and add the ICM2 pointer
if (pSubMenu)
{
// NOTE: Remove the TRACE statements if not needed
UINT nSubCount = pSubMenu->GetMenuItemCount();
TRACE(_T("Count=%u\n"),nSubCount);
for(UINT m=0;m < nSubCount;m++)
{
CMenuItemInfo mii;
mii.fMask = MIIM_TYPE;
pSubMenu->GetMenuItemInfo(m,&mii,TRUE);
if (mii.fType & MFT_OWNERDRAW)
{
TRACE(_T("OwnerDraw submenu found in CShellContextMenu\n"));
g_CoolMenuManager.AddShellContextMenu(pSubMenu,m_lpcm,m);
STL_ADD_ITEM(m_OwnerDrawMenus,pSubMenu);
}
}
}
/////////////////////////////
// find the "Send To" and the new "Open With" submenu: look for a defined menu item id
if (pSubMenu && pSubMenu->GetMenuItemCount() == 1)
{
CString str;
pSubMenu->GetMenuString(0,str,MF_BYPOSITION);
UINT idmFirst = pSubMenu->GetMenuItemID(0);
TRACE(_T("Menu Item %s=%d\n"),str,idmFirst);
/////////////////////////////
// Additions Philip Oldaker
// Populate the OpenWith menu
if (idmFirst == IDM_OPENWITHID1 || idmFirst == IDM_OPENWITHID2)
{
// ok - found it. now populate it
IContextMenu2 *lpcm2=NULL;
HRESULT hr = m_lpcm->QueryInterface(IID_IContextMenu2,(LPVOID*)&lpcm2);
if (SUCCEEDED(hr))
{
hr = lpcm2->HandleMenuMsg(WM_INITMENUPOPUP,(WPARAM)pSubMenu->GetSafeHmenu(),0);
lpcm2->Release();
// We need the extension to search the registry for valid applications
CString sExt(GetExt(m_sAbsPath));
// No extension then there's nothing to do
if (sExt.IsEmpty())
continue;
FillOpenWithMenu(pSubMenu,sExt);
STL_ADD_ITEM(m_OwnerDrawMenus,pSubMenu);
}
}
else if (idmFirst == IDM_SENDTOID)
{
UINT idm = IDM_SENDTOFIRST;
// ok - found it. now populate it
m_pSendToMenu = CMenu::FromHandle(::CreatePopupMenu());
ASSERT_VALID(m_pSendToMenu);
pSubMenu->DestroyMenu();
pMenu->ModifyMenu(i, MF_BYPOSITION | MF_POPUP,
(UINT)m_pSendToMenu->m_hMenu, str);
FillSendToMenu(m_pSendToMenu, stat_data.m_sfSendTo, idm);
}
/////////////////////////////
}
}
// Not needed I think :PO
return;
}
////////////////////////////
// Additions: Philip Oldaker
// Scan the registry looking for a OpenWithList key in this format
// Entry MRUList contains the alphabetical order eg. afgrde for each entry
// each of these entries points to the application name which in turn
// has the command and display name
////////////////////////////
void CShellContextMenu::FillOpenWithMenu(CMenu *pMenu,const CString &sExt)
{
HKEY hKey;
CString sFileExtKey(szFileExtKey);
AddKey(sFileExtKey,sExt);
AddKey(sFileExtKey,szOpenWithListKey);
if (RegOpenKeyEx(HKEY_CURRENT_USER,sFileExtKey,0,KEY_READ,&hKey) != ERROR_SUCCESS)
return;
BYTE szMRUList[_MAX_PATH];
szMRUList[0] = 0;
DWORD dwSize=sizeof(szMRUList);
DWORD dwType=REG_SZ;
RegQueryValueEx(hKey,szMRUListEntry,NULL,&dwType,szMRUList,&dwSize);
int nLen = _tcslen((LPCTSTR)szMRUList);
TCHAR szOpenWithItemEntry[sizeof(TCHAR)*2];
ZeroMemory(szOpenWithItemEntry,sizeof(szOpenWithItemEntry));
BYTE szOpenWithItem[_MAX_PATH];
CString sDisplayName;
HICON hIconApp;
CString sCommand;
CString sMenuText;
for(int i=0;i < nLen;i++)
{
szOpenWithItemEntry[0] = szMRUList[i];
dwSize = sizeof(szOpenWithItem);
RegQueryValueEx(hKey,szOpenWithItemEntry,NULL,&dwType,szOpenWithItem,&dwSize);
GetAppDetails(szOpenWithItem, sDisplayName, sCommand, hIconApp);
if (!sCommand.IsEmpty())
{
for(UINT idm=0;idm < pMenu->GetMenuItemCount();idm++)
{
pMenu->GetMenuString(idm,sMenuText,MF_BYPOSITION);
if (sMenuText == sDisplayName)
{
g_CoolMenuManager.ConvertMenuItem(pMenu, idm);
CCoolMenuManager::SetItemIcon(*pMenu, hIconApp, idm, TRUE);
break;
}
}
}
}
RegCloseKey(hKey);
}
void CShellContextMenu::FillSendToMenu(CMenu *pMenu, LPSHELLFOLDER pSF,
UINT &idm)
{
if (pSF == NULL)
return;
USES_CONVERSION;
CPIDL pidl, abspidl;
LPENUMIDLIST peidl;
HRESULT hr;
STRRET str;
UINT idmStart = idm;
LPSHELLFOLDER pSubSF;
SHFILEINFO sfi;
vecCMSort vMenuItems;
int idx_folder = 0; // folder insertion index
hr = pSF->EnumObjects(m_hWnd,
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &peidl);
if (FAILED(hr))
return;
g_CoolMenuManager.ConvertMenu(pMenu);
while (peidl->Next(1, pidl, NULL) == S_OK &&
idm < IDM_SENDTOLAST)
{
hr = pSF->GetDisplayNameOf(pidl, SHGDN_NORMAL, &str);
if (SUCCEEDED(hr))
{
ULONG ulAttrs = (unsigned)-1;
pSF->GetAttributesOf(1, pidl, &ulAttrs);
abspidl.MakeAbsPIDLOf(pSF, pidl);
SHGetFileInfo((LPCTSTR)abspidl.m_pidl, 0, &sfi, sizeof(sfi),
SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON);
pidl.ExtractCStr(str);
if (ulAttrs & SFGAO_FOLDER) // folder?
{
// create new submenu & recurse
HMENU hSubMenu = ::CreateMenu();
pMenu->InsertMenu(idx_folder,
MF_POPUP | MF_BYPOSITION | MF_STRING,
(UINT)hSubMenu, A2T(str.cStr));
g_CoolMenuManager.ConvertMenuItem(pMenu,
idx_folder);
CCoolMenuManager::SetItemIcon(*pMenu,
sfi.hIcon, idx_folder, TRUE);
idx_folder++;
hr = pSF->BindToObject(pidl, NULL,
IID_IShellFolder, (LPVOID *)&pSubSF);
if (!SUCCEEDED(hr)) pSubSF = NULL;
FillSendToMenu(CMenu::FromHandle(hSubMenu), pSubSF,
idm);
if (pSubSF) pSubSF->Release();
abspidl.Free();
}
else
{
CShCMSort *pSMI = new CShCMSort(idm,pidl.m_pidl,sfi.hIcon,A2T(str.cStr),(DWORD)abspidl.m_pidl);
STL_ADD_ITEM(vMenuItems,pSMI);
idm++;
}
abspidl.m_pidl = NULL;
}
}
peidl->Release();
// Addition: Philip Oldaker
// To keep it familiar the SendTo menu is sorted
STL_SORT(vMenuItems,pSF,STL_SORT_FUNC);
CShCMSort *pItem=NULL;
STL_FOR_ITERATOR(vecCMSort,vMenuItems)
{
pItem = STL_GET_CURRENT(vMenuItems);
pMenu->AppendMenu(MF_STRING, pItem->GetItemID(), pItem->GetText());
g_CoolMenuManager.ConvertMenuItem(pMenu,
pMenu->GetMenuItemCount() - 1);
CCoolMenuManager::SetItemIcon(*pMenu,
pItem->GetIcon(), pItem->GetItemID());
CCoolMenuManager::SetItemData(*pMenu,
(void*)pItem->GetItemData(), pItem->GetItemID());
CPIDL toFree(pItem->GetPidl());
delete pItem;
}
STL_ERASE_ALL(vMenuItems);
//////////////////////////////////
// If the menu is still empty (the user has an empty SendTo folder),
// then add a disabled "(empty)" item so we have at least something
// to display.
if (idm == idmStart)
{
pMenu->AppendMenu(MF_GRAYED | MF_DISABLED | MF_STRING, idm,
_T("(empty)"));
idm++;
}
}
@@ -1,96 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "ShellDetails.h"
HRESULT CShellDetails::GetDetailsOf(LPCITEMIDLIST pidl,UINT iColumn,LPSHELLDETAILS pDetail)
{
HRESULT hr=E_FAIL;
if (m_pUnk == NULL)
return hr;
IShellFolder2 *pShellFolder2=NULL;
hr = m_pUnk->QueryInterface(IID_IShellFolder2,(LPVOID*)&pShellFolder2);
if (SUCCEEDED(hr))
{
hr = pShellFolder2->GetDetailsOf(pidl,iColumn,pDetail);
pShellFolder2->Release();
}
else
{
IShellDetails *pShellDetails=NULL;
hr = m_pUnk->QueryInterface(IID_IShellDetails,(LPVOID*)&pShellDetails);
if (SUCCEEDED(hr))
{
hr = pShellDetails->GetDetailsOf(pidl,iColumn,pDetail);
pShellDetails->Release();
}
}
return hr;
}
bool CShellDetails::IsValidDetails()
{
return m_pUnk != NULL;
}
void CShellDetails::SetShellDetails(IUnknown *pUnk)
{
FreeInterfaces();
if (pUnk)
{
m_pUnk = pUnk;
m_pUnk->AddRef();
}
}
CShellDetails::CShellDetails(const CShellDetails &rOther)
: m_pUnk(rOther.m_pUnk)
{
m_pUnk->AddRef();
}
const CShellDetails &CShellDetails::operator=(const CShellDetails &rOther)
{
if (this == &rOther)
return *this;
FreeInterfaces();
m_pUnk = rOther.m_pUnk;
m_pUnk->AddRef();
return *this;
}
void CShellDetails::FreeInterfaces()
{
if (m_pUnk)
{
m_pUnk->Release();
m_pUnk = NULL;
}
}
CShellDetails::CShellDetails()
{
m_pUnk = NULL;
}
CShellDetails::~CShellDetails()
{
FreeInterfaces();
}
@@ -1,804 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// ShellPidl.cpp: implementation of the CShellPidl class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ShellPidl.h"
#include "UIMessages.h"
#include <intshcut.h>
#include <subsmgr.h>
#include <ExDisp.h>
#include "ShellContextMenu.h"
#include "UICoolMenu.h"
#include "cbformats.h"
#define SF_DRAGDROP_FLAGS SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK;
UINT CF_IDLIST = RegisterClipboardFormat(CFSTR_SHELLIDLIST);
UINT CF_SHELLURL = RegisterClipboardFormat(CFSTR_SHELLURL);
#define TPM_FLAGS (TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CShellPidl::CShellPidl()
{
SHGetMalloc(&m_pMalloc);
SHGetDesktopFolder(&m_psfDesktop);
ZeroMemory(&m_EmptyPidl,sizeof(ITEMIDLIST));
}
CShellPidl::~CShellPidl()
{
if (m_pMalloc)
m_pMalloc->Release();
if (m_psfDesktop)
m_psfDesktop->Release();
}
IMalloc *CShellPidl::GetMalloc()
{
return m_pMalloc;
}
DWORD CShellPidl::GetDragDropAttributes(LPLVITEMDATA plvid)
{
return GetDragDropAttributes(plvid->lpsfParent,plvid->lpi);
}
DWORD CShellPidl::GetDragDropAttributes(LPTVITEMDATA ptvid)
{
return GetDragDropAttributes(ptvid->lpsfParent,ptvid->lpi);
}
DWORD CShellPidl::GetDragDropAttributes(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl)
{
if (pFolder == NULL)
pFolder = m_psfDesktop;
DWORD dwAttrs=SF_DRAGDROP_FLAGS;
HRESULT hr = pFolder->GetAttributesOf(1,(LPCITEMIDLIST*)&pidl,&dwAttrs);
if (FAILED(hr))
dwAttrs = SF_DRAGDROP_FLAGS;
return dwAttrs;
}
DWORD CShellPidl::GetDragDropAttributes(COleDataObject *pDataObject)
{
IDataObject *pDataObj = pDataObject->m_lpDataObject;
STGMEDIUM stgm;
ZeroMemory(&stgm, sizeof(stgm));
FORMATETC fetc;
fetc.cfFormat = CF_IDLIST;
fetc.ptd = NULL;
fetc.dwAspect = DVASPECT_CONTENT;
fetc.lindex = -1;
fetc.tymed = TYMED_HGLOBAL;
DWORD dwAttrs=DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK;
HRESULT hr = pDataObj->QueryGetData(&fetc);
if (FAILED(hr))
return dwAttrs;
hr = pDataObj->GetData(&fetc, &stgm);
if (FAILED(hr))
return dwAttrs;
DWORD pData = (DWORD)GlobalLock(stgm.hGlobal);
LPIDA pIDList = (LPIDA)pData;
UINT nFolderOffset = pIDList->aoffset[0];
TRACE2("PIDL(%u) offfset=%u\n",0,nFolderOffset);
DWORD pFolder = pData+nFolderOffset;
LPITEMIDLIST pidl = (LPITEMIDLIST)pFolder;
LPSHELLFOLDER psfParent = GetFolder(pidl);
if (psfParent)
{
// get attributes for the children
TRACE1("PIDL count=%u\n",pIDList->cidl);
for(UINT i=1;i < (pIDList->cidl+1);i++)
{
UINT nListOffset = pIDList->aoffset[i];
TRACE2("PIDL(%u) offfset=%u\n",i,nListOffset);
ULONG ulAttrs = SF_DRAGDROP_FLAGS;
DWORD dwPidl = pData+nListOffset;
LPITEMIDLIST pidlist = (LPITEMIDLIST)dwPidl;
psfParent->GetAttributesOf(1,(LPCITEMIDLIST*)&pidlist,&ulAttrs);
#ifdef _DEBUG
CString sPath;
SHPidlToPathEx(pidlist,sPath,psfParent);
TRACE2("Drag drop source path=%s Attributes=%u\n",sPath,ulAttrs);
#endif
if (ulAttrs)
dwAttrs = dwAttrs & ulAttrs;
}
psfParent->Release();
}
GlobalUnlock(stgm.hGlobal);
ReleaseStgMedium(&stgm);
return dwAttrs;
}
LPCITEMIDLIST CShellPidl::GetEmptyPidl()
{
return &m_EmptyPidl;
}
bool CShellPidl::IsDesktopFolder(LPSHELLFOLDER psFolder)
{
return psFolder == NULL || psFolder == m_psfDesktop;
}
LPSHELLFOLDER CShellPidl::GetDesktopFolder()
{
return m_psfDesktop;
}
LPSHELLFOLDER CShellPidl::GetFolder(LPITEMIDLIST pidl)
{
if (pidl == NULL || pidl->mkid.cb == 0)
return m_psfDesktop;
LPSHELLFOLDER pFolder=NULL;
if (FAILED(m_psfDesktop->BindToObject(pidl, 0, IID_IShellFolder,(LPVOID*)&pFolder)))
return NULL;
return pFolder;
}
// CopyItemID - creates an item identifier list containing the first
// item identifier in the specified list.
// Returns a PIDL if successful, or NULL if out of memory.
LPITEMIDLIST CShellPidl::CopyItemID(LPITEMIDLIST pidl,int n)
{
// Get the size of the specified item identifier.
ASSERT(pidl);
if (n == 0)
{
int cb = pidl->mkid.cb;
int nSize = cb + sizeof(pidl->mkid.cb);
// Allocate a new item identifier list.
LPITEMIDLIST pidlNew = (LPITEMIDLIST)m_pMalloc->Alloc(nSize);
ZeroMemory(pidlNew,nSize);
if (pidlNew == NULL)
return NULL;
// Copy the specified item identifier.
CopyMemory(pidlNew, pidl, nSize-sizeof(pidl->mkid.cb));
return pidlNew;
}
else
{
LPITEMIDLIST pidl_index=NULL;
for(int i=0;i < n && pidl->mkid.cb;i++)
{
pidl_index = pidl;
pidl = Next(pidl);
}
return pidl_index ? CopyItemID(pidl_index,0) : NULL;
}
return NULL;
}
// Returns a PIDL if successful, or NULL if out of memory.
LPITEMIDLIST CShellPidl::CopyLastItemID(LPITEMIDLIST pidl)
{
// Get the size of the specified item identifier.
ASSERT(pidl);
if (pidl == NULL)
return NULL;
LPITEMIDLIST last_pidl=pidl;
while (pidl->mkid.cb)
{
last_pidl = pidl;
pidl = Next(pidl);
}
if (last_pidl == NULL)
return NULL;
return CopyItemID(last_pidl);
}
// copies the absolute pidl up till n
LPITEMIDLIST CShellPidl::CopyAbsItemID(LPITEMIDLIST pidl,int n)
{
// Get the size of the specified item identifier.
ASSERT(pidl);
if (pidl == NULL)
return NULL;
LPITEMIDLIST first_pidl=NULL;
LPITEMIDLIST abs_pidl=NULL;
LPITEMIDLIST new_abs_pidl=NULL;
for(int i=0;i < n && pidl && pidl->mkid.cb;i++)
{
first_pidl = CopyItemID(pidl);
new_abs_pidl = ConcatPidl(abs_pidl,first_pidl);
if (abs_pidl)
{
m_pMalloc->Free(abs_pidl);
}
abs_pidl = new_abs_pidl;
if (first_pidl)
{
m_pMalloc->Free(first_pidl);
}
pidl = Next(pidl);
}
return new_abs_pidl;
}
// Makes a copy of an ITEMIDLIST
LPITEMIDLIST CShellPidl::CopyItemIDList(LPITEMIDLIST pidl)
{
// Allocate a new item identifier list.
int nSize = GetSize(pidl);
LPITEMIDLIST pidlNew = (LPITEMIDLIST)m_pMalloc->Alloc(nSize);
ZeroMemory(pidlNew,nSize);
if (pidlNew == NULL)
return NULL;
// Copy the specified item identifier.
CopyMemory(pidlNew, pidl, nSize);
return pidlNew;
}
bool CShellPidl::CompareMemPidls(LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2)
{
// Allocate a new item identifier list.
if (pidl1 == NULL || pidl2 == NULL)
return false;
return memcmp(pidl1,pidl2,(size_t)GetSize(pidl1)) == 0;
}
// Returns true if lists are the same
bool CShellPidl::ComparePidls(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2)
{
// Allocate a new item identifier list.
if (pFolder == NULL)
pFolder = GetDesktopFolder();
if (pidl1 == NULL || pidl2 == NULL)
return false;
return (short)pFolder->CompareIDs(0,pidl1,pidl2) == 0;
}
void CShellPidl::Free(void *pv)
{
if (m_pMalloc)
m_pMalloc->Free(pv);
}
void CShellPidl::FreePidl(LPITEMIDLIST pidl)
{
if (m_pMalloc)
m_pMalloc->Free(pidl);
}
UINT CShellPidl::GetCount(LPCITEMIDLIST pidl)
{
UINT nCount = 0;
if (pidl)
{
while (pidl->mkid.cb)
{
pidl = Next(pidl);
nCount++;
}
}
return nCount;
}
UINT CShellPidl::GetSize(LPCITEMIDLIST pidl)
{
UINT cbTotal = 0;
if (pidl)
{
cbTotal += sizeof(pidl->mkid.cb); // Null terminator
while (pidl->mkid.cb)
{
cbTotal += pidl->mkid.cb;
pidl = Next(pidl);
}
}
return cbTotal;
}
LPITEMIDLIST CShellPidl::Next(LPCITEMIDLIST pidl)
{
LPSTR lpMem=(LPSTR)pidl;
lpMem+=pidl->mkid.cb;
return (LPITEMIDLIST)lpMem;
}
LPITEMIDLIST CShellPidl::ConcatPidl(LPITEMIDLIST pidlDest,LPITEMIDLIST pidlSrc)
{
// Get the size of the specified item identifier.
UINT cbDest=0;
UINT cbSrc=0;
if (pidlDest) //May be NULL
cbDest = GetSize(pidlDest) - sizeof(pidlDest->mkid.cb);
cbSrc = GetSize(pidlSrc);
// Allocate a new item identifier list.
LPITEMIDLIST pidlNew = (LPITEMIDLIST)m_pMalloc->Alloc(cbSrc+cbDest);
if (pidlNew == NULL)
return NULL;
ZeroMemory(pidlNew,cbSrc+cbDest);
// Copy the specified item identifier.
if (pidlDest)
CopyMemory(pidlNew, pidlDest, cbDest);
CopyMemory(((USHORT*)(((LPBYTE)pidlNew)+cbDest)), pidlSrc, cbSrc);
return pidlNew;
}
int CShellPidl::GetIcon(LPITEMIDLIST lpi, UINT uFlags)
{
SHFILEINFO sfi;
ZeroMemory(&sfi,sizeof(sfi));
if (uFlags == 0)
uFlags |= (SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
uFlags |= SHGFI_PIDL;
SHGetFileInfo((LPCTSTR)lpi, 0, &sfi, sizeof(SHFILEINFO), uFlags);
return sfi.iIcon;
}
STDMETHODIMP CShellPidl::SHPidlToPathEx(LPCITEMIDLIST pidl, CString &sPath, LPSHELLFOLDER pFolder, DWORD dwFlags)
{
STRRET StrRetFilePath;
LPTSTR pszFilePath = NULL;
HRESULT hr=E_FAIL;
if (pFolder == NULL)
pFolder = GetDesktopFolder();
if (pFolder == NULL)
return E_FAIL;
hr = pFolder->GetDisplayNameOf(pidl, dwFlags, &StrRetFilePath);
if (SUCCEEDED(hr))
{
StrRetToStr(StrRetFilePath, &pszFilePath, (LPITEMIDLIST)pidl);
sPath = pszFilePath;
}
if (pszFilePath)
m_pMalloc->Free(pszFilePath);
return hr;
}
STDMETHODIMP CShellPidl::SHPathToPidlEx(LPCTSTR szPath, LPITEMIDLIST* ppidl, LPSHELLFOLDER pFolder)
{
OLECHAR wszPath[MAX_PATH] = {0};
ULONG nCharsParsed = 0;
LPSHELLFOLDER pShellFolder = NULL;
BOOL bFreeOnExit = FALSE;
#ifdef UNICODE
lstrcpy(wszPath,szPath);
#else
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1, wszPath, MAX_PATH);
#endif
// Use the desktop's IShellFolder by default
if(pFolder == NULL)
{
SHGetDesktopFolder(&pShellFolder);
bFreeOnExit = TRUE;
}
else
pShellFolder = pFolder;
HRESULT hr = pShellFolder->ParseDisplayName(NULL, NULL, wszPath, &nCharsParsed, ppidl, NULL);
if(bFreeOnExit)
pShellFolder->Release();
return hr;
}
void CShellPidl::GetTypeName(LPITEMIDLIST lpi,CString &sTypeName)
{
SHFILEINFO sfi;
ZeroMemory(&sfi,sizeof(sfi));
UINT uFlags = SHGFI_PIDL | SHGFI_TYPENAME;
SHGetFileInfo((LPCTSTR)lpi, 0, &sfi, sizeof(SHFILEINFO), uFlags);
sTypeName = sfi.szTypeName;
}
void CShellPidl::GetDisplayName(LPITEMIDLIST lpifq,CString &sDisplayName)
{
SHFILEINFO sfi;
ZeroMemory(&sfi,sizeof(sfi));
UINT uFlags = SHGFI_PIDL | SHGFI_DISPLAYNAME;
SHGetFileInfo((LPCTSTR)lpifq, 0, &sfi, sizeof(SHFILEINFO), uFlags);
sDisplayName = sfi.szDisplayName;
}
void CShellPidl::GetNormalAndSelectedIcons (
LPITEMIDLIST lpifq, int &iImage, int &iSelectedImage)
{
// Don't check the return value here.
// If IGetIcon() fails, you're in big trouble.
iImage = GetIcon (lpifq,
SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
iSelectedImage = GetIcon (lpifq,
SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON);
return;
}
BOOL CShellPidl::HandleMenuMsg(HWND hwnd, LPSHELLFOLDER lpsfParent,
LPITEMIDLIST lpi, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LPCONTEXTMENU lpcm=NULL;
HRESULT hr=lpsfParent->GetUIObjectOf(hwnd,
1, // get attributes for this many objects
(const struct _ITEMIDLIST **)&lpi,
IID_IContextMenu,
0,
(LPVOID *)&lpcm);
if (SUCCEEDED(hr))
{
LPCONTEXTMENU2 lpcm2=NULL;
hr = lpcm->QueryInterface(IID_IContextMenu2,(LPVOID*)&lpcm2);
lpcm->Release();
if (SUCCEEDED(hr))
{
lpcm2->HandleMenuMsg(uMsg,wParam,lParam);
lpcm2->Release();
}
return TRUE;
}
return FALSE;
}
BOOL CShellPidl::PopupTheMenu(HWND hwnd, LPSHELLFOLDER lpsfParent,
LPITEMIDLIST *plpi, UINT cidl, LPPOINT lppt)
{
CMenu menu;
menu.CreatePopupMenu();
g_CoolMenuManager.Install(CWnd::FromHandle(hwnd));
CString sPath;
if (lpsfParent == NULL)
lpsfParent = GetDesktopFolder();
SHPidlToPathEx(*plpi,sPath,lpsfParent);
CShellContextMenu shell_menu(hwnd,sPath,plpi,cidl,lpsfParent);
shell_menu.SetMenu(&menu);
int idCmd = menu.TrackPopupMenu(TPM_FLAGS, lppt->x, lppt->y, CWnd::FromHandle(hwnd));
shell_menu.InvokeCommand(idCmd);
g_CoolMenuManager.Uninstall();
return TRUE;
}
/****************************************************************************
*
* FUNCTION: GetName(LPSHELLFOLDER lpsf,LPITEMIDLIST lpi,DWORD dwFlags,
* LPSTR lpFriendlyName)
*
* PURPOSE: Gets the friendly name for the folder
*
****************************************************************************/
BOOL CShellPidl::GetName (LPSHELLFOLDER lpsf, LPITEMIDLIST lpi,
DWORD dwFlags, CString &sFriendlyName)
{
BOOL bSuccess=TRUE;
STRRET str;
if (NOERROR==lpsf->GetDisplayNameOf(lpi,dwFlags, &str))
{
switch (str.uType)
{
case STRRET_WSTR:
#ifdef UNICODE
_tcscpy(sFriendlyName.GetBuffer(MAX_PATH),str.pOleStr);
sFriendlyName.ReleaseBuffer();
#else
WideCharToMultiByte(
CP_ACP, // code page
0, // dwFlags
str.pOleStr, // lpWideCharStr
-1, // cchWideCharStr
sFriendlyName.GetBuffer(_MAX_PATH), // lpMultiByteStr
_MAX_PATH, // cchMultiByte
NULL, // lpDefaultChar
NULL); // lpUsedDefaultChar
#endif
sFriendlyName.ReleaseBuffer();
break;
case STRRET_OFFSET:
sFriendlyName = (LPTSTR)lpi+str.uOffset;
break;
case STRRET_CSTR:
sFriendlyName = (LPTSTR)str.cStr;
break;
default:
bSuccess = FALSE;
break;
}
}
else
bSuccess = FALSE;
return bSuccess;
}
//
// ResolveChannel: Resolves a Channel Shortcut to its URL
//
STDMETHODIMP CShellPidl::ResolveChannel(IShellFolder* pFolder, LPCITEMIDLIST pidl, LPTSTR* lpszURL)
{
IShellLink* pShellLink;
*lpszURL = NULL; // Assume failure
// Get a pointer to the IShellLink interface from the given folder
HRESULT hr = pFolder->GetUIObjectOf(NULL, 1, &pidl, IID_IShellLink, NULL, (LPVOID*)&pShellLink);
if (SUCCEEDED(hr))
{
LPITEMIDLIST pidlChannel;
// Convert the IShellLink pointer to a PIDL.
hr = pShellLink->GetIDList(&pidlChannel);
if (SUCCEEDED(hr))
{
IShellFolder* psfDesktop;
hr = SHGetDesktopFolder(&psfDesktop);
if (SUCCEEDED(hr))
{
STRRET strret;
hr = psfDesktop->GetDisplayNameOf(pidlChannel, 0, &strret);
if (SUCCEEDED(hr))
StrRetToStr(strret, lpszURL, pidlChannel);
psfDesktop->Release();
}
}
pShellLink->Release();
}
return hr;
}
STDMETHODIMP CShellPidl::ResolveHistoryShortcut(LPSHELLFOLDER pFolder,LPCITEMIDLIST *ppidl,CString &sURL)
{
HRESULT hr=E_FAIL;
IDataObject *pObj=NULL;
hr = pFolder->GetUIObjectOf(NULL, 1, ppidl, IID_IDataObject, NULL, (LPVOID*)&pObj);
if (SUCCEEDED(hr))
{
hr = GetURL(pObj,sURL);
pObj->Release();
}
return hr;
}
STDMETHODIMP CShellPidl::GetURL(IDataObject *pDataObj,CString &sURL)
{
sURL.Empty();
STGMEDIUM stgm;
ZeroMemory(&stgm, sizeof(stgm));
FORMATETC fetc;
fetc.cfFormat = CF_SHELLURL;
fetc.ptd = NULL;
fetc.dwAspect = DVASPECT_CONTENT;
fetc.lindex = -1;
fetc.tymed = TYMED_HGLOBAL;
HRESULT hr = pDataObj->QueryGetData(&fetc);
if (FAILED(hr))
return hr;
hr = pDataObj->GetData(&fetc, &stgm);
if (FAILED(hr))
return hr;
LPCTSTR pData = (LPCTSTR)GlobalLock(stgm.hGlobal);
sURL = pData;
GlobalUnlock(stgm.hGlobal);
ReleaseStgMedium(&stgm);
return S_OK;
}
//
// ResolveInternetShortcut: Resolves an Internet Shortcut to its URL
//
STDMETHODIMP CShellPidl::ResolveInternetShortcut(LPCTSTR lpszLinkFile, LPTSTR* lpszURL)
{
IUniformResourceLocator* pUrlLink = NULL;
*lpszURL=NULL;
HRESULT hr = CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER,
IID_IUniformResourceLocator, (LPVOID*)&pUrlLink);
if (FAILED(hr))
return hr;
IPersistFile* pPersistFile = NULL;
hr = pUrlLink->QueryInterface(IID_IPersistFile, (LPVOID*)&pPersistFile);
if (SUCCEEDED(hr))
{
// Ensure that the string is Unicode.
WORD wsz[MAX_PATH];
#ifdef UNICODE
_tcscpy(wsz,lpszLinkFile);
#else
MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH);
#endif
// Load the Internet Shortcut from persistent storage.
hr = pPersistFile->Load(wsz, STGM_READ);
if (SUCCEEDED(hr))
{
hr = pUrlLink->GetURL(lpszURL);
}
pPersistFile->Release();
}
pUrlLink->Release();
return hr;
}
//
// ResolveLink: Resolves a Shell Link to its actual folder location
//
STDMETHODIMP CShellPidl::ResolveLink(HWND hWnd,LPCTSTR lpszLinkFile, LPTSTR* lpszURL)
{
IShellLink* pShellLink = NULL;
*lpszURL = NULL; // Assume failure
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID*)&pShellLink);
if (SUCCEEDED(hr))
{
IPersistFile* pPersistFile = NULL;
hr = pShellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&pPersistFile);
if (SUCCEEDED(hr))
{
// Ensure that the string is Unicode.
WORD wsz[MAX_PATH];
#ifdef UNICODE
_tcscpy(wsz,lpszLinkFile);
#else
MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH);
#endif
// Load the shortcut.from persistent storage
hr = pPersistFile->Load(wsz, STGM_READ);
if (SUCCEEDED(hr))
{
WIN32_FIND_DATA wfd;
hr = pShellLink->Resolve(hWnd, SLR_NO_UI);
if (NOERROR == hr)
{
// Get the path to the link target.
*lpszURL = (LPTSTR)m_pMalloc->Alloc(MAX_PATH); // Must remember to Free later
hr = pShellLink->GetPath(*lpszURL, MAX_PATH - 1, (WIN32_FIND_DATA*)&wfd, SLGP_UNCPRIORITY);
}
}
pPersistFile->Release();
}
pShellLink->Release();
}
return hr;
}
//
// This method converts a STRRET structure to a LPTSTR
//
#ifdef UNICODE
STDMETHODIMP CShellPidl::StrRetToStr(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl)
{
HRESULT hr = S_OK;
int cch;
LPSTR strOffset;
*str = NULL; // Assume failure
switch (StrRet.uType)
{
case STRRET_WSTR:
cch = wcslen(StrRet.pOleStr) + 1; // NULL terminator
*str = (LPTSTR)m_pMalloc->Alloc(cch * sizeof(TCHAR));
if (*str != NULL)
lstrcpyn(*str, StrRet.pOleStr, cch);
else
hr = E_FAIL;
break;
case STRRET_OFFSET:
strOffset = (((char *) pidl) + StrRet.uOffset);
cch = MultiByteToWideChar(CP_OEMCP, 0, strOffset, -1, NULL, 0);
*str = (LPTSTR)m_pMalloc->Alloc(cch * sizeof(TCHAR));
if (*str != NULL)
MultiByteToWideChar(CP_OEMCP, 0, strOffset, -1, *str, cch);
else
hr = E_FAIL;
break;
case STRRET_CSTR:
cch = MultiByteToWideChar(CP_OEMCP, 0, StrRet.cStr, -1, NULL, 0);
*str = (LPTSTR)m_pMalloc->Alloc(cch * sizeof(TCHAR));
if (*str != NULL)
MultiByteToWideChar(CP_OEMCP, 0, StrRet.cStr, -1, *str, cch);
else
hr = E_FAIL;
break;
}
return hr;
}
#else // UNICODE not defined
STDMETHODIMP CShellPidl::StrRetToStr(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl)
{
HRESULT hr = S_OK;
int cch;
LPSTR strOffset;
*str = NULL; // Assume failure
switch (StrRet.uType)
{
case STRRET_WSTR:
cch = WideCharToMultiByte(CP_ACP, 0, StrRet.pOleStr, -1, NULL, 0, NULL, NULL);
*str = (LPTSTR)m_pMalloc->Alloc(cch * sizeof(TCHAR));
if (*str != NULL)
WideCharToMultiByte(CP_ACP, 0, StrRet.pOleStr, -1, *str, cch, NULL, NULL);
else
hr = E_FAIL;
break;
case STRRET_OFFSET:
strOffset = (((char *) pidl) + StrRet.uOffset);
cch = strlen(strOffset) + 1; // NULL terminator
*str = (LPTSTR)m_pMalloc->Alloc(cch * sizeof(TCHAR));
if (*str != NULL)
strcpy(*str, strOffset);
else
hr = E_FAIL;
break;
case STRRET_CSTR:
cch = strlen(StrRet.cStr) + 1; // NULL terminator
*str = (LPTSTR)m_pMalloc->Alloc(cch * sizeof(TCHAR));
if (*str != NULL)
strcpy(*str, StrRet.cStr);
else
hr = E_FAIL;
break;
}
return hr;
}
#endif
@@ -1,65 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "ShellSettings.h"
typedef void (WINAPI *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
CShellSettings::CShellSettings()
{
// Since SHGetSettings is not implemented in all versions of the shell,
// get the function address manually at run time.
// This allows the extension to run on all platforms.
m_hinstShell32 = LoadLibrary(TEXT("shell32.dll"));
ZeroMemory(&m_sfs, sizeof(m_sfs));
// The default is classic Windows 95 style.
m_sfs.fWin95Classic = TRUE;
}
CShellSettings::~CShellSettings()
{
if (m_hinstShell32)
FreeLibrary(m_hinstShell32);
}
bool CShellSettings::GetSettings()
{
if (m_hinstShell32 == NULL)
return false;
PFNSHGETSETTINGSPROC pfnSHGetSettings;
pfnSHGetSettings = (PFNSHGETSETTINGSPROC)GetProcAddress(m_hinstShell32, "SHGetSettings");
if(pfnSHGetSettings)
{
ZeroMemory(&m_sfs, sizeof(m_sfs));
(*pfnSHGetSettings)(&m_sfs,
SSF_DESKTOPHTML | // The fDesktopHTML member is being requested.
SSF_DONTPRETTYPATH | // The fDontPrettyPath member is being requested.
SSF_DOUBLECLICKINWEBVIEW | // The fDoubleClickInWebView member is being requested.
SSF_HIDEICONS | // The fHideIcons member is being requested.
SSF_MAPNETDRVBUTTON | // The fMapNetDrvBtn member is being requested.
SSF_NOCONFIRMRECYCLE | // The fNoConfirmRecycle member is being requested.
SSF_SHOWALLOBJECTS | // The fShowAllObjects member is being requested.
SSF_SHOWATTRIBCOL | // The fShowAttribCol member is being requested.
SSF_SHOWCOMPCOLOR | // The fShowCompColor member is being requested.
SSF_SHOWEXTENSIONS | // The fShowExtensions member is being requested.
SSF_SHOWINFOTIP | // The fShowInfoTip member is being requested.
SSF_SHOWSYSFILES | // The fShowSysFiles member is being requested.
SSF_WIN95CLASSIC); // The fWin95Classic member is being requested.
}
return true;
}
@@ -1,758 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "TextParse.h"
CTextParse::CTextParse()
{
m_szBuffer[0] = '\0';
m_pStartLine = m_szBuffer;
m_pLine = m_szBuffer;
m_pSavePos = m_szBuffer;
}
CTextParse::CTextParse(LPCTSTR pszLine)
{
m_szBuffer[0] = '\0';
Set(pszLine);
}
CTextParse::~CTextParse()
{
}
CTextParse::CTextParse(const CTextParse &tp)
{
m_pLine = tp.m_pLine;
m_pStartLine = tp.m_pStartLine;
m_pSavePos = tp.m_pSavePos;
m_szCopyBuf[0] = '\0';
m_szBuffer[0] = '\0';
_tcscpy(m_szCopyBuf,tp.m_szCopyBuf);
_tcscpy(m_szBuffer,tp.m_szBuffer);
}
const CTextParse& CTextParse::operator=(LPCTSTR lpsz)
{
Set(lpsz);
m_szCopyBuf[0] = '\0';
m_szBuffer[0] = '\0';
return *this;
}
const CTextParse& CTextParse::operator=(const CTextParse &tp)
{
if (*this == tp)
return *this;
m_pLine = tp.m_pLine;
m_pStartLine = tp.m_pStartLine;
m_pSavePos = tp.m_pSavePos;
_tcscpy(m_szCopyBuf,tp.m_szCopyBuf);
_tcscpy(m_szBuffer,tp.m_szBuffer);
return *this;
}
BOOL CTextParse::CharExistFromCurPos(int c,BOOL bForward)
{
LPCTSTR p = m_pLine;
if (bForward)
{
while (*p && *p != c)
p = _tcsinc(p);
}
else
{
while (p > m_pStartLine && *p != c)
p = _tcsdec(m_pLine,p);
}
return *p == c;
}
BOOL CTextParse::ValidCppCharExist(int c,BOOL bForward)
{
LPCTSTR p = m_pLine;
while (*p && *p != c && *p != '/')
p = _tcsinc(p);
return *p == c;
}
BOOL CTextParse::CharExist(LPCTSTR str)
{
LPCTSTR p = m_pStartLine;
while (*p && !IsToken(str,p))
p = _tcsinc(p);
return *p != '\0';
}
BOOL CTextParse::FindString(LPCTSTR str)
{
LPCTSTR p = _tcsstr(m_pLine,str);
if (p)
m_pLine = p;
return p ? TRUE : FALSE;
}
BOOL CTextParse::FindChar(int c)
{
LPCTSTR p = _tcschr(m_pLine,c);
if (p)
m_pLine = p;
return p ? TRUE : FALSE;
}
BOOL CTextParse::MoveUntilChar(int c,BOOL bForward)
{
if (bForward)
{
while(*m_pLine && *m_pLine != c)
m_pLine = _tcsinc(m_pLine);
return *m_pLine != '\0';
}
else
{
while(m_pLine > m_pStartLine && *m_pLine != c)
m_pLine = _tcsdec(m_pStartLine,m_pLine);
return *m_pLine == c;
}
}
BOOL CTextParse::MoveUntilChar(LPCTSTR strTok,BOOL bForward)
{
if (bForward)
{
while(*m_pLine && !IsToken(strTok,m_pLine))
m_pLine = _tcsinc(m_pLine);
return *m_pLine != '\0';
}
else
{
while(m_pLine > m_pStartLine && !IsToken(strTok,m_pLine))
m_pLine = _tcsdec(m_pStartLine,m_pLine);
return IsToken(strTok,m_pLine);
}
}
BOOL CTextParse::MoveUntilString(LPCTSTR str,BOOL bForward)
{
if (bForward)
{
while(*m_pLine && !IsString(str))
m_pLine = _tcsinc(m_pLine);
return *m_pLine != '\0';
}
else
{
while(m_pLine > m_pStartLine && !IsString(str))
m_pLine = _tcsdec(m_pStartLine,m_pLine);
return IsString(str);
}
}
BOOL CTextParse::MoveWhileChar(int c,BOOL bForward)
{
if (bForward)
{
while(*m_pLine && *m_pLine == c)
m_pLine = _tcsinc(m_pLine);
return *m_pLine != '\0';
}
else
{
while(m_pLine > m_pStartLine && *m_pLine == c)
m_pLine = _tcsdec(m_pStartLine,m_pLine);
return *m_pLine == c;
}
}
BOOL CTextParse::MoveWhileChar(LPCTSTR strTok,BOOL bForward)
{
if (bForward)
{
while(*m_pLine && IsToken(strTok,m_pLine))
m_pLine = _tcsinc(m_pLine);
return *m_pLine != '\0';
}
else
{
while(m_pLine > m_pStartLine && IsToken(strTok,m_pLine))
m_pLine = _tcsdec(m_pStartLine,m_pLine);
return IsToken(strTok,m_pLine);
}
}
LPCTSTR CTextParse::CopyWhileChar(int c)
{
for(int i=0;i < MAX_BUF && *m_pLine != '\0' && *m_pLine == c;i++)
{
m_szCopyBuf[i] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
LPCTSTR CTextParse::CopyUntilString(LPCTSTR pszText)
{
int nLen = _tcslen(pszText);
for(int i=0;i < MAX_BUF && *m_pLine != '\0' && _tcsncmp(m_pLine,pszText,nLen) != 0;i++)
{
m_szCopyBuf[i] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
LPCTSTR CTextParse::CopyUntilChar(int c)
{
for(int i=0;i < MAX_BUF && *m_pLine != '\0' && *m_pLine != c;i++)
{
m_szCopyBuf[i] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
LPCTSTR CTextParse::CopyWhileChar(LPCTSTR strTok)
{
for(int i=0;i < MAX_BUF && *m_pLine != '\0' && IsToken(strTok,m_pLine);i++)
{
m_szCopyBuf[i] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
LPCTSTR CTextParse::CopyUntilChar(LPCTSTR strTok)
{
for(int i=0;i < MAX_BUF && *m_pLine != '\0' && !IsToken(strTok,m_pLine);i++)
{
m_szCopyBuf[i] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
LPCTSTR CTextParse::CopyFuncUntilChar(LPCTSTR strTok)
{
for(int i=0;i < MAX_BUF && !IsEnd() && !IsToken(strTok,m_pLine);i++)
{
/* if (*m_pLine == '=') {
MoveUntilChar(",)");
if (m_szCopyBuf[i-1] == ' ') {
i--;
}
}*/
if (CharAtCurrent('/'))
{
MoveForward();
MoveUntilChar(_T("/"));
if (m_szCopyBuf[i-1] == ' ')
{
i--;
MoveForward();
}
}
m_szCopyBuf[i] = *m_pLine;
MoveForward();
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
BOOL CTextParse::IsToken(LPCTSTR strTok,LPCTSTR p)
{
while(*strTok)
{
if (*p == *strTok)
break;
strTok = _tcsinc(strTok);
}
return *strTok != '\0';
}
LPCTSTR CTextParse::ExtractConstructor()
{
MoveUntilChar('(');
CopyUntilChar(')');
_tcscat(m_szCopyBuf,_T(")"));
return m_szCopyBuf;
}
LPCTSTR CTextParse::ExtractDeclareMacro()
{
return CopyUntilChar('(');
}
LPCTSTR CTextParse::ExtractFuncName()
{
Reset();
// skip keywords
if (_tcsncmp(m_pLine,_T("const"),5) == 0 || _tcsncmp(m_pLine,_T("afx_msg"),7) == 0 || _tcsncmp(m_pLine,_T("virtual"),7) == 0)
{
CopyUntilWhiteSpace();
MoveWhileWhiteSpace();
}
MoveUntilChar(_T("("));
MoveUntilWhiteSpace(FALSE);
if (*m_pLine == CPP_SPACE) // regular function
MoveWhileWhiteSpace();
else
{ // else constructor or destructor
// allow for virtual destructors
if (_tcsncmp(m_pLine,_T("virtual"),7) == 0)
{
CopyUntilWhiteSpace();
MoveWhileWhiteSpace();
}
Reset();
}
// returning pointer or reference
if (*m_pLine == '*' || *m_pLine == '&')
m_pLine = _tcsinc(m_pLine);
return CopyUntilChar('(');
}
LPCTSTR CTextParse::ExtractClassName()
{
MoveWhileWhiteSpace();
if (_tcsncmp(m_pLine,_T("class"),5) != 0)
{
m_szCopyBuf[0] = 0;
return m_szCopyBuf;
}
Reset();
// check if derived class
if (!CharExistFromCurPos(':'))
{
if (!CharExistFromCurPos('{'))
{
MoveToLastChar();
MoveWhileWhiteSpace(FALSE);
MoveUntilWhiteSpace(FALSE);
MoveWhileWhiteSpace();
}
else
{
MoveUntilChar('{');
MoveUntilWhiteSpace(FALSE);
MoveWhileWhiteSpace(FALSE);
MoveUntilWhiteSpace(FALSE);
MoveWhileWhiteSpace();
}
}
else
{
MoveUntilChar(':');
// go back and skip colon
MoveUntilWhiteSpace(FALSE);
MoveWhileWhiteSpace(FALSE);
if (CharAtCurrent('>'))
{
MoveUntilChar('<',FALSE);
MoveUntilWhiteSpace(FALSE);
MoveWhileWhiteSpace(FALSE);
}
MoveUntilWhiteSpace(FALSE);
MoveWhileWhiteSpace();
}
return CopyUntilChar(_T(" \t<"));
}
LPCTSTR CTextParse::ExtractBaseClassName()
{
Reset();
MoveWhileWhiteSpace();
if (_tcsncmp(m_pLine,_T("class"),5) != 0)
{
m_szCopyBuf[0] = 0;
return m_szCopyBuf;
}
Reset();
// check if derived class
if (CharExistFromCurPos(':'))
{
MoveUntilChar(':');
// go back
MoveWhileChar(':');
MoveWhileWhiteSpace();
MoveUntilWhiteSpace();
MoveWhileWhiteSpace();
}
else
{
m_szCopyBuf[0] = 0;
return m_szCopyBuf;
}
return CopyUntilChar(_T(" \t<"));
}
BOOL CTextParse::IsCommentBlock(LPCTSTR strStart,LPCTSTR strEnd)
{
LPCTSTR p = _tcsstr(m_pLine,strStart);
if (p)
{
if (p == m_pStartLine && *(p+sizeof(TCHAR)*2) == '+')
return FALSE;
if (p == m_pStartLine || (p != m_pStartLine && *(p-sizeof(TCHAR)) != '/') )
{
if (_tcsstr(m_pLine,strEnd) == NULL)
return TRUE;
}
}
return FALSE;
}
LPCTSTR CTextParse::CopyWholeWord()
{
bool bQuote=false;
for(int i=0;i < MAX_BUF && *m_pLine != '\0';i++)
{
if (*m_pLine == '"')
{
bQuote = !bQuote;
}
else if (*m_pLine == ' ' && bQuote == false)
{
break;
}
m_szCopyBuf[i] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
SkipWhiteSpace();
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
LPCTSTR CTextParse::CopyUntilEnd()
{
for(int i=0;i < MAX_BUF && *m_pLine != '\0';i++)
{
m_szCopyBuf[i] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
bool CTextParse::FindWholeWord(LPCTSTR pszText)
{
bool bQuote = _tcsstr(pszText,_T("\"")) != NULL;
if (*pszText == '+' || *pszText == '-')
pszText = _tcsinc(pszText);
int nLen = _tcslen(pszText);
int nRet=-1;
for(int i=0;i < MAX_BUF && *m_pLine != '\0';i++)
{
SkipWhiteSpace();
if (*m_pLine == '"')
{
if (bQuote == true)
{
nRet = _tcsncmp(m_pLine,pszText,nLen);
if (nRet == 0)
break;
}
MoveWhileChar('"');
MoveUntilChar('"');
MoveWhileChar('"');
}
else
{
nRet = _tcsncmp(m_pLine,pszText,GetWordLen());
if (nRet == 0)
break;
SkipWord();
}
}
return nRet == 0;
}
int CTextParse::GetWordLen()
{
LPCTSTR p = m_pLine;
for (int i=0;*p && !IsToken(CPP_WHITE_SPACE,p);i++)
{
p++;
}
return i;
}
bool CTextParse::SkipHTMLCommand(bool bSkipCRLF)
{
if (CharAtCurrent('&'))
{
MoveUntilChar(';');
if (CharAtCurrent(';'))
MoveForward();
return true;
}
LPCTSTR p = m_pLine;
if (bSkipCRLF)
{
while (*p == '\r' || *p == '\n')
p = _tcsinc(p);
}
if (*p != '<')
return false;
while (*p != '>' && *p != '\0')
p = _tcsinc(p);
if (*p == '>')
p = _tcsinc(p);
m_pLine = p;
return true;
}
void CTextParse::SkipHTMLCommands(bool bSkipCRLF)
{
while (SkipHTMLCommand(bSkipCRLF))
;
}
BOOL CTextParse::IsValidCPP(LPCTSTR pszText)
{
BOOL bRet=FALSE;
if (FindString(pszText))
{
// check if a comment
SaveCurPos();
if (!MoveUntilString(_T("//"),FALSE))
{
RestorePos();
if (!MoveUntilString(_T("/*"),FALSE))
bRet = TRUE;
}
}
Reset();
return bRet;
}
BOOL CTextParse::IsPrivate()
{
return IsValidCPP(_T("private"));
}
BOOL CTextParse::IsPublic()
{
return IsValidCPP(_T("public"));
}
BOOL CTextParse::IsProtected()
{
return IsValidCPP(_T("protected"));
}
BOOL CTextParse::IsVirtualFunc()
{
return IsValidCPP(_T("virtual"));
}
BOOL CTextParse::IsStartBrace()
{
return IsValidCPP(_T("{"));
}
BOOL CTextParse::IsEndBrace()
{
return IsValidCPP(_T("}"));
}
BOOL CTextParse::IsAccessSpecifier()
{
return IsValidCPP(_T(":"));
}
BOOL CTextParse::IsConstructor(LPCTSTR pszClassName)
{
CString sTest(pszClassName);
sTest += _T("(");
if (FindChar('~'))
{
Reset();
return FALSE;
}
return IsValidCPP(sTest);
}
BOOL CTextParse::IsMsgMap()
{
return FindString(_T("{{AFX_MSG"));
}
BOOL CTextParse::IsDeclareMacro()
{
BOOL bRet = FALSE;
if (IsValidCPP(_T("DECLARE_")))
{
if (!FindString(_T("()")))
bRet = TRUE;
Reset();
}
return bRet;
}
BOOL CTextParse::IsStartCommentBlock()
{
if (!FindString(_T("//")))
return FindString(_T("/*"));
return FALSE;
}
BOOL CTextParse::IsEndCommentBlock()
{
return FindString(_T("*/"));
}
BOOL CTextParse::IsClass()
{
BOOL bRet=TRUE;
if (FindString(_T("template")))
{
bRet = FALSE;
}
if (!StringAtCurrent(_T("class ")))
{
bRet = FALSE;
}
Reset();
// any line comments before 'class '
MoveUntilString(_T("class "));
if (MoveUntilString(_T("//"),FALSE))
{
bRet = FALSE;
}
Reset();
if (FindChar(_T(';')))
{
bRet = FALSE;
}
if (FindChar(_T('#')))
{
bRet = FALSE;
}
Reset();
return bRet;
}
BOOL CTextParse::ExtractArgs(CString &sRet,CStringArray &asArgs)
{
asArgs.RemoveAll();
SaveCurPos();
if (!CharAtCurrent('(') && FindChar('('))
{
RestorePos();
SkipWhiteSpace();
if (StringAtCurrent(_T("const")))
{
MoveUntilWhiteSpace();
SkipWhiteSpace();
}
sRet = CopyUntilWhiteSpace();
if (MoveUntilChar('('))
{
MoveForward();
}
else
{
RestorePos();
}
}
while (!CharAtCurrent(')') && !IsEnd())
{
SkipWhiteSpace();
if (StringAtCurrent(_T("const")))
{
MoveUntilWhiteSpace();
SkipWhiteSpace();
}
MoveUntilWhiteSpace();
SkipWhiteSpace();
if (StringAtCurrent(_T("void")))
break;
if (CharAtCurrent('*') || CharAtCurrent('&'))
MoveForward();
asArgs.Add(CopyUntilChar(_T(",)\t ")));
if (CharAtCurrent(','))
MoveForward();
else
SkipWhiteSpace();
}
return TRUE;
}
LPCTSTR CTextParse::ExtractHTMLText(bool bRemoveCRLF)
{
return ExtractHTMLText(_T("<"),bRemoveCRLF);
}
LPCTSTR CTextParse::ExtractHTMLText(LPCTSTR pszUntil,bool bRemoveCRLF)
{
int nLen=_tcslen(pszUntil);
int i=0;
bool bEnd = false;
while(i < MAX_BUF && *m_pLine != '\0' && _tcsncmp(m_pLine,pszUntil,nLen) != 0)
{
if (*m_pLine == '<' || *m_pLine == '&')
{
while (SkipHTMLCommand(false))
{
if (_tcsncmp(m_pLine,pszUntil,nLen) == 0)
{
bEnd = true;
break;
}
}
}
if (bEnd)
break;
if (bRemoveCRLF && (*m_pLine == '\n' || *m_pLine == '\r'))
{
m_pLine = _tcsinc(m_pLine);
}
else
{
m_szCopyBuf[i++] = *m_pLine;
m_pLine = _tcsinc(m_pLine);
}
}
m_szCopyBuf[i] = '\0';
return m_szCopyBuf;
}
LPCTSTR CTextParse::ExtractHTMLLink()
{
m_szCopyBuf[0] = '\0';
if (!FindString(_T("href=")))
return m_szCopyBuf;
MoveUntilChar('"');
LPCTSTR p = m_pLine;
if (*p == '"')
{
p = _tcsinc(p);
m_pLine = p;
LPCTSTR pRet = CopyUntilChar('"');
MoveUntilChar('>');
MoveWhileChar('>');
return pRet;
}
return m_szCopyBuf;
}
@@ -1,223 +0,0 @@
// TextProgressCtrl.cpp : implementation file
//
// Written by Chris Maunder ([email protected])
// Copyright 1998.
//
// TextProgressCtrl is a drop-in replacement for the standard
// CProgressCtrl that displays text in a progress control.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this
// notice and the authors name is included. If the source code in
// this file is used in any commercial application then an email to
// the me would be nice.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
// computer or anything else vaguely within it's vicinity.
//
// Expect bugs.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this
// file.
// Modified by Philip Oldaker 2000
#include "stdafx.h"
#include "TextProgressCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CTextProgressCtrl,CUIODColumnCtrl)
/////////////////////////////////////////////////////////////////////////////
// CTextProgressCtrl
CTextProgressCtrl::CTextProgressCtrl()
{
m_nPos = 0;
m_nStepSize = 1;
m_nMax = 100;
m_nMin = 0;
m_bShowText = TRUE;
m_crBarClr = CLR_DEFAULT;
m_crBgClr = CLR_DEFAULT;
m_crTextClr = CLR_DEFAULT;
m_crSelBarClr = CLR_DEFAULT;
m_crSelBgClr = CLR_DEFAULT;
m_crSelTextClr = CLR_DEFAULT;
}
CTextProgressCtrl::~CTextProgressCtrl()
{
}
void CTextProgressCtrl::DoPaint(CDC *PaintDC,CRect rcClient,bool bSelected)
{
if (m_nMin >= m_nMax)
return;
bool bInvert=bSelected;
COLORREF crBarColour = (m_crBarClr == CLR_DEFAULT)? RGB(10,20,200) : m_crBarClr;
COLORREF crBgColour = (m_crBgClr == CLR_DEFAULT)? ::GetSysColor(COLOR_MENU) : m_crBgClr;
COLORREF crTextColor = (m_crTextClr == CLR_DEFAULT)? ::GetSysColor(COLOR_BTNTEXT) : m_crTextClr;
if (bSelected)
{
if (m_crSelBarClr != CLR_DEFAULT)
{
crBarColour = m_crSelBarClr;
bInvert = false;
}
if (m_crSelBgClr != CLR_DEFAULT)
{
crBgColour = m_crSelBgClr;
bInvert = false;
}
if (m_crSelTextClr != CLR_DEFAULT)
{
crTextColor = m_crSelTextClr;
bInvert = false;
}
}
double Fraction = (double)(m_nPos - m_nMin) / ((double)(m_nMax - m_nMin));
CDC &dc = *PaintDC;
dc.Rectangle(rcClient.left+1,rcClient.top+1,rcClient.right-1,rcClient.bottom-1);
rcClient.DeflateRect(2,2);
CRect LeftRect(rcClient);
CRect RightRect(rcClient);
LeftRect.right = LeftRect.left + (int)((LeftRect.right - LeftRect.left)*Fraction);
RightRect.left = LeftRect.right;
dc.FillSolidRect(LeftRect, crBarColour);
dc.FillSolidRect(RightRect, crBgColour);
// Draw Text if not vertical
if (m_bShowText)
{
CString str;
if (m_strText.GetLength())
str = m_strText;
else
str.Format(_T("%d%%"), (int)(Fraction*100.0));
CSize sz = dc.GetTextExtent(str);
int nTextPos = 0;
if (rcClient.Width() > sz.cx)
nTextPos = (rcClient.Width() - sz.cx) / 2;
if (!bSelected && LeftRect.Width() >= nTextPos)
{
dc.SetTextColor(RGB(255,255,255));
}
else
dc.SetTextColor(crTextColor);
dc.SetBkMode(TRANSPARENT);
DWORD dwTextStyle = DT_CENTER | DT_VCENTER | DT_SINGLELINE;
dc.DrawText(str, rcClient, dwTextStyle);
}
if (bInvert)
{
dc.InvertRect(rcClient);
}
}
/////////////////////////////////////////////////////////////////////////////
// CTextProgressCtrl operations
void CTextProgressCtrl::SetShowText(BOOL bShow)
{
m_bShowText = bShow;
}
void CTextProgressCtrl::SetRange(int nLower, int nUpper)
{
m_nMax = nUpper;
m_nMin = nLower;
}
void CTextProgressCtrl::GetRange(int& nLower, int& nUpper) const
{
nUpper = m_nMax;
nLower = m_nMin;
}
int CTextProgressCtrl::SetPos(int nPos)
{
int nOldPos = m_nPos;
m_nPos = nPos;
return nOldPos;
}
int CTextProgressCtrl::StepIt()
{
return SetPos(m_nPos + m_nStepSize);
}
int CTextProgressCtrl::OffsetPos(int nPos)
{
return SetPos(m_nPos + nPos);
}
int CTextProgressCtrl::SetStep(int nStep)
{
int nOldStep = m_nStepSize;
m_nStepSize = nStep;
return nOldStep;
}
COLORREF CTextProgressCtrl::SetBarColor(COLORREF crBarClr /*= CLR_DEFAULT*/,COLORREF crSelBarClr /*= CLR_DEFAULT*/)
{
COLORREF crOldBarClr = m_crBarClr;
m_crBarClr = crBarClr;
m_crSelBarClr = crSelBarClr;
return crOldBarClr;
}
COLORREF CTextProgressCtrl::GetBarColor() const
{
return m_crBarClr;
}
COLORREF CTextProgressCtrl::GetSelBarColor() const
{
return m_crSelBarClr;
}
COLORREF CTextProgressCtrl::SetBgColor(COLORREF crBgClr /*= CLR_DEFAULT*/,COLORREF crSelBgClr /*= CLR_DEFAULT*/)
{
COLORREF crOldBgClr = m_crBgClr;
m_crBgClr = crBgClr;
m_crSelBgClr = crSelBgClr;
return crOldBgClr;
}
COLORREF CTextProgressCtrl::GetBgColor() const
{
return m_crBgClr;
}
COLORREF CTextProgressCtrl::GetSelBgColor() const
{
return m_crSelBgClr;
}
COLORREF CTextProgressCtrl::SetTextColor(COLORREF crTextClr /*= CLR_DEFAULT*/,COLORREF crSelTextClr /*= CLR_DEFAULT*/)
{
COLORREF crOldTextClr = m_crTextClr;
m_crTextClr = crTextClr;
m_crSelTextClr = crSelTextClr;
return crOldTextClr;
}
COLORREF CTextProgressCtrl::GetTextColor() const
{
return m_crTextClr;
}
COLORREF CTextProgressCtrl::GetSelTextColor() const
{
return m_crSelTextClr;
}
@@ -1,368 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "UIFrameWnd.h"
#include "UIApp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUIApp
IMPLEMENT_DYNAMIC(CUIApp,CWinApp)
BEGIN_MESSAGE_MAP(CUIApp, CWinApp)
//{{AFX_MSG_MAP(CUIApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUIApp construction
CUIApp::CUIApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
m_IDMyIcon = 0;
m_bMyClassRegistered = false;
}
CDocTemplate *CUIApp::GetFirstDocTemplate()
{
POSITION posTempl = GetFirstDocTemplatePosition();
CDocTemplate *pTempl = GetNextDocTemplate(posTempl);
ASSERT(pTempl);
return pTempl;
}
CFrameWnd *CUIApp::GetMainFrame(CWnd *pWnd)
{
if (pWnd)
return pWnd->GetParentFrame();
return (CFrameWnd*)m_pMainWnd;
}
CString CUIApp::GetRegAppKey()
{
CString sKey;
sKey += _T("Software");
sKey += _T("\\");
sKey += m_pszRegistryKey;
sKey += _T("\\");
sKey += m_pszProfileName;
sKey += _T("\\");
return sKey;
}
BOOL CUIApp::InitInstance()
{
if (!m_sMyClassName.IsEmpty() && !RegisterMyClass())
return FALSE;
return CWinApp::InitInstance();
}
int CUIApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
if(m_bMyClassRegistered)
::UnregisterClass(m_sMyClassName,AfxGetInstanceHandle());
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CUIApp object
bool CUIApp::RegisterMyClass()
{
// Register our unique class name so only one instance can be started
//////////////////////////////////////////////////////////////
ASSERT(!m_sMyClassName.IsEmpty());
if (m_sMyClassName.IsEmpty())
return false;
//////////////////////////////////////////////////////////////
WNDCLASSEX wndcls;
memset(&wndcls, 0, sizeof(WNDCLASSEX));
wndcls.cbSize = sizeof(WNDCLASSEX);
wndcls.style = CS_DBLCLKS;// | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.hInstance = AfxGetInstanceHandle();
if (m_IDMyIcon)
{
wndcls.hIcon = LoadIcon(m_IDMyIcon);
wndcls.hIconSm = (HICON)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(m_IDMyIcon),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0);
if (wndcls.hIconSm == NULL)
{
ErrorMessage(_T("LoadImage failed"));
}
}
wndcls.hCursor = LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = NULL; //(HBRUSH) (COLOR_WINDOW + 1);
wndcls.lpszMenuName = NULL;
// Specify our own class name for using FindWindow later to set focus to running app
wndcls.lpszClassName = m_sMyClassName;
WNDCLASSEX wndclsEx;
if (GetClassInfoEx(wndcls.hInstance, wndcls.lpszClassName, &wndclsEx))
{
// class already registered
return true;
}
// Register new class and exit if it fails
if(!::RegisterClassEx(&wndcls))
{
ErrorMessage(_T("Class Registration Failed"));
return false;
}
else
TRACE(_T("Window class %s was registered in CUIApp\n"),GetMyClass());
m_bMyClassRegistered = true;
return true;
}
BOOL CUIApp::FirstInstance()
{
ASSERT(!m_sMyClassName.IsEmpty());
if (m_sMyClassName.IsEmpty())
return TRUE;
CWnd *pWndPrev, *pWndChild;
// Determine if another window with our class name exists...
if (pWndPrev = CWnd::FindWindow(m_sMyClassName,NULL))
{
// if so, does it have any popups?
pWndChild = pWndPrev->GetLastActivePopup();
// If iconic, restore the main window
if (pWndPrev->IsIconic())
pWndPrev->ShowWindow(SW_RESTORE);
// Bring the main window or its popup to
// the foreground
pWndChild->SetForegroundWindow();
// and we are done activating the previous one.
return FALSE;
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CUIApp initialization
void CUIApp::SetStatusBarText(UINT nPaneID,LPCTSTR Text,UINT nIconID)
{
if (m_pMainWnd == NULL)
{
TRACE1("Warning: '%s' SetStatusBarText called before main frame created!\n",Text);
return;
}
CUIFrameWnd *pMainFrame = (CUIFrameWnd*)m_pMainWnd;
if (nIconID)
pMainFrame->GetStatusBar().AddIcon(nPaneID,nIconID,false);
pMainFrame->GetStatusBar().SetText(nPaneID,Text,true);
}
void CUIApp::SetStatusBarText(LPCTSTR Text)
{
SetStatusBarText(0,Text);
}
void CUIApp::SetStatusBarText(UINT nPaneID,LPCTSTR Text,CView *pView,UINT nIconID)
{
if (m_pMainWnd == NULL)
return;
if (((CFrameWnd*)m_pMainWnd)->GetActiveView() == pView)
SetStatusBarText(nPaneID,Text,nIconID);
}
void CUIApp::SetStatusBarText(UINT nPaneID,UINT nResID,UINT nIconID)
{
CString str;
str.LoadString(nResID);
SetStatusBarText(nPaneID,str,nIconID);
}
void CUIApp::SetStatusBarIcon(UINT nPaneID,UINT nIconID,bool bAdd)
{
if (m_pMainWnd == NULL)
return;
CUIFrameWnd *pMainFrame = (CUIFrameWnd*)m_pMainWnd;
if (bAdd)
pMainFrame->GetStatusBar().AddIcon(nPaneID,nIconID);
else
pMainFrame->GetStatusBar().RemoveIcon(nPaneID,nIconID);
pMainFrame->GetStatusBar().RedrawWindow();
}
void CUIApp::SetStatusBarIdleMessage()
{
if (m_pMainWnd == NULL)
return;
CUIFrameWnd *pMainFrame = (CUIFrameWnd*)m_pMainWnd;
pMainFrame->GetStatusBar().RemoveAllIcons(0);
SetStatusBarText(0,AFX_IDS_IDLEMESSAGE);
}
CDocument *CUIApp::GetDocument()
{
CDocTemplate *pTempl = GetFirstDocTemplate();
POSITION posDoc = pTempl->GetFirstDocPosition();
CDocument *pDoc = pTempl->GetNextDoc(posDoc);
ASSERT(pDoc);
return pDoc;
}
CView *CUIApp::GetView(CRuntimeClass *pClass)
{
CDocTemplate *pTemplate = GetFirstDocTemplate();
POSITION posDoc = pTemplate->GetFirstDocPosition();
while (posDoc)
{
CDocument *pDoc = pTemplate->GetNextDoc(posDoc);
POSITION posView = pDoc->GetFirstViewPosition();
while (posView)
{
CView *pView = pDoc->GetNextView(posView);
if (pView && pView->IsKindOf(pClass))
return pView;
}
}
return NULL;
}
void CUIApp::ChangeProfile(LPCTSTR szRegistryKey,LPCTSTR szProfileName)
{
m_strOldProfileName = m_pszProfileName;
m_strOldRegistryKey = m_pszRegistryKey;
free((void*)m_pszRegistryKey);
m_pszRegistryKey = _tcsdup(szRegistryKey);
free((void*)m_pszProfileName);
m_pszProfileName = _tcsdup(szProfileName);
}
void CUIApp::RestoreProfile()
{
if (!m_strOldProfileName.IsEmpty())
{
free((void*)m_pszProfileName);
m_pszProfileName = _tcsdup(m_strOldProfileName);
}
if (!m_strOldRegistryKey.IsEmpty())
{
free((void*)m_pszRegistryKey);
m_pszRegistryKey = _tcsdup(m_strOldRegistryKey);
}
}
/////////////////////////////////////////////////////////////////////////////
// CAppReg
// Tricks MFC into using another application key
// useful if in HKEY_CURRENT_USER
CAppReg::CAppReg(CWinApp *pApp,LPCTSTR szRegistryKey,LPCTSTR szProfileName)
{
ASSERT(pApp);
m_pApp = (CUIApp*)pApp;
m_pApp->ChangeProfile(szRegistryKey,szProfileName);
}
CAppReg::~CAppReg()
{
ASSERT(m_pApp);
m_pApp->RestoreProfile();
}
//static
bool CUIApp::COMMessage(HRESULT hr,UINT nID)
{
CString sMess;
sMess.LoadString(nID);
return COMMessage(hr,sMess);
}
bool CUIApp::COMMessage(HRESULT hr,LPCTSTR szText)
{
if (FAILED(hr))
{
ErrorMessage(szText,(DWORD)hr);
return false;
}
return true;
}
void CUIApp::ErrorMessage(UINT nID,DWORD dwError)
{
CString sMess;
sMess.LoadString(nID);
ErrorMessage(sMess);
}
void CUIApp::ErrorMessage(LPCTSTR szText,DWORD dwError)
{
bool bError=true;
if (dwError == 0)
{
dwError = GetLastError();
bError = true;
}
else
{
bError = FAILED(dwError);
}
LPVOID lpMsgBuf=NULL;
if (bError)
{
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
}
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
CString sMess;
if (lpMsgBuf)
{
sMess = (LPCTSTR)lpMsgBuf;
sMess += _T("\n");
LocalFree( lpMsgBuf );
}
if (szText)
{
sMess += szText;
}
AfxMessageBox(sMess, MB_ICONSTOP );
}
@@ -1,77 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "UIData.h"
#include "UICont.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListObList
IMPLEMENT_SERIAL(CUIObjList, CObList, 0)
CUIObjList::CUIObjList()
{
}
CUIObjList::~CUIObjList()
{
DeleteAll();
}
/////////////////////////////////////////////////////////////////////////////
// CListObList commands
// Delete al objects in the list
void CUIObjList::DeleteAll()
{
while(!IsEmpty())
{
CUIListCtrlData* ptr = RemoveHead();
if (ptr->GetAutoDelete())
{
CObject *p =(CObject*)ptr->GetExtData();
ASSERT_KINDOF(CObject,p);
delete p;
}
delete ptr;
}
}
// Add a new object to the end of the list
void CUIObjList::Append(CUIListCtrlData* pListObj)
{
ASSERT(pListObj);
ASSERT(pListObj->IsKindOf(RUNTIME_CLASS(CUIListCtrlData)));
POSITION pos = CObList::AddTail(pListObj);
}
// Remove an object from the list but don't delete it
BOOL CUIObjList::Remove(CUIListCtrlData* pListObj)
{
POSITION pos = Find(pListObj);
if (!pos)
return FALSE;
RemoveAt(pos);
return TRUE;
}
@@ -1,237 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// CCoolBar implements coolbars for MFC.
//
#include "StdAfx.h"
#include "UICoolBar.h"
#include "UIModulVer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// if you want to see extra TRACE diagnostics, set below to TRUE
BOOL CCoolBar::bTRACE = FALSE;
#ifdef _DEBUG
#define CBTRACEFN \
CTraceFn __fooble; \
if (bTRACE) \
TRACE
#define CBTRACE \
if (bTRACE) \
TRACE
#else
#define CBTRACEFN TRACE
#define CBTRACE TRACE
#endif
IMPLEMENT_DYNAMIC(CCoolBar, CControlBar)
BEGIN_MESSAGE_MAP(CCoolBar, CControlBar)
//{{AFX_MSG_MAP(CCoolBar)
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_NOTIFY_REFLECT(RBN_HEIGHTCHANGE, OnHeightChange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CCoolBar::CCoolBar()
{
}
CCoolBar::~CCoolBar()
{
}
//////////////////
// Create coolbar
//
BOOL CCoolBar::Create(CWnd* pParentWnd, DWORD dwStyle,
DWORD dwAfxBarStyle, UINT nID)
{
ASSERT_VALID(pParentWnd); // must have a parent
// dynamic coolbar not supported
dwStyle &= ~CBRS_SIZE_DYNAMIC;
// save the style (this code copied from MFC--probably unecessary)
m_dwStyle = dwAfxBarStyle;
if (nID == AFX_IDW_TOOLBAR)
m_dwStyle |= CBRS_HIDE_INPLACE;
// MFC requires these:
dwStyle |= CCS_NODIVIDER|CCS_NOPARENTALIGN;
// initialize cool common controls
static BOOL bInit = FALSE;
if (!bInit) {
HMODULE h = ::GetModuleHandle(_T("ComCtl32"));
ASSERT(h);
typedef BOOL (CALLBACK* INITCC)(INITCOMMONCONTROLSEX*);
INITCC pfn = (INITCC)GetProcAddress(h, "InitCommonControlsEx");
if (pfn) {
INITCOMMONCONTROLSEX sex;
sex.dwSize = sizeof(INITCOMMONCONTROLSEX);
sex.dwICC = ICC_COOL_CLASSES;
(*pfn)(&sex);
}
bInit = TRUE;
}
// Finally create the cool bar using given style and parent.
CRect rc;
rc.SetRectEmpty();
return CWnd::CreateEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL,
dwStyle, rc, pParentWnd, nID);
}
//////////////////
// Invalidate coolbar: invalidate children too
//
void CCoolBar::Invalidate(BOOL bErase)
{
HWND hWndChild = ::GetWindow(m_hWnd, GW_CHILD);
while (hWndChild != NULL) {
::InvalidateRect(hWndChild, NULL, bErase);
hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT);
}
CControlBar::Invalidate(bErase);
}
//////////////////
// Set the background bitmap. This sets the background for all bands and
// sets the RBBS_FIXEDBMP style so it looks like one background.
//
void CCoolBar::SetBackgroundBitmap(CBitmap* pBitmap)
{
HBITMAP hbm = (HBITMAP)pBitmap->GetSafeHandle();
CRebarBandInfo rbbi;
int n = GetBandCount();
for (int i=0; i< n; i++) {
rbbi.fMask = RBBIM_STYLE;
GetBandInfo(i, &rbbi);
rbbi.fMask |= RBBIM_BACKGROUND;
rbbi.fStyle |= RBBS_FIXEDBMP;
rbbi.hbmBack = hbm;
SetBandInfo(i, &rbbi);
}
}
//////////////////
// Set background/foreground colors for all bands
//
void CCoolBar::SetColors(COLORREF clrFG, COLORREF clrBG)
{
CRebarBandInfo rbbi;
rbbi.fMask = RBBIM_COLORS;
rbbi.clrFore = clrFG;
rbbi.clrBack = clrBG;
int n = GetBandCount();
for (int i=0; i< n; i++)
SetBandInfo(i, &rbbi);
}
//////////////////
// Insert band. This overloaded version lets you create a child window band.
//
BOOL CCoolBar::InsertBand(CWnd* pWnd, CSize szMin, int cx,
LPCTSTR lpText, int iPos, BOOL bNewRow)
{
CRebarBandInfo rbbi;
rbbi.fMask = RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_TEXT;
if (cx>0) {
rbbi.fMask |= RBBIM_SIZE;
rbbi.cx = cx;
}
if (bNewRow) {
rbbi.fMask |= RBBIM_STYLE;
rbbi.fStyle |= RBBS_BREAK;
}
rbbi.hwndChild = pWnd->GetSafeHwnd();
rbbi.cxMinChild = szMin.cx;
rbbi.cyMinChild = szMin.cy;
rbbi.lpText = (LPTSTR)lpText;
return InsertBand(iPos, &rbbi);
}
//////////////////
// Handle WM_CREATE: call virtual fn so derived class can create bands.
//
int CCoolBar::OnCreate(LPCREATESTRUCT lpcs)
{
return (CControlBar::OnCreate(lpcs)==-1 || !OnCreateBands()) ? -1 : 0;
}
//////////////////
// Standard UI handler updates any controls in the coolbar.
//
void CCoolBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
{
UpdateDialogControls(pTarget, bDisableIfNoHndler);
}
/////////////////
// These two functions are called by MFC to calculate the layout of
// the main frame. Since CCoolBar is not designed to be dynamic, the
// size is always fixed, and the same as the window size.
//
CSize CCoolBar::CalcDynamicLayout(int nLength, DWORD dwMode)
{
return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZ);
}
CSize CCoolBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
CRect rc;
GetWindowRect(&rc);
CSize sz(bHorz && bStretch ? 0x7FFF : rc.Width(),
!bHorz && bStretch ? 0x7FFF : rc.Height());
return sz;
}
//////////////////
// Handle RBN_HEIGHTCHANGE notification: pass to virtual fn w/nicer args.
//
void CCoolBar::OnHeightChange(NMHDR* pNMHDR, LRESULT* pRes)
{
CRect rc;
GetWindowRect(&rc);
OnHeightChange(rc);
*pRes = 0; // why not?
}
//////////////////
// Height changed: Default implementation does the right thing for MFC
// doc/view: notify parent frame by posting a WM_SIZE message. This will
// cause the frame to do RecalcLayout. The message must be posted, not sent,
// because the coolbar could send RBN_HEIGHTCHANGE while the user is sizing,
// which would be in the middle of a CFrame::RecalcLayout, and RecalcLayout
// doesn't let you re-enter it. Posting guarantees that CFrameWnd can finish
// any recalc it may be in the middle of *before* handling my posted WM_SIZE.
// Very confusing, but that's MFC for you.
//
void CCoolBar::OnHeightChange(const CRect& rcNew)
{
CWnd* pParent = GetParent();
CRect rc;
pParent->GetWindowRect(&rc);
pParent->PostMessage(WM_SIZE, 0, MAKELONG(rc.Width(),rc.Height()));
}
void CCoolBar::OnPaint()
{
Default(); // bypass CControlBar
}
BOOL CCoolBar::OnEraseBkgnd(CDC* pDC)
{
return (BOOL)Default(); // bypass CControlBar
}
File diff suppressed because it is too large Load Diff
@@ -1,202 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
/**********************************************************/
/* implementation of class CUIListCtrlData */
/* */
/**********************************************************/
#include "stdafx.h"
#include "UIData.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIconObj
IMPLEMENT_DYNAMIC(CUIODColumnCtrl, CObject)
IMPLEMENT_DYNAMIC(CUIListCtrlData, CObject)
IMPLEMENT_DYNAMIC(CUIDBListCtrlData, CUIListCtrlData)
IMPLEMENT_DYNAMIC(CUIStrListCtrlData, CUIListCtrlData)
IMPLEMENT_DYNAMIC(CUIComboBoxData, CUIListCtrlData)
/////////////////////////////////////////////////////////////////////////////
// CUIListCtrlData construction/destruction
CUIListCtrlData::CUIListCtrlData(int nCols)
{
Init(nCols);
}
void CUIListCtrlData::Init(int nCols)
{
const int cMaxCols=50;
m_arCtrl.SetSize(nCols < cMaxCols ? cMaxCols : nCols);
m_arFonts.SetSize(nCols < cMaxCols ? cMaxCols : nCols);
m_arTextColors.SetSize(nCols < cMaxCols ? cMaxCols : nCols);
m_arBkColors.SetSize(nCols);
for(int i=0;i < nCols;i++)
{
SetDefaultTextColor(i);
SetDefaultBkColor(i);
}
m_dwExtData = 0;
m_bAutoDelete = false;
m_bDeleted = false;
}
CUIListCtrlData::~CUIListCtrlData()
{
DestroyCtrls();
DestroyFonts();
}
void CUIListCtrlData::DestroyFonts()
{
CFont *pFont=NULL;
for(int i=0;i < m_arFonts.GetSize();i++)
{
pFont = (CFont*)m_arFonts[i];
delete pFont;
}
}
void CUIListCtrlData::DestroyCtrls()
{
CUIODColumnCtrl *pCtrl=NULL;
for(int i=0;i < m_arCtrl.GetSize();i++)
{
pCtrl = (CUIODColumnCtrl*)m_arCtrl[i];
delete pCtrl;
}
}
BOOL CUIListCtrlData::IsFontSet(int nCol) const
{
if (nCol == -1)
{
BOOL bRet=TRUE;
for(int i=0;i < m_arFonts.GetSize();i++)
{
if (m_arFonts[i] == NULL)
{
bRet = FALSE;
break;
}
}
return bRet;
}
return(m_arFonts[nCol] && ((CFont*)m_arFonts[nCol])->GetSafeHandle() != NULL);
}
void CUIListCtrlData::SetFont(CFont *pFont,int nCol)
{
LOGFONT lf;
pFont->GetLogFont(&lf);
if (nCol == -1)
{
for(int i=0;i < m_arFonts.GetSize();i++)
{
CreateNewFont(i,lf);
}
}
else
{
CreateNewFont(nCol,lf);
}
}
void CUIListCtrlData::CreateNewFont(int nCol,LOGFONT &lf)
{
CFont *pNewFont = NULL;
CFont *pOldFont = (CFont*)m_arFonts[nCol];
if (pOldFont)
{
if (pOldFont->GetSafeHandle())
pOldFont->DeleteObject();
pNewFont = pOldFont;
}
else
pNewFont = new CFont;
pNewFont->CreateFontIndirect(&lf);
m_arFonts[nCol] = pNewFont;
}
/////////////////////////////////////////////////////////////////////////////
//
// CUIComboBoxData
//
/////////////////////////////////////////////////////////////////////////////
// columns in a combo box
CString CUIComboBoxData::GetText(int nCol) const
{
TCHAR szDest[256];
if (nCol == -1 || m_strText.IsEmpty())
return m_strText;
LPCTSTR p = m_strText;
LPTSTR pDest;
nCol++;
while (nCol > 0)
{
pDest = szDest;
while (*p && *p != _T('\t'))
{
*pDest = *p;
pDest = _tcsinc(pDest);
p = _tcsinc(p);
}
nCol--;
if (*p == _T('\t'))
p = _tcsinc(p);
else
break;
}
*pDest = '\0';
CString str;
if (nCol)
str.Empty();
else
str = szDest;
return str;
}
/////////////////////////////////////////////////////////////////////////////
// CUIStrListCtrlData
/////////////////////////////////////////////////////////////////////////////
CUIStrListCtrlData::CUIStrListCtrlData(int nColumns) : CUIListCtrlData(nColumns)
{
m_StringArray.SetSize(nColumns);
}
LPTSTR CUIStrListCtrlData::GetString(int nCol)
{
return (LPTSTR)(LPCTSTR)m_StringArray[nCol];
}
// return TRUE if needs updating
BOOL CUIStrListCtrlData::AddString(int nCol,LPCTSTR szStr)
{
if (nCol < 0)
return FALSE;
BOOL ret = !m_StringArray[nCol].IsEmpty();
m_StringArray[nCol] = szStr;
return ret;
}
/////////////////////////////////////////////////////////////////////////////
@@ -1,610 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
//////////////////////////////////////////////////////////////////////////////////////--*/
// UIDragDropTree.cpp : implementation file
//
#include "stdafx.h"
#include "UICtrl.h"
#include "UIDragDropTree.h"
#include "cbformats.h"
#include "UIRes.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CUIDragDropTree,CTreeCtrl)
/////////////////////////////////////////////////
//
// For OLE drag and drop
//
/////////////////////////////////////////////////
void CUI_TreeDropTarget::OnDragLeave(CWnd* pWnd)
{
CUIDragDropTree *pTree = static_cast<CUIDragDropTree*>(pWnd);
if (pTree == NULL)
return;
pTree->KillDragTimer();
pTree->SelectDropTarget(NULL);
CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd());
Info.SetItem(pTree->GetDropHilightItem());
BOOL bRet = pTree->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info);
if (bRet == FALSE)
bRet = pTree->GetParent()->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info);
}
DROPEFFECT CUI_TreeDropTarget::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
{
// ASSERT_KINDOF(CUIDragDropTree,pWnd);
CUIDragDropTree *pTree = static_cast<CUIDragDropTree*>(pWnd);
if (pTree == NULL)
return DROPEFFECT_NONE;
((CUIDragDropTree*)pWnd)->SetDragTimer();
CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
m_dwEnterKeyboardState = dwKeyState;
Info.SetKeyboardState(dwKeyState);
Info.SetItem(pTree->GetDropHilightItem());
BOOL bRet = pTree->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
if (bRet == FALSE)
bRet = pTree->GetParent()->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
return Info.GetDropEffect();
}
DROPEFFECT CUI_TreeDropTarget::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
{
// disallow if the control key pressed
EraseOldImage();
CUIDragDropTree *pTree = static_cast<CUIDragDropTree*>(pWnd);
if (pTree == NULL)
return DROPEFFECT_NONE;
// ASSERT_KINDOF(CUIDragDropTree,pWnd);
CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
m_dwKeyboardState = dwKeyState;
Info.SetKeyboardState(dwKeyState);
// WM_APP_OLE_DD_OVER message sent in SelectCurrentTarget
DROPEFFECT dropEffect = pTree->SelectCurrentTarget(&Info);
CUI_ImageDropTarget::OnDragOver(pWnd,pDataObject,dwKeyState,point);
return dropEffect;
}
BOOL CUI_TreeDropTarget::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
{
CUIDragDropTree *pTree = static_cast<CUIDragDropTree*>(pWnd);
if (pTree == NULL)
return FALSE;
// ASSERT_KINDOF(CUIDragDropTree,pWnd);
pTree->KillDragTimer();
HTREEITEM hItem = pTree->GetDropHilightItem();
BOOL bRet=FALSE;
if (hItem)
{
CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
Info.SetDropEffect(dropEffect);
Info.SetItem(hItem);
if (m_dwEnterKeyboardState & MK_RBUTTON)
m_dwKeyboardState |= MK_RBUTTON;
if (m_dwEnterKeyboardState & MK_LBUTTON)
m_dwKeyboardState |= MK_LBUTTON;
Info.SetKeyboardState(m_dwKeyboardState);
bRet = pTree->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
if (bRet == FALSE)
bRet = pTree->GetParent()->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
}
pTree->SelectDropTarget(NULL);
return bRet;
}
// During slow scroll, process every third message.
#define SLOWSCROLL_FREQUENCY 3
/////////////////////////////////////////////////////////////////////////////
// CUIDragDropTree
CUIDragDropTree::CUIDragDropTree(bool bDragDrop): m_nUpperYCoor(0),
m_nLowerYCoor(0),
m_nSlowScrollTimeout(0),
m_nTimerID(0),
m_bDragging(FALSE),
m_pImageList(NULL),
m_hitemDrag(NULL),
m_hitemDrop(NULL),
m_bDragDrop(bDragDrop),
m_bDropFiles(true)
{
m_nScrollBarSize = GetSystemMetrics( SM_CYHSCROLL );
m_CopyMode = eDDCancel;
}
CUIDragDropTree::~CUIDragDropTree()
{
}
void CUIDragDropTree::OnDropFile(HTREEITEM hItem,LPCTSTR pszFile,UINT nFlags)
{
}
BEGIN_MESSAGE_MAP(CUIDragDropTree, CTreeCtrl)
//{{AFX_MSG_MAP(CUIDragDropTree)
ON_NOTIFY_REFLECT_EX(TVN_BEGINDRAG, OnBegindrag)
ON_NOTIFY_REFLECT_EX(TVN_BEGINRDRAG, OnBeginRDrag)
ON_WM_TIMER()
ON_WM_RBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_DESTROY()
ON_WM_CREATE()
ON_WM_DROPFILES()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUIDragDropTree message handlers
void CUIDragDropTree::OnDropFiles(HDROP hDropInfo)
{
UINT wNumFilesDropped = DragQueryFile(hDropInfo, 0XFFFFFFFF, NULL, 0);
TCHAR szFile[MAX_PATH];
UINT nLen;
UINT nFlags;
POINT pt;
::DragQueryPoint(hDropInfo,&pt);
HTREEITEM hitemDrag = HitTest(CPoint(pt), &nFlags);
for(UINT i=0; i < wNumFilesDropped;i++)
{
nLen = DragQueryFile(hDropInfo,i,szFile,sizeof(szFile)/sizeof(TCHAR));
if (nLen)
OnDropFile(hitemDrag,szFile,nFlags);
}
}
BOOL CUIDragDropTree::OnBeginRDrag(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
return StartDragDrop(pNMTreeView);
}
BOOL CUIDragDropTree::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
return StartDragDrop(pNMTreeView);
}
BOOL CUIDragDropTree::StartDragDrop(NM_TREEVIEW* pNMTreeView)
{
if (GetDragDrop() == false || pNMTreeView->itemNew.hItem == GetRootItem())
return FALSE;
// See if COM drag drop is implemented in this window or parent window
DWORD dwDragEffect = SendMessage(WM_APP_OLE_DD_DODRAGDROP,(WPARAM)pNMTreeView,(LPARAM)&m_OleDataSource);
if (dwDragEffect == 0)
dwDragEffect = GetParent()->SendMessage(WM_APP_OLE_DD_DODRAGDROP,(WPARAM)pNMTreeView,(LPARAM)&m_OleDataSource);
if (dwDragEffect)
{
CRect rcDrag;
m_hitemDrag = pNMTreeView->itemNew.hItem;
// Define starting rect
GetItemRect(pNMTreeView->itemNew.hItem,rcDrag,TRUE);
// Start the DragDrop
DWORD dwEffect = m_OleDataSource.DoDragDrop(dwDragEffect,rcDrag);
// Clear the cache
m_OleDataSource.Empty();
}
else // otherwise start local drag drop
{
CPoint ptAction;
UINT nFlags;
GetCursorPos(&ptAction);
ScreenToClient(&ptAction);
m_bDragging = TRUE;
m_hitemDrag = HitTest(pNMTreeView->ptDrag, &nFlags);
m_hitemDrop = NULL;
// Create drag image and begin dragging
m_pImageList = CreateDragImage(m_hitemDrag);
m_pImageList->BeginDrag(0, CPoint(0,0));
m_pImageList->DragEnter(GetDesktopWindow(), ptAction);
SetCapture();
SetDragTimer();
}
return TRUE;
}
void CUIDragDropTree::SetDragTimer()
{
// Set the timer to slow down the scrolling when the dragging cursor
// is close to the top/bottom border of the tree control
if (!m_nTimerID)
{
m_nTimerID = SetTimer(1, 75, NULL);
CRect rect;
GetClientRect(&rect);
ClientToScreen(&rect);
m_nUpperYCoor = rect.top;
m_nLowerYCoor = rect.bottom;
}
}
void CUIDragDropTree::KillDragTimer()
{
if (m_nTimerID)
{
KillTimer(m_nTimerID);
}
m_nTimerID = 0;
m_nUpperYCoor = 0;
m_nLowerYCoor = 0;
m_nSlowScrollTimeout = 0;
}
void CUIDragDropTree::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if (nIDEvent != m_nTimerID)
{
CTreeCtrl::OnTimer(nIDEvent);
return;
}
// Get the "current" mouse position
const MSG* pMessage;
CPoint ptMouse;
pMessage = GetCurrentMessage();
ASSERT(pMessage);
ptMouse = pMessage->pt;
// Move the ghost image
if (m_pImageList)
m_pImageList->DragMove(ptMouse);
// Find out if scrolling is needed.
// Scrolling is not needed for example, if the dragging cursor is
// within the tree control itself
if(!NeedToScroll(ptMouse))
{
CTreeCtrl::OnTimer(nIDEvent);
return;
}
if (!m_bDragging)
m_OleDropTarget.EraseOldImage();
// Refine the scrolling mode -
// Scroll Up/Down, Slow/Normal
int nScrollMode = RefineScrollMode(ptMouse);
switch(nScrollMode)
{
case SCROLL_UP_SLOW:
case SCROLL_DOWN_SLOW:
if( m_nSlowScrollTimeout == 0)
SendMessage( WM_VSCROLL,
nScrollMode == SCROLL_UP_SLOW ? SB_LINEUP : SB_LINEDOWN);
m_nSlowScrollTimeout = ++m_nSlowScrollTimeout%SLOWSCROLL_FREQUENCY;
break;
case SCROLL_UP_NORMAL:
case SCROLL_DOWN_NORMAL:
SendMessage( WM_VSCROLL,
nScrollMode == SCROLL_UP_NORMAL ? SB_LINEUP : SB_LINEDOWN);
break;
default:
ASSERT(FALSE);
return;
break;
}
if (m_bDragging)
{
// Select the drop target
if (m_pImageList)
m_pImageList->DragLeave(this);
HTREEITEM hitem = GetFirstVisibleItem();
switch( nScrollMode )
{
case SCROLL_UP_SLOW:
case SCROLL_UP_NORMAL:
{
SelectDropTarget(hitem);
m_hitemDrop = hitem;
break;
}
case SCROLL_DOWN_SLOW:
case SCROLL_DOWN_NORMAL:
{
// Get the last visible item in the control
int nCount = GetVisibleCount();
for ( int i=0; i<nCount-1; ++i )
hitem = GetNextVisibleItem(hitem);
SelectDropTarget(hitem);
m_hitemDrop = hitem;
break;
}
default:
ASSERT(FALSE);
return;
break;
}
if (m_pImageList)
m_pImageList->DragEnter(this, ptMouse); CTreeCtrl::OnTimer(nIDEvent);
}
}
void CUIDragDropTree::OnRButtonUp(UINT nFlags, CPoint point)
{
if (!m_bDragging)
return;
// Kill the timer and reset all variables
EndDragging();
CMenu menu;
VERIFY(menu.LoadMenu(IDR_POPUPMENU_DRAGDROP));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->SetDefaultItem(ID_POPUP_DD_MOVE);
CPoint pts(point);
ClientToScreen(&pts);
if (GetRDragMenu(pPopup))
{
UINT nCmd = pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD, pts.x, pts.y,this);
if (nCmd == ID_POPUP_DD_MOVE)
{
OnButtonUp(true);
}
else if (nCmd == ID_POPUP_DD_COPY)
{
OnButtonUp(false);
}
}
else
{
// otherwise just move
OnButtonUp(true);
}
SelectDropTarget(NULL);
CTreeCtrl::OnRButtonUp(nFlags, point);
}
void CUIDragDropTree::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
HTREEITEM hItem;
UINT flags;
if (!m_bDragging)
return;
CPoint ptScreen(point);
ClientToScreen(&ptScreen);
m_pImageList->DragMove(ptScreen);
m_pImageList->DragShowNolock(FALSE);
if ((hItem = HitTest(point, &flags)) != NULL)
{
CDD_OleDropTargetInfo Info(this->GetSafeHwnd(),point,NULL);
Info.SetItem(hItem);
LRESULT lResult = SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)&Info);
if (lResult == 0)
{
lResult = GetParent()->SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)&Info);
}
if (lResult)
{
SelectDropTarget(hItem);
m_hitemDrop = hItem;
}
}
m_pImageList->DragShowNolock(TRUE);
CTreeCtrl::OnMouseMove(nFlags, point);
}
void CUIDragDropTree::OnButtonUp(bool bMove)
{
if (!m_bDragging)
return;
EndDragging();
if (m_hitemDrag && m_hitemDrag != m_hitemDrop && !IsChildNodeOf(m_hitemDrop, m_hitemDrag) &&
GetParentItem(m_hitemDrag) != m_hitemDrop)
{
CDD_OleDropTargetInfo Info(GetSafeHwnd(),CPoint(),NULL);
Info.SetDropEffect(bMove ? DROPEFFECT_MOVE : DROPEFFECT_COPY);
Info.SetItem(m_hitemDrop);
LRESULT lResult = SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
if (lResult == 0)
lResult = GetParent()->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
}
}
void CUIDragDropTree::EndDragging()
{
if (!m_bDragging)
return;
m_bDragging = FALSE;
if (m_pImageList)
{
m_pImageList->DragLeave(this);
m_pImageList->EndDrag();
}
delete m_pImageList;
m_pImageList = NULL;
ReleaseCapture();
KillDragTimer();
}
void CUIDragDropTree::NewTransferItem(HTREEITEM hNewItem)
{
}
BOOL CUIDragDropTree::TransferItem(HTREEITEM hitemDrag, HTREEITEM hitemDrop)
{
TV_INSERTSTRUCT tvstruct;
TCHAR sztBuffer[256];
HTREEITEM hNewItem, hFirstChild;
// avoid an infinite recursion situation
tvstruct.item.hItem = hitemDrag;
tvstruct.item.cchTextMax = sizeof(sztBuffer)-1;
tvstruct.item.pszText = sztBuffer;
tvstruct.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
GetItem(&tvstruct.item);
tvstruct.hParent = hitemDrop;
tvstruct.hInsertAfter = TVI_SORT;
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
hNewItem = InsertItem(&tvstruct);
NewTransferItem(hNewItem);
while ((hFirstChild = GetChildItem(hitemDrag)) != NULL)
{
// recursively transfer all the items
TransferItem(hFirstChild, hNewItem);
// delete the first child and all its children
DeleteItem(hFirstChild);
}
return TRUE;
}
BOOL CUIDragDropTree::NeedToScroll( CPoint ptMouse )
{
if (m_bDragging)
{
return ptMouse.y < m_nUpperYCoor || ptMouse.y > m_nLowerYCoor;
}
else
{
return ptMouse.y < m_nUpperYCoor+10 || ptMouse.y > m_nLowerYCoor-30;
}
}
CUIDragDropTree::SCROLLMODE CUIDragDropTree::RefineScrollMode( CPoint ptMouse )
{
int nYCoor = ptMouse.y;
CUIDragDropTree::SCROLLMODE nScrollMode;
if (m_bDragging)
{
nScrollMode = nYCoor > m_nLowerYCoor + m_nScrollBarSize ? SCROLL_DOWN_NORMAL :
nYCoor > m_nLowerYCoor ? SCROLL_DOWN_SLOW :
nYCoor < m_nUpperYCoor - m_nScrollBarSize ? SCROLL_UP_NORMAL :
SCROLL_UP_SLOW;
}
else
{
nScrollMode = nYCoor > m_nLowerYCoor-30 ? SCROLL_DOWN_NORMAL :
nYCoor < m_nUpperYCoor-10 ? SCROLL_UP_NORMAL : SCROLL_UP_NORMAL;
}
return nScrollMode;
}
BOOL CUIDragDropTree::IsChildNodeOf(HTREEITEM hitemChild, HTREEITEM hitemSuspectedParent)
{
do
{
if (hitemChild == hitemSuspectedParent)
break;
}
while ((hitemChild = GetParentItem(hitemChild)) != NULL);
return (hitemChild != NULL);
}
void CUIDragDropTree::RegisterDropTarget()
{
if (GetDragDrop())
{
VERIFY(m_OleDropTarget.Register(this));
if (GetDropFiles())
DragAcceptFiles();
}
}
DROPEFFECT CUIDragDropTree::SelectCurrentTarget(CDD_OleDropTargetInfo *pInfo)
{
HTREEITEM hItem;
UINT flags;
if ((hItem = HitTest(pInfo->GetPoint(), &flags)) != NULL)
{
// select it
SelectDropTarget(hItem);
// save it
m_hitemDrop = hItem;
// returns 1 if allowed
pInfo->SetItem(hItem);
LRESULT lResult = SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)pInfo);
if (lResult == 0)
{
lResult = GetParent()->SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)pInfo);
}
if (lResult)
{
if (::GetKeyState(VK_LCONTROL) < 0)
{
if (ItemHasChildren(hItem))
{
Expand(hItem, TVE_EXPAND);
}
}
return pInfo->GetDropEffect();
}
}
return DROPEFFECT_NONE;
}
void CUIDragDropTree::OnDestroy()
{
CTreeCtrl::OnDestroy();
// TODO: Add your message handler code here
}
int CUIDragDropTree::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTreeCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
RegisterDropTarget();
return 0;
}
bool CUIDragDropTree::GetRDragMenu(CMenu *pMenu)
{
return true;
}
void CUIDragDropTree::OnDDMove()
{
m_CopyMode = eDDMove;
}
void CUIDragDropTree::OnDDCopy()
{
m_CopyMode = eDDCopy;
}
void CUIDragDropTree::OnDDCancel()
{
m_CopyMode = eDDCancel;
}
@@ -1,87 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "UIExplorerFrameWnd.h"
#include "UIres.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CUIExplorerFrameWnd, CUIFrameWnd)
CUIExplorerFrameWnd::CUIExplorerFrameWnd()
{
m_pExplorerView = NULL;
}
CUIExplorerFrameWnd::~CUIExplorerFrameWnd()
{
}
BOOL CUIExplorerFrameWnd::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
// create a splitter with 1 row, 2 columns
// if this asserts you forgot to call SetExplorerView
ASSERT(m_pExplorerView);
if (m_pExplorerView == NULL)
return CUIFrameWnd::OnCreateClient(lpcs,pContext);
USES_CONVERSION;
m_wndSplitter.SetSection(A2CT(GetRuntimeClass()->m_lpszClassName));
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStatic Splitter\n");
return FALSE;
}
CSize sizeSplitter(200,0);
// add the second splitter pane - a tab view in column 1
// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0, pContext->m_pNewViewClass, sizeSplitter, pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
TRACE1("Created %s view1\n",m_pExplorerView->m_lpszClassName);
}
if (m_pExplorerView)
{
pContext->m_pNewViewClass = m_pExplorerView;
if (!m_wndSplitter.CreateView(0, 1, pContext->m_pNewViewClass, CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
TRACE1("Created %s view2\n",m_pExplorerView->m_lpszClassName);
}
// activate the input view
SetActiveView((CView*)m_wndSplitter.GetPane(0,0));
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CUIExplorerFrameWnd message handlers
BEGIN_MESSAGE_MAP(CUIExplorerFrameWnd, CUIFrameWnd)
//{{AFX_MSG_MAP(CUIExplorerFrameWnd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -1,558 +0,0 @@
f////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// CFixMFCToolBar fixes sizing bugs in MFC CToolBar, so it works with
// modern toolbars in versions of comctl32.dll > 4.70.
//
// Most of this code is copied from MFC, with slight modifications marked "PD"
//
#include "StdAfx.h"
#include "UIFixTB.h"
#include "UIModulVer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CFixMFCToolBar, CToolBar)
BEGIN_MESSAGE_MAP(CFixMFCToolBar, CToolBar)
ON_MESSAGE(TB_SETBITMAPSIZE, OnSetBitmapSize)
ON_MESSAGE(TB_SETBUTTONSIZE, OnSetButtonSize)
ON_MESSAGE(WM_SETTINGCHANGE, OnSettingChange)
ON_MESSAGE(WM_SETFONT, OnSettingChange)
END_MESSAGE_MAP()
/////////////////
// This function gets the version number of comctl32.dll.
//
static int GetVerComCtl32()
{
CModuleVersion ver;
DLLVERSIONINFO dvi;
VERIFY(ver.DllGetVersion(_T("comctl32.dll"), dvi));
return dvi.dwMajorVersion*100 + dvi.dwMinorVersion;
}
int CFixMFCToolBar::iVerComCtl32 = GetVerComCtl32();
CFixMFCToolBar::CFixMFCToolBar()
{
m_bShowDropdownArrowWhenVertical = FALSE;
}
CFixMFCToolBar::~CFixMFCToolBar()
{
}
//////////////////
// These functions duplicate functionalityin VC 6.0
// Need to set transparent/flat style before setting
// button/image size or font to allow zero-height border.
//
LRESULT CFixMFCToolBar::OnSetBitmapSize(WPARAM, LPARAM lp)
{
return OnSizeHelper(m_sizeImage, lp);
}
LRESULT CFixMFCToolBar::OnSetButtonSize(WPARAM, LPARAM lp)
{
return OnSizeHelper(m_sizeButton, lp);
}
LRESULT CFixMFCToolBar::OnSettingChange(WPARAM, LPARAM lp)
{
return OnSizeHelper(CSize(0,0), lp);
}
LRESULT CFixMFCToolBar::OnSizeHelper(CSize& sz, LPARAM lp)
{
ASSERT(iVerComCtl32 > 0);
BOOL bModStyle =FALSE;
DWORD dwStyle =0;
if (iVerComCtl32 >= 471) {
dwStyle = GetStyle();
bModStyle = ModifyStyle(0, TBSTYLE_TRANSPARENT|TBSTYLE_FLAT);
}
LRESULT lRet = Default();
if (lRet)
sz = lp;
if (bModStyle)
SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
return lRet;
}
//////////////////
// **PD**
// This is the all-important function that gets the true size of a button,
// instead of using m_sizeButton. And it's virtual, so you can override if
// my algorithm doesn't work, as will surely be the case in some circumstances.
//
CSize CFixMFCToolBar::GetButtonSize(TBBUTTON* pData, int iButton)
{
ASSERT(iVerComCtl32 > 0);
// Get the actual size of the button, not what's in m_sizeButton.
// Make sure to do SendMessage instead of calling MFC's GetItemRect,
// which has all sorts of bad side-effects! (Go ahead, take a look at it.)
//
CRect rc;
SendMessage(TB_GETITEMRECT, iButton, (LPARAM)&rc);
CSize sz = rc.Size();
////////////////
// Now must do special case for various versions of comctl32.dll,
//
DWORD dwStyle = pData[iButton].fsStyle;
if ((pData[iButton].fsState & TBSTATE_WRAP)) {
if (dwStyle & TBSTYLE_SEP) {
// this is the last separator in the row (eg vertically docked)
// fudge the height, and ignore the width. TB_GETITEMRECT will return
// size = (8 x 22) even for a separator in vertical toolbar
//
if (iVerComCtl32 <= 470)
sz.cy -= 3; // empircally good fudge factor
else if (iVerComCtl32 != 471)
sz.cy = sz.cx;
sz.cx = 0; // separator takes no width if it's the last one
} else if (dwStyle & TBSTYLE_DROPDOWN &&
!m_bShowDropdownArrowWhenVertical) {
// ignore width of dropdown
sz.cx = 0;
}
}
return sz;
}
//////////////////
// **PD**
// Part 2 of correction for MFC is to recalculate everything when the bar
// goes from docked to undocked because the AdjustSize calculation happens
// when the bar is in the old state, and thus wrong. After the bar is
// docked/undocked, I'll recalculate with the new style and commit the change.
//
void CFixMFCToolBar::OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle)
{
CToolBar::OnBarStyleChange(dwOldStyle, dwNewStyle);
if (dwOldStyle != dwNewStyle) {
DWORD dwMode = 0;
if ((dwNewStyle & CBRS_SIZE_DYNAMIC) && (dwNewStyle & CBRS_FLOATING))
dwMode = LM_HORZ | LM_MRUWIDTH;
else if (dwNewStyle & CBRS_ORIENT_HORZ)
dwMode = LM_HORZ | LM_HORZDOCK;
else
dwMode = LM_VERTDOCK;
CalcDynamicLayout(-1, dwMode | LM_COMMIT);
}
}
////////////////////////////////////////////////////////////////
// Stuff below is copied from MFC; only mod is to call GetButtonSize.
#ifdef _MAC
#define CX_OVERLAP 1
#else
#define CX_OVERLAP 0
#endif
CSize CFixMFCToolBar::CalcSize(TBBUTTON* pData, int nCount)
{
ASSERT(pData != NULL && nCount > 0);
CPoint cur(0,0);
CSize sizeResult(0,0);
int cyTallestOnRow = 0;
for (int i = 0; i < nCount; i++)
{
if (pData[i].fsState & TBSTATE_HIDDEN)
continue;
// **PD**
// Load actual size of button into a local variable
// called m_sizeButton. C++ will use this instead of
// CToolBar::m_sizeButton.
//
CSize m_sizeButton = GetButtonSize(pData, i);
// **PD**
// I also changed the logic below to be more correct.
cyTallestOnRow = max(cyTallestOnRow, m_sizeButton.cy);
sizeResult.cx = max(cur.x + m_sizeButton.cx, sizeResult.cx);
sizeResult.cy = max(cur.y + m_sizeButton.cy, sizeResult.cy);
cur.x += m_sizeButton.cx - CX_OVERLAP;
if (pData[i].fsState & TBSTATE_WRAP)
{
cur.x = 0;
cur.y += cyTallestOnRow;
cyTallestOnRow = 0;
if (pData[i].fsStyle & TBSTYLE_SEP)
cur.y += m_sizeButton.cy;
}
}
return sizeResult;
}
int CFixMFCToolBar::WrapToolBar(TBBUTTON* pData, int nCount, int nWidth)
{
ASSERT(pData != NULL && nCount > 0);
int nResult = 0;
int x = 0;
for (int i = 0; i < nCount; i++)
{
pData[i].fsState &= ~TBSTATE_WRAP;
if (pData[i].fsState & TBSTATE_HIDDEN)
continue;
int dx, dxNext;
// **PD**
// Load actual size of button into a local variable
// called m_sizeButton. C++ will use this instead of
// CToolBar::m_sizeButton.
//
CSize m_sizeButton = GetButtonSize(pData, i);
dx = m_sizeButton.cx;
dxNext = dx - CX_OVERLAP;
if (x + dx > nWidth)
{
BOOL bFound = FALSE;
for (int j = i; j >= 0 && !(pData[j].fsState & TBSTATE_WRAP); j--)
{
// Find last separator that isn't hidden
// a separator that has a command ID is not
// a separator, but a custom control.
if ((pData[j].fsStyle & TBSTYLE_SEP) &&
(pData[j].idCommand == 0) &&
!(pData[j].fsState & TBSTATE_HIDDEN))
{
bFound = TRUE; i = j; x = 0;
pData[j].fsState |= TBSTATE_WRAP;
nResult++;
break;
}
}
if (!bFound)
{
for (int j = i - 1; j >= 0 && !(pData[j].fsState & TBSTATE_WRAP); j--)
{
// Never wrap anything that is hidden,
// or any custom controls
if ((pData[j].fsState & TBSTATE_HIDDEN) ||
((pData[j].fsStyle & TBSTYLE_SEP) &&
(pData[j].idCommand != 0)))
continue;
bFound = TRUE; i = j; x = 0;
pData[j].fsState |= TBSTATE_WRAP;
nResult++;
break;
}
if (!bFound)
x += dxNext;
}
}
else
x += dxNext;
}
return nResult + 1;
}
//////////////////////////////////////////////////////////////////////////
// **PD**
// Functions below are NOT actually modified. They're only here because they
// calls the modified functions above, which are NOT virtual.
//////////////////////////////////////////////////////////////////////////
void CFixMFCToolBar::SizeToolBar(TBBUTTON* pData, int nCount, int nLength, BOOL bVert)
{
ASSERT(pData != NULL && nCount > 0);
if (!bVert)
{
int nMin, nMax, nTarget, nCurrent, nMid;
// Wrap ToolBar as specified
nMax = nLength;
nTarget = WrapToolBar(pData, nCount, nMax);
// Wrap ToolBar vertically
nMin = 0;
nCurrent = WrapToolBar(pData, nCount, nMin);
if (nCurrent != nTarget)
{
while (nMin < nMax)
{
nMid = (nMin + nMax) / 2;
nCurrent = WrapToolBar(pData, nCount, nMid);
if (nCurrent == nTarget)
nMax = nMid;
else
{
if (nMin == nMid)
{
WrapToolBar(pData, nCount, nMax);
break;
}
nMin = nMid;
}
}
}
CSize size = CalcSize(pData, nCount);
WrapToolBar(pData, nCount, size.cx);
}
else
{
CSize sizeMax, sizeMin, sizeMid;
// Wrap ToolBar vertically
WrapToolBar(pData, nCount, 0);
sizeMin = CalcSize(pData, nCount);
// Wrap ToolBar horizontally
WrapToolBar(pData, nCount, 32767);
sizeMax = CalcSize(pData, nCount);
while (sizeMin.cx < sizeMax.cx)
{
sizeMid.cx = (sizeMin.cx + sizeMax.cx) / 2;
WrapToolBar(pData, nCount, sizeMid.cx);
sizeMid = CalcSize(pData, nCount);
if (nLength < sizeMid.cy)
{
if (sizeMin == sizeMid)
{
WrapToolBar(pData, nCount, sizeMax.cx);
return;
}
sizeMin = sizeMid;
}
else if (nLength > sizeMid.cy)
sizeMax = sizeMid;
else
return;
}
}
}
struct _AFX_CONTROLPOS
{
int nIndex, nID;
CRect rectOldPos;
};
CSize CFixMFCToolBar::CalcLayout(DWORD dwMode, int nLength)
{
ASSERT_VALID(this);
ASSERT(::IsWindow(m_hWnd));
if (dwMode & LM_HORZDOCK)
ASSERT(dwMode & LM_HORZ);
int nCount;
TBBUTTON* pData;
CSize sizeResult(0,0);
// Load Buttons
{
nCount = SendMessage(TB_BUTTONCOUNT, 0, 0);
if (nCount != 0)
{
int i;
pData = new TBBUTTON[nCount];
for (i = 0; i < nCount; i++)
GetButton(i, &pData[i]); // **PD** renamed from _GetButton
}
}
if (nCount > 0)
{
if (!(m_dwStyle & CBRS_SIZE_FIXED))
{
BOOL bDynamic = m_dwStyle & CBRS_SIZE_DYNAMIC;
if (bDynamic && (dwMode & LM_MRUWIDTH))
SizeToolBar(pData, nCount, m_nMRUWidth);
else if (bDynamic && (dwMode & LM_HORZDOCK))
SizeToolBar(pData, nCount, 32767);
else if (bDynamic && (dwMode & LM_VERTDOCK))
SizeToolBar(pData, nCount, 0);
else if (bDynamic && (nLength != -1))
{
CRect rect; rect.SetRectEmpty();
CalcInsideRect(rect, (dwMode & LM_HORZ));
BOOL bVert = (dwMode & LM_LENGTHY);
int nLen = nLength + (bVert ? rect.Height() : rect.Width());
SizeToolBar(pData, nCount, nLen, bVert);
}
else if (bDynamic && (m_dwStyle & CBRS_FLOATING))
SizeToolBar(pData, nCount, m_nMRUWidth);
else
SizeToolBar(pData, nCount, (dwMode & LM_HORZ) ? 32767 : 0);
}
sizeResult = CalcSize(pData, nCount);
if (dwMode & LM_COMMIT)
{
_AFX_CONTROLPOS* pControl = NULL;
int nControlCount = 0;
BOOL bIsDelayed = m_bDelayedButtonLayout;
m_bDelayedButtonLayout = FALSE;
for(int i = 0; i < nCount; i++)
if ((pData[i].fsStyle & TBSTYLE_SEP) && (pData[i].idCommand != 0))
nControlCount++;
if (nControlCount > 0)
{
pControl = new _AFX_CONTROLPOS[nControlCount];
nControlCount = 0;
for(int i = 0; i < nCount; i++)
{
if ((pData[i].fsStyle & TBSTYLE_SEP) && (pData[i].idCommand != 0))
{
pControl[nControlCount].nIndex = i;
pControl[nControlCount].nID = pData[i].idCommand;
CRect rect;
GetItemRect(i, &rect);
ClientToScreen(&rect);
pControl[nControlCount].rectOldPos = rect;
nControlCount++;
}
}
}
if ((m_dwStyle & CBRS_FLOATING) && (m_dwStyle & CBRS_SIZE_DYNAMIC))
m_nMRUWidth = sizeResult.cx;
for (i = 0; i < nCount; i++)
SetButton(i, &pData[i]); // **PD** renamed from _SetButton
if (nControlCount > 0)
{
for (int i = 0; i < nControlCount; i++)
{
CWnd* pWnd = GetDlgItem(pControl[i].nID);
if (pWnd != NULL)
{
CRect rect;
pWnd->GetWindowRect(&rect);
CPoint pt = rect.TopLeft() - pControl[i].rectOldPos.TopLeft();
GetItemRect(pControl[i].nIndex, &rect);
pt = rect.TopLeft() + pt;
pWnd->SetWindowPos(NULL, pt.x, pt.y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
}
}
delete[] pControl;
}
m_bDelayedButtonLayout = bIsDelayed;
}
delete[] pData;
}
//BLOCK: Adjust Margins
{
CRect rect; rect.SetRectEmpty();
CalcInsideRect(rect, (dwMode & LM_HORZ));
sizeResult.cy -= rect.Height();
sizeResult.cx -= rect.Width();
CSize size = CControlBar::CalcFixedLayout((dwMode & LM_STRETCH), (dwMode & LM_HORZ));
sizeResult.cx = max(sizeResult.cx, size.cx);
sizeResult.cy = max(sizeResult.cy, size.cy);
}
return sizeResult;
}
CSize CFixMFCToolBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
DWORD dwMode = bStretch ? LM_STRETCH : 0;
dwMode |= bHorz ? LM_HORZ : 0;
return CalcLayout(dwMode);
}
CSize CFixMFCToolBar::CalcDynamicLayout(int nLength, DWORD dwMode)
{
if ((nLength == -1) && !(dwMode & LM_MRUWIDTH) && !(dwMode & LM_COMMIT) &&
((dwMode & LM_HORZDOCK) || (dwMode & LM_VERTDOCK)))
{
return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZDOCK);
}
return CalcLayout(dwMode, nLength);
}
/////////////////////////////////////////////////////////////////////////////
// CToolBar attribute access
// **PD** I renamed this from _GetButton.
//
void CFixMFCToolBar::GetButton(int nIndex, TBBUTTON* pButton) const
{
CToolBar* pBar = (CToolBar*)this;
VERIFY(pBar->SendMessage(TB_GETBUTTON, nIndex, (LPARAM)pButton));
// TBSTATE_ENABLED == TBBS_DISABLED so invert it
pButton->fsState ^= TBSTATE_ENABLED;
}
// **PD** I renamed this from _SetButton.
//
void CFixMFCToolBar::SetButton(int nIndex, TBBUTTON* pButton)
{
// get original button state
TBBUTTON button;
VERIFY(SendMessage(TB_GETBUTTON, nIndex, (LPARAM)&button));
// prepare for old/new button comparsion
button.bReserved[0] = 0;
button.bReserved[1] = 0;
// TBSTATE_ENABLED == TBBS_DISABLED so invert it
pButton->fsState ^= TBSTATE_ENABLED;
pButton->bReserved[0] = 0;
pButton->bReserved[1] = 0;
// nothing to do if they are the same
if (memcmp(pButton, &button, sizeof(TBBUTTON)) != 0)
{
// don't redraw everything while setting the button
DWORD dwStyle = GetStyle();
ModifyStyle(WS_VISIBLE, 0);
VERIFY(SendMessage(TB_DELETEBUTTON, nIndex, 0));
VERIFY(SendMessage(TB_INSERTBUTTON, nIndex, (LPARAM)pButton));
ModifyStyle(0, dwStyle & WS_VISIBLE);
// invalidate appropriate parts
if (((pButton->fsStyle ^ button.fsStyle) & TBSTYLE_SEP) ||
((pButton->fsStyle & TBSTYLE_SEP) && pButton->iBitmap != button.iBitmap))
{
// changing a separator
Invalidate(FALSE);
}
else
{
// invalidate just the button
CRect rect;
if (SendMessage(TB_GETITEMRECT, nIndex, (LPARAM)&rect))
InvalidateRect(rect, FALSE); // don't erase background
}
}
}
@@ -1,334 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// CFlatToolBar implements dockable flat-style toolbars with "grippers"
//
#include "StdAfx.h"
#include "UIFlatBar.h"
#include "UIModulVer.h"
// if you want to see extra TRACE diagnostics, set below to TRUE
BOOL CFlatToolBar::bTRACE = FALSE;
#ifdef _DEBUG
#define FBTRACEFN \
CTraceFn __fooble; \
if (bTRACE) \
TRACE
#define FBTRACE \
if (bTRACE) \
TRACE
#else
#define FBTRACEFN TRACE
#define FBTRACE TRACE
#endif
/////////////////
// One of these for each drop-down button
//
struct DROPDOWNBUTTON {
DROPDOWNBUTTON* next;
UINT idButton; // command ID of button
UINT idMenu; // popup menu to display
};
// these define size of grippers
const GRIP_WIDTH = 3;
const GRIP_MARGIN = 5;
// flags stored in item data
#define ITEMF_INITIALIZED 0x01 // item data initialized
#define ITEMF_CHECKED 0x02 // item is checked
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////
// CFlatToolBar--does flat tool bar in MFC.
//
IMPLEMENT_DYNAMIC(CFlatToolBar, CFlatToolBarBase)
BEGIN_MESSAGE_MAP(CFlatToolBar, CFlatToolBarBase)
ON_NOTIFY_REFLECT(TBN_DROPDOWN, OnTbnDropDown)
ON_WM_WINDOWPOSCHANGING()
ON_WM_WINDOWPOSCHANGED()
ON_WM_NCCALCSIZE()
ON_WM_ERASEBKGND()
ON_WM_NCCREATE()
ON_WM_PAINT()
ON_WM_CREATE()
END_MESSAGE_MAP()
CFlatToolBar::CFlatToolBar()
{
FBTRACE(_T("CFlatToolBar::CFlatToolBar, comctl32 version = %d\n"),
iVerComCtl32);
m_bDrawDisabledButtonsInColor = FALSE; // don't use color
m_bInCoolBar = FALSE; // assume not inside coolbar
m_pDropDownButtons = NULL; // list of drop-down buttons
m_bShowDropdownArrowWhenVertical = TRUE;
m_bNoEntry = FALSE;
}
CFlatToolBar::~CFlatToolBar()
{
while (m_pDropDownButtons) {
DROPDOWNBUTTON* pnext = m_pDropDownButtons->next;
delete m_pDropDownButtons;
m_pDropDownButtons = pnext;
}
}
/////////////////
// Create handler: set flat style by default
//
int CFlatToolBar::OnCreate(LPCREATESTRUCT lpcs)
{
if (CFlatToolBarBase::OnCreate(lpcs) == -1)
return -1;
ModifyStyle(0, TBSTYLE_FLAT);
return 0; // OK
}
////////////////
// Load function sets flat style after loading buttons.
//
BOOL CFlatToolBar::LoadToolBar(LPCTSTR lpszResourceName)
{
// Set transparent/flat style before loading buttons to allow zero-height
// border. This required because of bug in comctl32.dll that always adds
// a border, unless flat/transparent.
//
DWORD dwStyle = GetStyle();
ModifyStyle(0, TBSTYLE_FLAT|TBSTYLE_TRANSPARENT);
BOOL bRet = CFlatToolBarBase::LoadToolBar(lpszResourceName);
SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
return bRet;
}
//////////////////
// Calcluate size of client area. Adds room for grippers
//
void CFlatToolBar::OnNcCalcSize(BOOL bCalc, NCCALCSIZE_PARAMS* pncp)
{
if (m_bInCoolBar) { // if I am in a coolbar (rebar):
Default(); // ..bypass CToolBar/CControlBar
} else {
CRect& rc = (CRect&)pncp->rgrc[0]; // rect to return
// copied from MFC below:
CRect rcMargin(0,0,0,0);
CControlBar::CalcInsideRect(rcMargin, m_dwStyle & CBRS_ORIENT_HORZ);
// adjust non-client area for border space
rc.left += rcMargin.left;
rc.top += rcMargin.top; // MFC has -2 here, bug for newer comctl32
rc.right += rcMargin.right;
rc.bottom+= rcMargin.bottom;
}
}
//////////////////
// MFC doesn't handle moving a TBSTYLE_FLAT toolbar correctly. The simplest
// way to fix it is to repaint whatever was underneath whenever the toolbar
// moves. This is done in this and the following function. All this stuff is
// only required because flat toolbars paint transparently (don't paint their
// backgrounds).
//
void CFlatToolBar::OnWindowPosChanging(LPWINDOWPOS lpwp)
{
if (m_bInCoolBar)
// inside coolbars, don't do MFC thing
Default();
else {
CFlatToolBarBase::OnWindowPosChanging(lpwp);
if (!(lpwp->flags & SWP_NOMOVE))
GetWindowRect(&m_rcOldPos); // remember old position
}
}
//////////////////
// Now toolbar has really moved: repaint area beneath old position
//
void CFlatToolBar::OnWindowPosChanged(LPWINDOWPOS lpwp)
{
if (m_bInCoolBar) {
Default();
} else {
CFlatToolBarBase::OnWindowPosChanged(lpwp);
if (!(lpwp->flags & SWP_NOMOVE)) { // if moved:
InvalidateOldPos(m_rcOldPos); // invalidate area of old position
// Now paint my non-client area at the new location.
// Without this, you will still have a partial display bug (try it!)
SendMessage(WM_NCPAINT);
}
}
}
//////////////////
// Invalidate toolbar rectangle. Because flat toolbars are transparent,
// this requires invalidating parent and all siblings that intersect the
// rectangle.
//
void CFlatToolBar::InvalidateOldPos(const CRect& rcInvalid)
{
// make parent paint the area beneath rectangle
CWnd* pParent = GetParent(); // parent (dock bar/frame) window
ASSERT_VALID(pParent); // check
CRect rc = rcInvalid; // copy rectangle
pParent->ScreenToClient(&rc); // convert to parent client coords
pParent->InvalidateRect(&rc); // invalidate
// now do same for each sibling too
for (CWnd* pSib = pParent->GetWindow(GW_CHILD);
pSib;
pSib=pSib->GetNextWindow(GW_HWNDNEXT)) {
CRect rc; // window rect of sibling
pSib->GetWindowRect(&rc); // ...
if (rc.IntersectRect(rc, rcInvalid)) { // if intersects invalid rect
pSib->ScreenToClient(&rc); // convert to sibling coords
pSib->InvalidateRect(&rc); // invalidate
pSib->SendMessage(WM_NCPAINT); // nonclient area too!
}
}
}
////////////////
// Override to avoid MFC in case I'm inside a coolbar
//
BOOL CFlatToolBar::OnEraseBkgnd(CDC* pDC)
{
return m_bInCoolBar ? Default() : CFlatToolBarBase::OnEraseBkgnd(pDC);
}
//////////////////
// If toolbar is inside a coolbar, need to make the parent frame
// my owner so it will get notifications.
//
BOOL CFlatToolBar::OnNcCreate(LPCREATESTRUCT lpcs)
{
CWnd* pParent = GetParent();
ASSERT(pParent);
TCHAR classname[64];
GetClassName(pParent->m_hWnd, classname, countof(classname));
if (_tcscmp(classname, REBARCLASSNAME)==0) {
CFrameWnd* pFrame = GetParentFrame();
ASSERT_VALID(pFrame);
SetOwner(pFrame);
m_bInCoolBar = TRUE;
}
return CFlatToolBarBase::OnNcCreate(lpcs);
}
//////////////////
// Avoid MFC if I'm inside a coolbar
//
void CFlatToolBar::OnPaint()
{
if (m_bInCoolBar)
Default(); // bypass CToolBar/CControlBar
else
CFlatToolBarBase::OnPaint();
}
////////////////////////////////////////////////////////////////
// Stuff for handling drop-down buttons in toobars
//
//////////////////
// Add dropdown buttons.
// The manager takes care of setting appropriate styles, etc.
//
// Args:
// - array of LONGs: MAKELONG(commandID, menuID)
// - number of buttons
//
BOOL CFlatToolBar::AddDropDownButton(UINT nIDButton, UINT nIDMenu, BOOL bArrow)
{
ASSERT_VALID(this);
DROPDOWNBUTTON* pb = FindDropDownButton(nIDButton);
if (!pb) {
pb = new DROPDOWNBUTTON;
ASSERT(pb);
pb->next = m_pDropDownButtons;
m_pDropDownButtons = pb;
}
pb->idButton = nIDButton;
pb->idMenu = nIDMenu;
int iButton = CommandToIndex(nIDButton);
DWORD dwStyle = GetButtonStyle(iButton);
dwStyle |= TBSTYLE_DROPDOWN;
SetButtonStyle(iButton, dwStyle);
if (bArrow)
SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
return TRUE;
}
//////////////////
// Find buttons structure for given ID
//
DROPDOWNBUTTON* CFlatToolBar::FindDropDownButton(UINT nID)
{
for (DROPDOWNBUTTON* pb = m_pDropDownButtons; pb; pb = pb->next) {
if (pb->idButton == nID)
return pb;
}
return NULL;
}
//////////////////
// Handle TBN_DROPDOWN
// Default is to display the specified menu at the right place.
// You can override to generate dynamic menus
//
// Args:
// - NMTOOLBAR struct from TBN_DROPDOWN
// - command id of button
// - point to display menu at
//
void CFlatToolBar::OnTbnDropDown(NMHDR* pNMHDR, LRESULT* pRes)
{
const NMTOOLBAR& nmtb = *(NMTOOLBAR*)pNMHDR;
// get location of button
CRect rc;
GetRect(nmtb.iItem, rc);
ClientToScreen(&rc);
// call virtual function to display dropdown menu
OnDropDownButton(nmtb, nmtb.iItem, rc);
}
/////////////////
// Virtual fn you can override to hand drop-down button
// events with more friendly args
//
void CFlatToolBar::OnDropDownButton(const NMTOOLBAR& nmtb, UINT nID, CRect rc)
{
DROPDOWNBUTTON* pb = FindDropDownButton(nmtb.iItem);
if (pb && pb->idMenu) {
// load and display popup menu
CMenu menu;
VERIFY(menu.LoadMenu(pb->idMenu));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup);
pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,
rc.left, rc.bottom, GetOwner(), &rc);
}
}
@@ -1,514 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
#include "stdafx.h"
#include "UIFrameWnd.h"
#include "UIApp.h"
#include "UIres.h"
#include "UIMessages.h"
#include "WindowPlacement.h"
#include "IEShellTreeView.h"
#include "IEShellListView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static UINT nMsgMouseWheel =
(((::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 4)) ||
(!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 3)))
? ::RegisterWindowMessage(MSH_MOUSEWHEEL) : 0;
LPCTSTR CUIFrameWnd::szMainFrame = _T("MainFrame");
IMPLEMENT_DYNAMIC(CUIFrameWnd, CFrameWnd)
CUIFrameWnd::CUIFrameWnd() : m_IDToolbar(0),m_pwndCoolBar(NULL)
{
m_bReportCtrl = false;
}
CUIFrameWnd::~CUIFrameWnd()
{
delete m_pwndCoolBar;
}
void CUIFrameWnd::RestoreWindow(UINT nCmdShow)
{
// Load window placement from profile
CWindowPlacement wp;
if (!wp.Restore(CUIFrameWnd::szMainFrame, this))
{
ShowWindow(nCmdShow);
}
}
CUIStatusBar &CUIFrameWnd::GetStatusBar()
{
return m_wndStatusBar;
}
CReallyCoolBar &CUIFrameWnd::GetCoolBar()
{
ASSERT(m_pwndCoolBar);
return *m_pwndCoolBar;
}
void CUIFrameWnd::CreateCoolBar()
{
if (m_pwndCoolBar == NULL)
m_pwndCoolBar = new CReallyCoolBar;
}
CCoolMenuManager &CUIFrameWnd::GetMenuManager()
{
return m_menuManager;
}
BEGIN_MESSAGE_MAP(CUIFrameWnd, CFrameWnd)
//{{AFX_MSG_MAP(CUIFrameWnd)
ON_WM_INITMENUPOPUP()
ON_WM_MENUSELECT()
ON_WM_CREATE()
ON_WM_CLOSE()
ON_WM_MOUSEWHEEL()
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(nMsgMouseWheel, OnRegisteredMouseWheel)
ON_MESSAGE(WM_APP_CB_IE_SET_EDIT_TEXT,OnCBIESetEditText)
ON_MESSAGE(WM_APP_CB_IE_POPULATE,OnCBIEPopulate)
ON_MESSAGE(WM_APP_CB_IE_SEL_CHANGE,OnCBIESelChange)
ON_MESSAGE(WM_APP_CB_IE_HIT_ENTER,OnCBIEHitEnter)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUIFrameWnd message handlers
BOOL CUIFrameWnd::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
CWinApp *pApp = AfxGetApp();
if (pApp->IsKindOf(RUNTIME_CLASS(CUIApp)))
{
if (((CUIApp*)pApp)->IsMyClassRegistered())
{
cs.lpszClass = ((CUIApp*)pApp)->GetMyClass();
TRACE(_T("Setting to window class %s in CUIFrameWnd\n"),cs.lpszClass);
}
}
if (cs.lpszClass == NULL)
{
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS,
NULL,
NULL,
NULL);
ASSERT(cs.lpszClass);
}
CWindowPlacement wp;
if (wp.GetProfileWP(szMainFrame))
{
CRect rc(wp.rcNormalPosition);
cs.x = rc.left;
cs.y = rc.top;
cs.cx = rc.Width();
cs.cy = rc.Height();
}
return CFrameWnd::PreCreateWindow(cs);
}
void CUIFrameWnd::OnClose()
{
// TODO: Add your message handler code here and/or call default
CWindowPlacement wp;
wp.Save(szMainFrame,this);
CFrameWnd::OnClose();
}
void CUIFrameWnd::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
// store width of first pane and its style
if (GetStatusBar().m_nStatusPane1Width == -1 && GetStatusBar().m_bMenuSelect)
{
UINT nStatusPane1Style;
GetStatusBar().GetPaneInfo(0, GetStatusBar().m_nStatusPane1ID,
nStatusPane1Style, GetStatusBar().m_nStatusPane1Width);
GetStatusBar().SetPaneInfo(0, GetStatusBar().m_nStatusPane1ID,
SBPS_NOBORDERS|SBPS_STRETCH, 16384);
}
}
int CUIFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// if not tool bar set no point in continuing
ASSERT(m_IDToolbar > 0);
if (m_IDToolbar == 0)
return 0;
if (!GetStatusBar().Create(this))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
GetStatusBar().AddPane(ID_SEPARATOR,TRUE);
GetStatusBar().SetPanes(FALSE);
CreateCoolBar();
ASSERT(m_pwndCoolBar);
if (m_pwndCoolBar == NULL)
return -1;
CReallyCoolBar& cb = GetCoolBar();
ASSERT(m_IDToolbar > 0);
cb.SetToolBarID(m_IDToolbar);
VERIFY(cb.Create(this,
WS_CHILD|WS_VISIBLE|WS_BORDER|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|
RBS_TOOLTIPS|RBS_BANDBORDERS|RBS_VARHEIGHT));
cb.SetColors(GetSysColor(COLOR_BTNTEXT),GetSysColor(COLOR_3DFACE));
// install/load cool menus
GetMenuManager().Install(this);
GetMenuManager().LoadToolbar(m_IDToolbar);
if (cb.IsKindOf(RUNTIME_CLASS(CWebBrowserCoolBar)))
GetMenuManager().LoadToolbar(IDB_HOTTOOLBAR);
if (m_bReportCtrl)
{
if (!m_wndFieldChooser.Create(this, IDD_FIELDCHOOSER,
CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE, ID_VIEW_FIELDCHOOSER))
return -1; // fail to create
EnableDocking(CBRS_ALIGN_ANY);
m_wndFieldChooser.EnableDocking(0);
m_wndFieldChooser.SetWindowText(_T("Field Chooser"));
FloatControlBar(&m_wndFieldChooser, CPoint(100, GetSystemMetrics(SM_CYSCREEN) / 3));
ShowControlBar(&m_wndFieldChooser, FALSE, FALSE);
}
return 0;
}
void CUIFrameWnd::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu)
{
CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu);
// Restore first pane of the statusbar?
if (nFlags == 0xFFFF && hSysMenu == 0 && GetStatusBar().m_nStatusPane1Width != -1)
{
GetStatusBar().m_bMenuSelect = FALSE;
GetStatusBar().SetPaneInfo(0, GetStatusBar().m_nStatusPane1ID, GetStatusBar().m_nStatusPane1Style, GetStatusBar().m_nStatusPane1Width);
GetStatusBar().m_nStatusPane1Width = -1; // Set it to illegal value
}
else
{
GetStatusBar().m_bMenuSelect = TRUE;
}
}
void CUIFrameWnd::GetMessageString( UINT nID, CString& rMessage ) const
{
CFrameWnd::GetMessageString(nID,rMessage);
CUIFrameWnd *pThis = const_cast<CUIFrameWnd*>(this);
if (pThis->GetStatusBar().IsPanes())
pThis->GetStatusBar().SetPaneText(0,rMessage);
}
BOOL CUIFrameWnd::PreTranslateMessage(MSG* pMsg)
{
return m_pwndCoolBar && m_pwndCoolBar->m_wndMenuBar.TranslateFrameMessage(pMsg) ?
TRUE : CFrameWnd::PreTranslateMessage(pMsg);
}
////////////////////////////////////////////////////////////////
// CReallyCoolBar
//
IMPLEMENT_DYNAMIC(CReallyCoolBar, CCoolBar)
IMPLEMENT_DYNAMIC(CWebBrowserCoolBar, CCoolBar)
////////////////
// This is the virtual function you have to override to add bands
//
BOOL CReallyCoolBar::OnCreateBands()
{
//////////////////
// Create menu bar
CMenuBar& mb = m_wndMenuBar;
VERIFY(mb.Create(this, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|
CBRS_TOOLTIPS|CBRS_SIZE_DYNAMIC|CBRS_FLYBY|CBRS_ORIENT_HORZ));
mb.ModifyStyle(0, TBSTYLE_TRANSPARENT);
// Load doc or main menu. Only required since this app flips
// between coolbar/toolbars.
CFrameWnd *pParent = GetParentFrame();
CFrameWnd* pFrame = pParent->GetActiveFrame();
ASSERT(m_IDToolbar > 0);
mb.LoadMenu(m_IDToolbar);
CRect rc;
mb.GetItemRect(0, &rc);
CSize szMenu = mb.CalcDynamicLayout(-1, LM_HORZ); // get min horz size
// create menu bar band.
CSize szMin;
szMin = CSize( szMenu.cx, rc.Height());
if (!InsertBand(&mb, szMin, 0x7ff))
return FALSE;
//////////////////
// Create tool bar
CFlatToolBar& tb = m_wndToolBar;
VERIFY(tb.Create(this,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|
CBRS_TOOLTIPS|CBRS_SIZE_DYNAMIC|CBRS_FLYBY|CBRS_ORIENT_HORZ));
VERIFY(tb.LoadToolBar(m_IDToolbar));
// use transparent so coolbar bitmap will show through
tb.ModifyStyle(0, TBSTYLE_TRANSPARENT);
// Get minimum size of toolbar, which is basically size of one button
CSize szHorz = tb.CalcDynamicLayout(-1, LM_HORZ); // get min horz size
tb.GetItemRect(0, &rc);
szMin = rc.Size(); // CSize( szHorz.cx, rc.Height());
// create toolbar band. Use largest size possible
if (!InsertBand(&tb, szMin, 0x7fff, NULL, -1, TRUE))
return FALSE;
return TRUE; // OK
}
void CReallyCoolBar::SetToolBarID(UINT IDToolbar)
{
m_IDToolbar = IDToolbar;
}
BOOL CWebBrowserCoolBar::OnCreateBands()
{
CReallyCoolBar::OnCreateBands();
CFlatToolBar& bb = m_wndBrowserBar;
VERIFY(bb.Create(this,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|
CBRS_TOOLTIPS|CBRS_SIZE_DYNAMIC|CBRS_FLYBY|CBRS_ORIENT_HORZ));
CImageList img;
CString str;
// bb.GetToolBarCtrl().SetButtonWidth(50, 150);
bb.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
img.Create(IDB_HOTTOOLBAR, 22, 0, RGB(255, 0, 255));
bb.GetToolBarCtrl().SetHotImageList(&img);
img.Detach();
img.Create(IDB_COLDTOOLBAR, 22, 0, RGB(255, 0, 255));
bb.GetToolBarCtrl().SetImageList(&img);
img.Detach();
bb.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
bb.SetButtons(NULL, 7);
// use transparent so coolbar bitmap will show through
bb.ModifyStyle(0, TBSTYLE_TRANSPARENT);
// set up each toolbar button
/* str.LoadString(IDS_BROWSER_GO_BACK);
bb.SetButtonText(0, str);
str.LoadString(IDS_BROWSER_GO_FORWARD);
bb.SetButtonText(1, str);
str.LoadString(IDS_BROWSER_STOP);
bb.SetButtonText(2, str);
str.LoadString(IDS_BROWSER_REFRESH);
bb.SetButtonText(3, str);
str.LoadString(IDS_BROWSER_GO_HOME);
bb.SetButtonText(4, str);
str.LoadString(IDS_BROWSER_SEARCH);
bb.SetButtonText(5, str);
str.LoadString(IDS_BROWSER_FAVORITES);
bb.SetButtonText(6, str);
*/
bb.SetButtonInfo(0, ID_BROWSER_GO_BACK, TBSTYLE_BUTTON, 0);
bb.SetButtonInfo(1, ID_BROWSER_GO_FORWARD, TBSTYLE_BUTTON, 1);
bb.SetButtonInfo(2, ID_BROWSER_STOP, TBSTYLE_BUTTON, 2);
bb.SetButtonInfo(3, ID_BROWSER_REFRESH, TBSTYLE_BUTTON, 3);
bb.SetButtonInfo(4, ID_BROWSER_GO_HOME, TBSTYLE_BUTTON, 4);
bb.SetButtonInfo(5, ID_BROWSER_SEARCH, TBSTYLE_BUTTON, 5);
bb.SetButtonInfo(6, ID_BROWSER_FAVORITES, TBSTYLE_BUTTON, 6);
CRect rectToolBar;
CRect rc;
// set up toolbar button sizes
bb.GetItemRect(0, &rectToolBar);
// bb.SetSizes(rectToolBar.Size(), CSize(30,20));
// Get minimum size of toolbar, which is basically size of one button
CSize szHorz = bb.CalcDynamicLayout(-1, LM_HORZ); // get min horz size
bb.GetItemRect(0, &rc);
CSize szMin = rc.Size(); // CSize( szHorz.cx, rc.Height());
// create toolbar band. Use largest size possible
if (!InsertBand(&bb, szMin, 0x7fff, NULL, -1, TRUE))
return FALSE;
//////////////////
// Create combo box and fill with data
CRect rcCombo(0,0,600,200);
m_wndCombo.Create(WS_VISIBLE|WS_CHILD|WS_VSCROLL|CBS_DROPDOWN|
WS_CLIPCHILDREN|WS_CLIPSIBLINGS, rcCombo, this, IDC_CB_IE_ADDRESS);
m_wndCombo.SetFont(GetFont());
CSize szMinCombo = m_wndBrowserBar.CalcDynamicLayout(-1, LM_HORZDOCK); // get min horz size
if (!InsertBand(&m_wndCombo, szMinCombo, 0x7fff, _T("Address")))
return FALSE;
return TRUE;
}
// changed from MFC to use WindowFromPoint instead of GetFocus
LRESULT CUIFrameWnd::OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam)
{
// convert from MSH_MOUSEWHEEL to WM_MOUSEWHEEL
TRACE(_T("CUFrameWnd registered mouse wheel message\n"));
// return CFrameWnd::OnRegisteredMouseWheel(wParam,lParam);
WORD keyState = 0;
keyState |= (::GetKeyState(VK_CONTROL) < 0) ? MK_CONTROL : 0;
keyState |= (::GetKeyState(VK_SHIFT) < 0) ? MK_SHIFT : 0;
LRESULT lResult;
CPoint point;
::GetCursorPos(&point);
HWND hwFocus = ::WindowFromPoint(point);
// HWND hwFocus = ::GetFocus();
const HWND hwDesktop = ::GetDesktopWindow();
if (hwFocus == NULL)
lResult = SendMessage(WM_MOUSEWHEEL, (wParam << 16) | keyState, lParam);
else
{
do {
lParam = ::SendMessage(hwFocus, WM_MOUSEWHEEL,
(wParam << 16) | keyState, lParam);
hwFocus = ::GetParent(hwFocus);
}
while (lParam == 0 && hwFocus != NULL && hwFocus != hwDesktop);
}
return lResult;
}
BOOL CUIFrameWnd::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
CFrameWnd::OnMouseWheel(nFlags,zDelta,pt);
// TODO: Add your message handler code here and/or call default
TRACE(_T("CUIFrameWnd mouse wheel message\n"));
return TRUE;
}
LRESULT CUIFrameWnd::OnCBIEPopulate(WPARAM wParam,LPARAM lParam)
{
TRACE(_T("Received ComboBox populate message in CUIFrameWnd\n"));
if (m_pwndCoolBar && m_pwndCoolBar->IsKindOf(RUNTIME_CLASS(CWebBrowserCoolBar)))
{
TRACE(_T("Sending to ShellComboBox...\n"));
((CWebBrowserCoolBar*)m_pwndCoolBar)->GetComboBox().SendMessage(WM_APP_CB_IE_POPULATE,wParam,lParam);
}
return 1L;
}
LRESULT CUIFrameWnd::OnCBIEHitEnter(WPARAM wParam,LPARAM lParam)
{
if (lParam == NULL)
return 0L;
if (m_pwndCoolBar && m_pwndCoolBar->IsKindOf(RUNTIME_CLASS(CWebBrowserCoolBar)))
{
CWinApp *pApp = AfxGetApp();
CUIApp *pUIApp=NULL;
if (pApp->IsKindOf(RUNTIME_CLASS(CUIApp)))
pUIApp = (CUIApp*)pApp;
if (pUIApp)
{
CView *pView = NULL;
pView = pUIApp->GetView(RUNTIME_CLASS(CIEShellTreeView));
if (pView)
{
LRESULT lResult = 0;
if (wParam == 0)
lResult = ((CIEShellTreeView*)pView)->GetShellTreeCtrl().SendMessage(WM_APP_CB_IE_HIT_ENTER,wParam,lParam);
if (lResult == 0)
{
pView = pUIApp->GetView(RUNTIME_CLASS(CIEShellListView));
if (pView)
pView->SendMessage(WM_APP_CB_IE_HIT_ENTER,wParam,lParam);
}
}
}
}
return 1L;
}
LRESULT CUIFrameWnd::OnCBIESelChange(WPARAM wParam,LPARAM lParam)
{
if (m_pwndCoolBar && m_pwndCoolBar->IsKindOf(RUNTIME_CLASS(CWebBrowserCoolBar)))
{
CWinApp *pApp = AfxGetApp();
CUIApp *pUIApp=NULL;
if (pApp->IsKindOf(RUNTIME_CLASS(CUIApp)))
pUIApp = (CUIApp*)pApp;
if (pUIApp)
{
CView *pView = NULL;
if (wParam)
{
pView = pUIApp->GetView(RUNTIME_CLASS(CIEShellTreeView));
if (pView)
((CIEShellTreeView*)pView)->GetShellTreeCtrl().SendMessage(WM_APP_CB_IE_SEL_CHANGE,wParam,lParam);
}
else
{
pView = pUIApp->GetView(RUNTIME_CLASS(CIEShellListView));
if (pView)
pView->SendMessage(WM_APP_CB_IE_SEL_CHANGE,wParam,lParam);
}
}
}
return 1L;
}
LRESULT CUIFrameWnd::OnCBIESetEditText(WPARAM wParam,LPARAM lParam)
{
if (m_pwndCoolBar && m_pwndCoolBar->IsKindOf(RUNTIME_CLASS(CWebBrowserCoolBar)))
{
if (wParam)
((CWebBrowserCoolBar*)m_pwndCoolBar)->GetComboBox().GetEditCtrl()->SetWindowText((LPCTSTR)wParam);
}
return 1L;
}
////////////////////////////////////////////////////////////////
// CToolBarComboBox
//
BEGIN_MESSAGE_MAP(CToolBarComboBox, CIEShellComboBox)
END_MESSAGE_MAP()
//////////////////
@@ -1,694 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// HtmlMsgView.cpp : implementation file
//
#include "stdafx.h"
#include "UIHtmlView.h"
#include "UIMessages.h"
#include <atlbase.h>
#include <mshtml.h>
#include "UIres.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUIHtmlView
IMPLEMENT_DYNAMIC(CUIHtmlView, CHtmlView)
CUIHtmlView::CUIHtmlView()
{
//{{AFX_DATA_INIT(CUIHtmlView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pHTMLDocument2 = NULL;
m_hNotifyWnd = NULL;
m_bSetCursor = false;
}
CUIHtmlView::~CUIHtmlView()
{
ReleaseDocument();
}
BOOL CUIHtmlView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS,
NULL,
NULL,
NULL);
ASSERT(cs.lpszClass);
BOOL bRet = CHtmlView::PreCreateWindow(cs);
cs.dwExStyle |= WS_EX_CLIENTEDGE;
// cs.style |= WS_BORDER;
return bRet;
}
void CUIHtmlView::ReleaseDocument()
{
if (m_pHTMLDocument2)
{
m_pHTMLDocument2->Release();
m_pHTMLDocument2 = NULL;
}
}
void CUIHtmlView::DocumentReady()
{
m_bSetCursor = false;
}
bool CUIHtmlView::ExecScript(LPCTSTR pszScript,LPCTSTR pszLang,_variant_t *pvt)
{
bool bRet = false;
CWaitCursor w;
IHTMLWindow2 *pW2=NULL;
IHTMLDocument2 *pDoc = GetHTMLDocument();
if (pDoc == NULL)
return bRet;
HRESULT hr = pDoc->get_parentWindow(&pW2);
if (SUCCEEDED(hr))
{
if (pszLang == NULL)
pszLang = _T("JScript");
_variant_t v;
hr = pW2->execScript(_bstr_t(pszScript),_bstr_t(pszLang),&v);
if (pvt)
*pvt = v;
pW2->Release();
bRet= true;
}
return bRet;
}
CString CUIHtmlView::GetBodyText()
{
IHTMLElement *pElem=NULL;
GetHTMLDocument()->get_body(&pElem);
_bstr_t bstText;
BSTR bsText;
pElem->get_innerText(&bsText);
pElem->Release();
bstText = bsText;
return (LPCTSTR)bstText;
}
CString CUIHtmlView::GetElementValue(LPCTSTR pszElemID)
{
IHTMLElement *pElem=NULL;
GetElement(pszElemID,&pElem);
BSTR bsText;
_bstr_t bstText;
if (pElem)
{
IHTMLInputTextElement *pInputElem=NULL;
HRESULT hr = pElem->QueryInterface(IID_IHTMLInputTextElement,(LPVOID*)&pInputElem);
if (SUCCEEDED(hr))
{
pInputElem->get_value(&bsText);
bstText= bsText;
pInputElem->Release();
pInputElem = NULL;
}
pElem->Release();
}
return (LPCTSTR)bstText;
}
CString CUIHtmlView::GetElementText(LPCTSTR pszElemID)
{
IHTMLElement *pElem=NULL;
GetElement(pszElemID,&pElem);
if (pElem == NULL)
return _T("");
BSTR bsText;
_bstr_t bstText;
pElem->get_innerText(&bsText);
bstText = bsText;
pElem->Release();
pElem = NULL;
return (LPCTSTR)bstText;
}
CString CUIHtmlView::GetElementHTML(LPCTSTR pszElemID)
{
IHTMLElement *pElem=NULL;
GetElement(pszElemID,&pElem);
BSTR bsText;
_bstr_t bstText;
if (pElem)
{
pElem->get_innerHTML(&bsText);
bstText = bsText;
pElem->Release();
pElem = NULL;
}
return (LPCTSTR)bstText;
}
bool CUIHtmlView::SetElementValue(LPCTSTR pszElemID,LPCTSTR pszText)
{
bool bRet=false;
IHTMLElement *pElem=NULL;
GetElement(pszElemID,&pElem);
if (pElem)
{
IHTMLInputTextElement *pInputElem=NULL;
HRESULT hr = pElem->QueryInterface(IID_IHTMLInputTextElement,(LPVOID*)&pInputElem);
if (SUCCEEDED(hr))
{
pInputElem->put_value(_bstr_t(pszText));
pInputElem->Release();
pInputElem = NULL;
bRet = true;
}
pElem->Release();
pElem = NULL;
}
return bRet;
}
bool CUIHtmlView::SetElementText(LPCTSTR pszElemID,LPCTSTR pszText)
{
bool bRet=false;
IHTMLElement *pElem=NULL;
GetElement(pszElemID,&pElem);
if (pElem == NULL)
return bRet;
pElem->put_innerText(_bstr_t(pszText));
pElem->Release();
pElem = NULL;
bRet= true;
return bRet;
}
bool CUIHtmlView::SetElementHTML(LPCTSTR pszElemID,LPCTSTR pszText)
{
bool bRet=false;
IHTMLElement *pElem=NULL;
GetElement(pszElemID,&pElem);
if (pElem == NULL)
return bRet;
pElem->put_innerHTML(_bstr_t(pszText));
pElem->Release();
pElem = NULL;
bRet= true;
return bRet;
}
bool CUIHtmlView::SetImageSource(LPCTSTR pszElemID,LPCTSTR pszText)
{
bool bRet=false;
IHTMLElement *pElem=NULL;
GetElement(pszElemID,&pElem);
if (pElem == NULL)
return bRet;
IHTMLImgElement *pImgElem=NULL;
HRESULT hr = pElem->QueryInterface(IID_IHTMLImgElement,(LPVOID*)&pImgElem);
pElem->Release();
if (SUCCEEDED(hr))
{
pImgElem->put_src(_bstr_t(pszText));
pImgElem->Release();
bRet = true;
}
return bRet;
}
bool CUIHtmlView::GetOptionString(LPCTSTR pszElemID,CString &sText,CString &sValue)
{
IHTMLElement *pElement = NULL;
GetElement(pszElemID,&pElement);
bool bRet=false;
if (pElement == NULL)
return bRet;
IHTMLSelectElement *pSelElem=NULL;
HRESULT hr = pElement->QueryInterface(IID_IHTMLSelectElement,(LPVOID*)&pSelElem);
pElement->Release();
pElement = NULL;
if (FAILED(hr))
return bRet;
long nSelIndex=-1;
pSelElem->get_selectedIndex(&nSelIndex);
if (nSelIndex == -1)
{
pSelElem->Release();
return bRet;
}
IDispatch *pDisp=NULL;
_variant_t vtName(nSelIndex);
_variant_t vtIndex;
pSelElem->item(vtName,vtIndex,&pDisp);
IHTMLOptionElement *pOptElem=NULL;
hr = pDisp->QueryInterface(IID_IHTMLOptionElement,(LPVOID*)&pOptElem);
if (SUCCEEDED(hr))
{
_bstr_t bstValue;
BSTR bsValue;
pOptElem->get_value(&bsValue);
bstValue = bsValue;
sValue = (LPCTSTR)bstValue;
BSTR bsText;
_bstr_t bstText;
pOptElem->get_text(&bsText);
bstText = bsText;
sText = (LPCTSTR)bstText;
pOptElem->Release();
bRet=true;
}
if (pSelElem)
pSelElem->Release();
return bRet;
}
bool CUIHtmlView::SetOptionString(LPCTSTR pszElemID,LPCTSTR pszText)
{
IHTMLElement *pElement = NULL;
GetElement(pszElemID,&pElement);
bool bRet=false;
if (pElement == NULL)
return bRet;
IHTMLSelectElement *pSelElem=NULL;
IDispatch *pDisp=NULL;
HRESULT hr = pElement->QueryInterface(IID_IHTMLSelectElement,(LPVOID*)&pSelElem);
if (FAILED(hr))
goto SOS_CleanUp;
{
long nLength=0;
pSelElem->get_length(&nLength);
for(long i=0;i < nLength;i++)
{
_variant_t vtName(i);
_variant_t vtIndex;
pSelElem->item(vtName,vtIndex,&pDisp);
if (pDisp == NULL)
continue;
IHTMLOptionElement *pOptElem=NULL;
hr = pDisp->QueryInterface(IID_IHTMLOptionElement,(LPVOID*)&pOptElem);
pDisp->Release();
pDisp = NULL;
if (SUCCEEDED(hr))
{
_bstr_t bstValue;
_bstr_t bstText;
BSTR bsValue;
BSTR bsText;
pOptElem->get_value(&bsValue);
pOptElem->get_text(&bsText);
bstValue = bsValue;
bstText = bsText;
pOptElem->Release();
if (_tcsicmp((LPCTSTR)bstText,pszText) == 0)
{
pSelElem->put_selectedIndex(i);
bRet=true;
break;
}
}
}
}
SOS_CleanUp:
if (pElement)
pElement->Release();
if (pSelElem)
pSelElem->Release();
return bRet;
}
bool CUIHtmlView::AddOptionString(LPCTSTR pszElemID,LPCTSTR pszText,LPCTSTR pszValue,bool bSelect)
{
IHTMLElement *pElement = NULL;
GetElement(pszElemID,&pElement);
bool bRet=false;
if (pElement == NULL)
return bRet;
IHTMLSelectElement *pSelElem=NULL;
HRESULT hr = pElement->QueryInterface(IID_IHTMLSelectElement,(LPVOID*)&pSelElem);
pElement->Release();
if (FAILED(hr))
return bRet;
IHTMLElement *pNewElem=NULL;
GetHTMLDocument()->createElement(_bstr_t(_T("OPTION")),&pNewElem);
IHTMLOptionElement *pNewOptElem=NULL;
hr = E_FAIL;
if (pNewElem)
hr = pNewElem->QueryInterface(IID_IHTMLOptionElement,(LPVOID*)&pNewOptElem);
if (SUCCEEDED(hr))
{
if (pszValue)
{
_bstr_t bsValue(pszValue);
pNewOptElem->put_value(bsValue);
}
_bstr_t bsText(pszText);
pNewOptElem->put_text(bsText);
pSelElem->add(pNewElem,_variant_t(vtMissing));
pNewOptElem->Release();
if (bSelect)
{
long nLength=0;
pSelElem->get_length(&nLength);
if (nLength > 0)
pSelElem->put_selectedIndex(nLength-1);
}
bRet=true;
}
if (pSelElem)
pSelElem->Release();
return bRet;
}
void CUIHtmlView::GetElement(LPCTSTR pszID,IHTMLElement **pElement)
{
*pElement=NULL;
if (m_pHTMLDocument2 == NULL)
return;
CComQIPtr<IHTMLElementCollection> spAllElements;
m_pHTMLDocument2->get_all(&spAllElements);
if (spAllElements)
{
IDispatch *pDisp=NULL;
HRESULT hr = spAllElements->item(CComVariant(pszID),CComVariant(0),&pDisp);
if (SUCCEEDED(hr))
{
hr = pDisp->QueryInterface(IID_IHTMLElement,(LPVOID*)pElement);
}
pDisp->Release();
}
}
void CUIHtmlView::ParseDocument()
{
if(m_pHTMLDocument2 == NULL)
return;
try
{
CComQIPtr<IHTMLDocument2> spDocument(m_pHTMLDocument2);
CComQIPtr<IHTMLElementCollection> spAllElements;
spDocument->get_all(&spAllElements);
CComBSTR bsIsControl(_T("OBJECT"));
CComBSTR bsIsImage(_T("IMG"));
long nElems;
spAllElements->get_length(&nElems);
for(long i = 0; i < nElems; i++)
{
CComVariant vIndex(i, VT_I4);
LPDISPATCH pDisp=NULL;
spAllElements->item(vIndex,vIndex,&pDisp);
CComQIPtr<IHTMLElement> spAnElement(pDisp);
pDisp->Release();
CComBSTR bsTagName;
spAnElement->get_tagName(&bsTagName);
if(bsTagName == bsIsControl)
{
// This will get you any ActiveX controls in a page. It is possible
// to call methods and properties of the control off the IHTMLElementPtr.
CComQIPtr<IHTMLObjectElement> spObj(spAnElement);
ActiveXControl(spObj);
}
else if(bsTagName == bsIsImage)
{
CComQIPtr<IHTMLImgElement> spImg(spAnElement);
ImageElement(spImg);
}
else
Element(spAnElement);
}
}
catch(...)
{
#ifdef _DEBUG
AfxMessageBox(_T("Unspecified exception thrown in UIHtmlView"),MB_ICONSTOP);
#endif
throw;
}
}
void CUIHtmlView::ActiveXControl(IHTMLObjectElement *pObj)
{
}
void CUIHtmlView::ImageElement(IHTMLImgElement *pImg)
{
}
void CUIHtmlView::Element(IHTMLElement *pElement)
{
}
void CUIHtmlView::DoDataExchange(CDataExchange* pDX)
{
CHtmlView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUIHtmlView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUIHtmlView, CHtmlView)
//{{AFX_MSG_MAP(CUIHtmlView)
ON_WM_SETCURSOR()
ON_COMMAND(ID_BROWSER_GO_BACK, OnBrowserGoBack)
ON_COMMAND(ID_BROWSER_GO_FORWARD, OnBrowserGoForward)
ON_COMMAND(ID_BROWSER_GO_BACK, OnBrowserGoBack)
ON_UPDATE_COMMAND_UI(ID_BROWSER_GO_FORWARD, OnUpdateBrowserGoForward)
ON_UPDATE_COMMAND_UI(ID_BROWSER_GO_BACK, OnUpdateBrowserGoBack)
ON_COMMAND(ID_BROWSER_GO_HOME, OnBrowserGoHome)
ON_COMMAND(ID_BROWSER_REFRESH, OnBrowserRefresh)
ON_COMMAND(ID_BROWSER_STOP, OnBrowserStop)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUIHtmlView diagnostics
#ifdef _DEBUG
void CUIHtmlView::AssertValid() const
{
CHtmlView::AssertValid();
}
void CUIHtmlView::Dump(CDumpContext& dc) const
{
CHtmlView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CUIHtmlView message handlers
void CUIHtmlView::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
// TODO: Add your specialized code here and/or call the base class
HRESULT hr;
LPUNKNOWN lpUnknown;
LPUNKNOWN lpUnknownWB = NULL;
LPUNKNOWN lpUnknownDC = NULL;
lpUnknown = m_wndBrowser.GetControlUnknown();
ASSERT(lpUnknown);
if (lpUnknown)
{
// Get the IUnknown of the WebBrowser control being hosted.
// The IUnknown returned from GetControlUnknown is not the
// IUnknown of the WebBrowser control. It's actually a
// IOleObject pointer.
//
hr = lpUnknown->QueryInterface(IID_IUnknown,
(LPVOID*)&lpUnknownWB);
ASSERT(SUCCEEDED(hr));
if (FAILED(hr))
return;
// Get the IUnknown of the object that fired this event.
//
hr = pDisp->QueryInterface(IID_IUnknown, (LPVOID*)&lpUnknownDC);
ASSERT(SUCCEEDED(hr));
if (SUCCEEDED(hr) && lpUnknownWB == lpUnknownDC)
{
// The document has finished loading.
//
LPDISPATCH pDispatch = GetHtmlDocument();
if (pDispatch)
{
hr = pDispatch->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&m_pHTMLDocument2);
DocumentReady();
pDispatch->Release();
}
}
if (lpUnknownWB)
lpUnknownWB->Release();
if (lpUnknownDC)
lpUnknownDC->Release();
}
}
void CUIHtmlView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel)
{
// TODO: Add your specialized code here and/or call the base class ReleaseDocument();
m_bSetCursor = true;
#ifdef _DEBUG
if (GetKeyState(VK_LCONTROL) < 0)
{
if (baPostedData.GetSize() > 0)
{
LPTSTR pszData = new TCHAR[baPostedData.GetSize()+1];
LPTSTR pszPosted = pszData;
for(int i=0;i < baPostedData.GetSize();i++)
{
*pszPosted = baPostedData[i];
pszPosted =_tcsinc(pszPosted);
}
*pszPosted = '\0';
CString sMess;
sMess = _T("Posted Data: ");
sMess += pszData;
sMess += _T("\n");
sMess += _T("URL: ");
sMess += lpszURL;
AfxMessageBox(sMess);
delete pszData;
}
}
#endif
ReleaseDocument();
if (m_hNotifyWnd)
{
::SendMessage(m_hNotifyWnd,WM_APP_CB_IE_SET_EDIT_TEXT,(WPARAM)lpszURL,0);
}
CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel);
}
BOOL CUIHtmlView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
if (m_bSetCursor)
{
SetCursor(::LoadCursor(NULL,IDC_APPSTARTING));
return TRUE;
}
return CHtmlView::OnSetCursor(pWnd, nHitTest, message);
}
void CUIHtmlView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
}
void CUIHtmlView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
// TODO: Add your specialized code here and/or call the base class
CHtmlView::OnActivateView(bActivate, pActivateView, pDeactiveView);
if (bActivate && pDeactiveView != NULL)
{
OnTitleChange(GetLocationURL());
SetActiveWindow();
}
}
void CUIHtmlView::OnCommandStateChange(long nCommand, BOOL bEnable)
{
// TODO: Add your specialized code here and/or call the base class
switch(nCommand)
{
case CSC_NAVIGATEFORWARD:
m_bGoForward = bEnable;
break;
case CSC_NAVIGATEBACK:
m_bGoBack = bEnable;
break;
default:
break;
}
CHtmlView::OnCommandStateChange(nCommand, bEnable);
}
void CUIHtmlView::OnUpdateBrowserGoBack(CCmdUI *pUI)
{
pUI->Enable(m_bGoBack);
}
void CUIHtmlView::OnUpdateBrowserGoForward(CCmdUI *pUI)
{
pUI->Enable(m_bGoForward);
}
void CUIHtmlView::OnBrowserGoBack()
{
// TODO: Add your command handler code here
GoBack();
}
void CUIHtmlView::OnBrowserGoForward()
{
// TODO: Add your command handler code here
GoForward();
}
void CUIHtmlView::OnBrowserGoHome()
{
// TODO: Add your command handler code here
GoHome();
}
void CUIHtmlView::OnBrowserRefresh()
{
// TODO: Add your command handler code here
Refresh();
}
void CUIHtmlView::OnBrowserStop()
{
// TODO: Add your command handler code here
Stop();
}
void CUIHtmlView::OnDocumentComplete(LPCTSTR lpszUrl)
{
// make sure the main frame has the new URL. This call also stops the animation
if (m_hNotifyWnd)
{
::SendMessage(m_hNotifyWnd,WM_APP_CB_IE_SET_EDIT_TEXT,(WPARAM)lpszUrl,0);
}
CHtmlView::OnDocumentComplete(lpszUrl);
}
void CUIHtmlView::OnTitleChange(LPCTSTR lpszText)
{
// this will change the main frame's title bar
if (m_pDocument != NULL)
m_pDocument->SetTitle(lpszText);
}
@@ -1,173 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// IM_OleImageDropTarget.cpp : implementation file
//
#include "stdafx.h"
#include "UIDragImage.h"
#include "UIImageDropTarget.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUI_ImageDropTarget
CUI_ImageDropTarget::CUI_ImageDropTarget() : m_pImage(NULL),m_pWnd(NULL)
{
m_nCFFormat = ::RegisterClipboardFormat(_T("APP_CF_DD_LISTCTRL_IMAGE"));
m_nImage = -1;
}
CUI_ImageDropTarget::~CUI_ImageDropTarget()
{
}
/////////////////////////////////////////////////
//
// For OLE drag and drop
//
/////////////////////////////////////////////////
void CUI_ImageDropTarget::OnDragLeave( CWnd* pWnd)
{
if (m_pImage == NULL)
return;
// Erase the old drag image and delete the temporary widget.
CClientDC dc(GetImageWin(pWnd));
m_pImage->DrawDragImage (&dc,m_ptOldImage,m_ptItem);
delete m_pImage;
m_pImage = NULL;
COleDropTarget::OnDragLeave(pWnd);
}
DROPEFFECT CUI_ImageDropTarget::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
{
DROPEFFECT dwEffect = COleDropTarget::OnDragEnter(pWnd,pDataObject,dwKeyState,point);
HGLOBAL hData = pDataObject->GetGlobalData(GetClipboardFormat());
if (hData == NULL)
return dwEffect;
//
// Create a temporary image for drag imaging.
//
int *pData = (int*)::GlobalLock(hData);
int nType = *pData++;
int nSelected = *pData++;
DD_ImageData *pImageData = (DD_ImageData*)pData;
CPoint pt = pImageData->m_ptDrag;
int i;
switch (nType)
{
case LVS_ICON:
case LVS_SMALLICON:
case LVS_LIST:
case LVS_REPORT:
m_pImage = new CDragDropImage(nSelected,nType);
for(i=0;i < nSelected;i++)
{
m_pImage->AddItem(&pImageData->m_rcItem,&pImageData->m_rcIcon);
pImageData++;
}
break;
default:
ASSERT(0);
// Just in case
::GlobalUnlock(hData);
return DROPEFFECT_NONE;
}
// total item
CRect rcItem;
pData = (int*)pImageData;
rcItem.left = *pData++;
rcItem.right = *pData++;
rcItem.top = *pData++;
rcItem.bottom = *pData;
::GlobalUnlock(hData);
//
// Begin dragging.
//
CClientDC dc(GetImageWin(pWnd));
pWnd->ClientToScreen(&point);
m_pWnd->ScreenToClient(&point);
dc.DPtoLP(&point);
m_ptItem = pt;
CPoint ptDrag (point.x, point.y);
m_ptOldImage.x = m_ptOldImage.y = -32000;
m_ptPrevPos = point;
return dwEffect;
}
DROPEFFECT CUI_ImageDropTarget::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
{
DROPEFFECT dwEffect = COleDropTarget::OnDragOver(pWnd,pDataObject,dwKeyState,point);
if (!pDataObject->IsDataAvailable(GetClipboardFormat()))
return dwEffect;
// Erase the old drag image and draw a new one if the cursor has moved.
CClientDC dc(GetImageWin(pWnd));
pWnd->ClientToScreen(&point);
m_pWnd->ScreenToClient(&point);
dc.DPtoLP(&point);
if (m_pImage && point != m_ptPrevPos)
{
// erase the old image
m_pImage->DrawDragImage(&dc,m_ptOldImage,m_ptItem);
// CPoint ptDrag (point.x - m_sizeDelta.cx, point.y - m_sizeDelta.cy);
CPoint ptDrag (point.x, point.y);
// draw the new image
m_pImage->DrawDragImage (&dc, ptDrag, m_ptItem);
// save coords
m_ptOldImage = ptDrag;
m_ptPrevPos = point;
}
return dwEffect;
}
BOOL CUI_ImageDropTarget::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
{
BOOL bRet = COleDropTarget::OnDrop(pWnd,pDataObject,dropEffect,point);
if (!pDataObject->IsDataAvailable(GetClipboardFormat()))
return bRet;
//
// Erase the old drag image and delete the temporary widget.
//
CClientDC dc(GetImageWin(pWnd));
if (m_pImage != NULL)
{
m_pImage->DrawDragImage (&dc,m_ptOldImage,m_ptItem);
delete m_pImage;
m_pImage = NULL;
}
return bRet;
}
void CUI_ImageDropTarget::EraseOldImage()
{
if (m_pImage == NULL)
return;
CClientDC dc(GetImageWin(NULL));
m_pImage->DrawDragImage(&dc,m_ptOldImage,m_ptItem);
m_ptOldImage.x = m_ptOldImage.y = -32000;
}
@@ -1,148 +0,0 @@
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: [email protected]>
//*******************************************************************************
// TabClientView.cpp : implementation file
//
#include "stdafx.h"
#include "UIListView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUIListView
IMPLEMENT_DYNAMIC(CUIListView, CView)
CUIListView::CUIListView(UINT nID) : m_nID(nID), m_pListCtrl(NULL)
{
m_Style = WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_SHOWSELALWAYS;
m_bDragDrop = true;
}
CUIListView::~CUIListView()
{
delete m_pListCtrl;
}
CUIODListCtrl &CUIListView::GetListCtrl()
{
ASSERT(m_pListCtrl);
return *m_pListCtrl;
}
void CUIListView::CreateListCtrl()
{
m_pListCtrl = new CUIODListCtrl;
GetListCtrl().SetDragDrop(m_bDragDrop);
}
BEGIN_MESSAGE_MAP(CUIListView, CView)
//{{AFX_MSG_MAP(CUIListView)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_SIZE()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_APP_UPDATE_ALL_VIEWS, OnAppUpdateAllViews)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUIListView drawing
void CUIListView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CUIListView diagnostics
#ifdef _DEBUG
void CUIListView::AssertValid() const
{
CView::AssertValid();
}
void CUIListView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CUIListView message handlers
int CUIListView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CreateListCtrl();
// TODO: Add your specialized creation code here
USES_CONVERSION;
GetListCtrl().SetSection(A2CT(GetRuntimeClass()->m_lpszClassName));
GetListCtrl().ChangeStyle(m_Style);
if (GetListCtrl().Create(m_Style,CRect(0,0,0,0),this,m_nID) == -1)
return -1;
GetListCtrl().Init();
return 0;
}
void CUIListView::OnSetFocus(CWnd* pOldWnd)
{
CView::OnSetFocus(pOldWnd);
// TODO: Add your message handler code here
GetListCtrl().SetFocus();
}
void CUIListView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if (GetListCtrl().GetSafeHwnd())
GetListCtrl().MoveWindow(0,0,cx,cy);
}
LRESULT CUIListView::OnAppUpdateAllViews( WPARAM wParam, LPARAM lParam )
{
ASSERT(wParam);
GetDocument()->UpdateAllViews(NULL,wParam,(CObject*)lParam);
return 1L;
}
BOOL CUIListView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS,
NULL,
NULL,
NULL);
ASSERT(cs.lpszClass);
return CView::PreCreateWindow(cs);
}
@@ -1,726 +0,0 @@
////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// CMenuBar implements menu bar for MFC. See MenuBar.h for how
// to use, and also the MBTest sample application.
//
#include "StdAfx.h"
#include "UIMenuBar.h"
const UINT MB_SET_MENU_NULL = WM_USER + 1100;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// if you want to see extra TRACE diagnostics, set CMenuBar::bTRACE = TRUE
BOOL CMenuBar::bTRACE = FALSE;
#ifdef _DEBUG
#define MBTRACEFN \
CTraceFn __fooble; \
if (CMenuBar::bTRACE)\
TRACE
#define MBTRACE \
if (CMenuBar::bTRACE)\
TRACE
#else
#define MBTRACEFN TRACE
#define MBTRACE TRACE
#endif
IMPLEMENT_DYNAMIC(CMenuBar, CFlatToolBar)
BEGIN_MESSAGE_MAP(CMenuBar, CFlatToolBar)
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_SIZE()
ON_UPDATE_COMMAND_UI_RANGE(0, 256, OnUpdateMenuButton)
ON_MESSAGE(MB_SET_MENU_NULL, OnSetMenuNull)
END_MESSAGE_MAP()
CMenuBar::CMenuBar()
{
if (iVerComCtl32 <= 470)
AfxMessageBox(_T("Warning: This program requires comctl32.dll version 4.71 or greater."));
m_iTrackingState = TRACK_NONE; // initial state: not tracking
m_iPopupTracking = m_iNewPopup = -1; // invalid
m_hmenu = NULL;
m_hMenuTracking = NULL;
m_bAutoRemoveFrameMenu = TRUE; // set frame's menu to NULL
}
CMenuBar::~CMenuBar()
{
}
//////////////////
// Menu bar was created: install hook into owner window
//
int CMenuBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFlatToolBar::OnCreate(lpCreateStruct)==-1)
return -1;
UpdateFont();
CWnd* pFrame = GetOwner();
ASSERT_VALID(pFrame);
m_frameHook.Install(this, *pFrame);
return 0; // OK
}
//////////////////
// Set menu bar font from current system menu font
//
void CMenuBar::UpdateFont()
{
static CFont font;
NONCLIENTMETRICS info;
info.cbSize = sizeof(info);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0);
if ((HFONT)font)
font.DeleteObject();
VERIFY(font.CreateFontIndirect(&info.lfMenuFont));
SetFont(&font);
}
//////////////////
// The reason for having this is so MFC won't automatically disable
// the menu buttons. Assumes < 256 top-level menu items. The ID of
// the ith menu button is i. IOW, the index and ID are the same.
//
void CMenuBar::OnUpdateMenuButton(CCmdUI* pCmdUI)
{
ASSERT_VALID(this);
if (IsValidButton(pCmdUI->m_nID))
pCmdUI->Enable(TRUE);
}
//////////////////
// Recompute layout of menu bar
//
void CMenuBar::RecomputeMenuLayout()
{
SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}
//////////////////
// Make frame recalculate control bar sizes after menu change
//
void CMenuBar::RecomputeToolbarSize()
{
// Force toolbar to recompute size
CFrameWnd* pFrame = (CFrameWnd*)GetOwner();
ASSERT_VALID(pFrame);
ASSERT(pFrame->IsFrameWnd());
pFrame->RecalcLayout();
// floating frame
pFrame = GetParentFrame();
if (pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)))
pFrame->RecalcLayout();
}
//////////////////
// Set tracking state: none, button, or popup
//
void CMenuBar::SetTrackingState(TRACKINGSTATE iState, int iButton)
{
ASSERT_VALID(this);
if (iState != m_iTrackingState) {
if (iState == TRACK_NONE)
iButton = -1;
#ifdef _DEBUG
static LPCTSTR StateName[] = { _T("NONE"), _T("BUTTON"), _T("POPUP") };
MBTRACE(_T("CMenuBar::SetTrackingState to %s, button=%d\n"),
StateName[iState], iButton);
#endif
SetHotItem(iButton); // could be none (-1)
if (iState==TRACK_POPUP) {
// set related state stuff
m_bEscapeWasPressed = FALSE; // assume Esc key not pressed
m_bProcessRightArrow = // assume left/right arrow..
m_bProcessLeftArrow = TRUE; // ..will move to prev/next popup
m_iPopupTracking = iButton; // which popup I'm tracking
}
m_iTrackingState = iState;
}
}
//////////////////
// Toggle state from home state to button-tracking and back
//
void CMenuBar::ToggleTrackButtonMode()
{
ASSERT_VALID(this);
if (m_iTrackingState == TRACK_NONE || m_iTrackingState == TRACK_BUTTON) {
SetTrackingState(m_iTrackingState == TRACK_NONE ?
TRACK_BUTTON : TRACK_NONE, 0);
}
}
//////////////////
// Get button index before/after a given button
//
int CMenuBar::GetNextOrPrevButton(int iButton, BOOL bPrev)
{
ASSERT_VALID(this);
if (bPrev) {
iButton--;
if (iButton <0)
iButton = GetButtonCount() - 1;
} else {
iButton++;
if (iButton >= GetButtonCount())
iButton = 0;
}
return iButton;
}
/////////////////
// This is to correct a bug in the system toolbar control: TB_HITTEST only
// looks at the buttons, not the size of the window. So it returns a button
// hit even if that button is totally outside the size of the window!
//
int CMenuBar::HitTest(CPoint p) const
{
int iHit = CFlatToolBar::HitTest(p);
if (iHit>0) {
CRect rc;
GetClientRect(&rc);
if (!rc.PtInRect(p)) // if point is outside window
iHit = -1; // can't be a hit!
}
return iHit;
}
//////////////////
// Load a different menu. The HMENU must not belong to any CMenu,
// and you must free it when you're done. Returns old menu.
//
HMENU CMenuBar::LoadMenu(HMENU hmenu)
{
UINT iPrevID=(UINT)-1;
ASSERT(::IsMenu(hmenu));
ASSERT_VALID(this);
if (m_bAutoRemoveFrameMenu) {
CFrameWnd* pFrame = GetParentFrame();
if (::GetMenu(*pFrame)!=NULL) {
// I would like to set the frame's menu to NULL now, but if I do, MFC
// gets all upset: it calls GetMenu and expects to have a real menu.
// So Instead, I post a message to myself. Because the message is
// posted, not sent, I won't process it until MFC is done with all its
// initialization stuff. (MFC needs to set CFrameWnd::m_hMenuDefault
// to the menu, which it gets by calling GetMenu.)
//
PostMessage(MB_SET_MENU_NULL, (WPARAM)pFrame->GetSafeHwnd());
}
}
HMENU hOldMenu = m_hmenu;
m_hmenu = hmenu;
// delete existing buttons
int nCount = GetButtonCount();
while (nCount--) {
VERIFY(DeleteButton(0));
}
SetImageList(NULL);
// SetButtonSize(CSize(0,0)); // This barfs in VC 6.0
DWORD dwStyle = GetStyle();
BOOL bModifyStyle = ModifyStyle(0, TBSTYLE_FLAT|TBSTYLE_TRANSPARENT);
// add text buttons
UINT nMenuItems = hmenu ? ::GetMenuItemCount(hmenu) : 0;
for (UINT i=0; i < nMenuItems; i++) {
TCHAR name[64];
memset(name, 0, sizeof(name)); // guarantees double-0 at end
if (::GetMenuString(hmenu, i, name, countof(name)-1, MF_BYPOSITION)) {
TBBUTTON tbb;
memset(&tbb, 0, sizeof(tbb));
tbb.idCommand = ::GetMenuItemID(hmenu, i);
// Because the toolbar is too brain-damaged to know if it already has
// a string, and is also too brain-dead to even let you delete strings,
// I have to determine if each string has been added already. Otherwise
// in a MDI app, as the menus are repeatedly switched between doc and
// no-doc menus, I will keep adding strings until somebody runs out of
// memory. Sheesh!
//
int iString = -1;
for (int j=0; j<m_arStrings.GetSize(); j++) {
if (m_arStrings[j] == name) {
iString = j; // found it
break;
}
}
if (iString <0) {
// string not found: add it
iString = AddStrings(name);
m_arStrings.SetAtGrow(iString, name);
}
tbb.iString = iString;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_AUTOSIZE;
tbb.iBitmap = -1;
tbb.idCommand = i;
VERIFY(AddButtons(1, &tbb));
}
}
if (bModifyStyle)
SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
if (hmenu) {
AutoSize(); // size buttons
RecomputeToolbarSize(); // and menubar itself
}
return hOldMenu;
}
//////////////////
// Load menu from resource
//
HMENU CMenuBar::LoadMenu(LPCTSTR lpszMenuName)
{
return LoadMenu(::LoadMenu(AfxFindResourceHandle(lpszMenuName,RT_MENU),lpszMenuName));
}
//////////////////
// Set the frame's menu to NULL. WPARAM is HWND of frame.
//
LRESULT CMenuBar::OnSetMenuNull(WPARAM wp, LPARAM lp)
{
HWND hwnd = (HWND)wp;
ASSERT(::IsWindow(hwnd));
::SetMenu(hwnd, NULL);
return 0;
}
//////////////////
// Handle mouse click: if clicked on button, press it
// and go into main menu loop.
//
void CMenuBar::OnLButtonDown(UINT nFlags, CPoint pt)
{
ASSERT_VALID(this);
int iButton = HitTest(pt);
if (iButton >= 0 && iButton<GetButtonCount()) // if mouse is over a button:
TrackPopup(iButton); // track it
else // otherwise:
CFlatToolBar::OnLButtonDown(nFlags, pt); // pass it on...
}
//////////////////
// Handle mouse movement
//
void CMenuBar::OnMouseMove(UINT nFlags, CPoint pt)
{
ASSERT_VALID(this);
if (m_iTrackingState==TRACK_BUTTON) {
// In button-tracking state, ignore mouse-over to non-button area.
// Normally, the toolbar would de-select the hot item in this case.
//
// Only change the hot item if the mouse has actually moved.
// This is necessary to avoid a bug where the user moves to a different
// button from the one the mouse is over, and presses arrow-down to get
// the menu, then Esc to cancel it. Without this code, the button will
// jump to wherever the mouse is--not right.
int iHot = HitTest(pt);
if (IsValidButton(iHot) && pt != m_ptMouse)
SetHotItem(iHot);
return; // don't let toolbar get it
}
m_ptMouse = pt; // remember point
CFlatToolBar::OnMouseMove(nFlags, pt);
}
//////////////////
// Window was resized: need to recompute layout
//
void CMenuBar::OnSize(UINT nType, int cx, int cy)
{
CFlatToolBar::OnSize(nType, cx, cy);
RecomputeMenuLayout();
}
//////////////////
// Bar style changed: eg, moved from left to right dock or floating
//
void CMenuBar::OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle)
{
CFlatToolBar::OnBarStyleChange(dwOldStyle, dwNewStyle);
RecomputeMenuLayout();
}
/////////////////
// When user selects a new menu item, note whether it has a submenu
// and/or parent menu, so I know whether right/left arrow should
// move to the next popup.
//
void CMenuBar::OnMenuSelect(HMENU hmenu, UINT iItem)
{
if (m_iTrackingState > 0) {
// process right-arrow iff item is NOT a submenu
m_bProcessRightArrow = (::GetSubMenu(hmenu, iItem) == NULL);
// process left-arrow iff curent menu is one I'm tracking
m_bProcessLeftArrow = hmenu==m_hMenuTracking;
}
}
// globals--yuk! But no other way using windows hooks.
//
static CMenuBar* g_pMenuBar = NULL;
static HHOOK g_hMsgHook = NULL;
////////////////
// Menu filter hook just passes to virtual CMenuBar function
//
LRESULT CALLBACK
CMenuBar::MenuInputFilter(int code, WPARAM wp, LPARAM lp)
{
return (code==MSGF_MENU && g_pMenuBar &&
g_pMenuBar->OnMenuInput(*((MSG*)lp))) ? TRUE
: CallNextHookEx(g_hMsgHook, code, wp, lp);
}
//////////////////
// Handle menu input event: Look for left/right to change popup menu,
// mouse movement over over a different menu button for "hot" popup effect.
// Returns TRUE if message handled (to eat it).
//
BOOL CMenuBar::OnMenuInput(MSG& m)
{
ASSERT_VALID(this);
ASSERT(m_iTrackingState == TRACK_POPUP); // sanity check
int msg = m.message;
if (msg==WM_KEYDOWN) {
// handle left/right-arow.
TCHAR vkey = m.wParam;
if (vkey == VK_LEFT)
MBTRACE(_T("CMenuBar::OnMenuInput: handle VK_LEFT - m_bProcessLeftArrow=%d\n"),m_bProcessLeftArrow);
else if (vkey == VK_RIGHT)
MBTRACE(_T("CMenuBar::OnMenuInput: handle RIGHT - m_bProcessRightArrow=%d\n"),m_bProcessRightArrow);
if ((vkey == VK_LEFT && m_bProcessLeftArrow) ||
(vkey == VK_RIGHT && m_bProcessRightArrow)) {
CancelMenuAndTrackNewOne(
GetNextOrPrevButton(m_iPopupTracking, vkey==VK_LEFT));
return TRUE; // eat it
} else if (vkey == VK_ESCAPE) {
m_bEscapeWasPressed = TRUE; // (menu will abort itself)
}
} else if (msg==WM_MOUSEMOVE || msg==WM_LBUTTONDOWN) {
// handle mouse move or click
CPoint pt = m.lParam;
ScreenToClient(&pt);
if (msg == WM_MOUSEMOVE) {
if (pt != m_ptMouse) {
int iButton = HitTest(pt);
if (IsValidButton(iButton) && iButton != m_iPopupTracking) {
// user moved mouse over a different button: track its popup
CancelMenuAndTrackNewOne(iButton);
}
m_ptMouse = pt;
}
} else if (msg == WM_LBUTTONDOWN) {
if (HitTest(pt) == m_iPopupTracking) {
// user clicked on same button I am tracking: cancel menu
MBTRACE(_T("CMenuBar:OnMenuInput: handle mouse click to exit popup\n"));
CancelMenuAndTrackNewOne(-1);
return TRUE; // eat it
}
}
}
return FALSE; // not handled
}
//////////////////
// Cancel the current popup menu by posting WM_CANCELMODE, and track a new
// menu. iNewPopup is which new popup to track (-1 to quit).
//
void CMenuBar::CancelMenuAndTrackNewOne(int iNewPopup)
{
MBTRACE(_T("CMenuBar::CancelMenuAndTrackNewOne: %d\n"), iNewPopup);
ASSERT_VALID(this);
if (iNewPopup != m_iPopupTracking) {
GetOwner()->PostMessage(WM_CANCELMODE); // quit menu loop
m_iNewPopup = iNewPopup; // go to this popup (-1 = quit)
}
}
//////////////////
// Track the popup submenu associated with the i'th button in the menu bar.
// This fn actually goes into a loop, tracking different menus until the user
// selects a command or exits the menu.
//
void CMenuBar::TrackPopup(int iButton)
{
MBTRACE(_T("CMenuBar::TrackPopup %d\n"), iButton);
ASSERT_VALID(this);
ASSERT(m_hmenu);
CMenu menu;
menu.Attach(m_hmenu);
int nMenuItems = menu.GetMenuItemCount();
while (iButton >= 0) { // while user selects another menu
m_iNewPopup = -1; // assume quit after this
PressButton(iButton, TRUE); // press the button
UpdateWindow(); // and force repaint now
// post a simulated arrow-down into the message stream
// so TrackPopupMenu will read it and move to the first item
GetOwner()->PostMessage(WM_KEYDOWN, VK_DOWN, 1);
GetOwner()->PostMessage(WM_KEYUP, VK_DOWN, 1);
SetTrackingState(TRACK_POPUP, iButton); // enter tracking state
// Need to install a hook to trap menu input in order to make
// left/right-arrow keys and "hot" mouse tracking work.
//
ASSERT(g_pMenuBar == NULL);
g_pMenuBar = this;
ASSERT(g_hMsgHook == NULL);
g_hMsgHook = SetWindowsHookEx(WH_MSGFILTER,
MenuInputFilter, NULL, ::GetCurrentThreadId());
// get submenu and display it beneath button
TPMPARAMS tpm;
CRect rcButton;
GetRect(iButton, rcButton);
ClientToScreen(&rcButton);
CPoint pt = ComputeMenuTrackPoint(rcButton, tpm);
HMENU hMenuPopup = ::GetSubMenu(m_hmenu, iButton);
ASSERT(hMenuPopup);
m_hMenuTracking = hMenuPopup;
BOOL bRet = TrackPopupMenuEx(hMenuPopup,
TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,
pt.x, pt.y, GetOwner()->GetSafeHwnd(), &tpm);
// uninstall hook.
::UnhookWindowsHookEx(g_hMsgHook);
g_hMsgHook = NULL;
g_pMenuBar = NULL;
PressButton(iButton, FALSE); // un-press button
UpdateWindow(); // and force repaint now
// If the user exited the menu loop by pressing Escape,
// return to track-button state; otherwise normal non-tracking state.
SetTrackingState(m_bEscapeWasPressed ?
TRACK_BUTTON : TRACK_NONE, iButton);
// If the user moved mouse to a new top-level popup (eg from File to
// Edit button), I will have posted a WM_CANCELMODE to quit
// the first popup, and set m_iNewPopup to the new menu to show.
// Otherwise, m_iNewPopup will be -1 as set above.
// So just set iButton to the next popup menu and keep looping...
iButton = m_iNewPopup;
}
menu.Detach();
m_hMenuTracking = m_hmenu;
}
//////////////////
// Given button rectangle, compute point and "exclude rect" for
// TrackPopupMenu, based on current docking style, so that the menu will
// appear always inside the window.
//
CPoint CMenuBar::ComputeMenuTrackPoint(const CRect& rcButn, TPMPARAMS& tpm)
{
tpm.cbSize = sizeof(tpm);
DWORD dwStyle = m_dwStyle;
CPoint pt;
CRect& rcExclude = (CRect&)tpm.rcExclude;
rcExclude = rcButn;
::GetWindowRect(::GetDesktopWindow(), &rcExclude);
switch (dwStyle & CBRS_ALIGN_ANY) {
case CBRS_ALIGN_BOTTOM:
pt = CPoint(rcButn.left, rcButn.top);
rcExclude.top = rcButn.top;
break;
case CBRS_ALIGN_LEFT:
pt = CPoint(rcButn.right, rcButn.top);
rcExclude.right = rcButn.right;
break;
case CBRS_ALIGN_RIGHT:
pt = CPoint(rcButn.left, rcButn.top);
rcExclude.left = rcButn.left;
break;
default: // case CBRS_ALIGN_TOP:
pt = CPoint(rcButn.left, rcButn.bottom);
break;
}
return pt;
}
//////////////////
// This function translates special menu keys and mouse actions.
// You must call it from your frame's PreTranslateMessage.
//
BOOL CMenuBar::TranslateFrameMessage(MSG* pMsg)
{
ASSERT_VALID(this);
ASSERT(pMsg);
UINT msg = pMsg->message;
if (WM_LBUTTONDOWN <= msg && msg <= WM_MOUSELAST) {
if (pMsg->hwnd != m_hWnd && m_iTrackingState > 0) {
// user clicked outside menu bar: exit tracking mode
MBTRACE(_T("CMenuBar::TranslateFrameMessage: user clicked outside menu bar: end tracking\n"));
SetTrackingState(TRACK_NONE);
}
} else if (msg==WM_SYSKEYDOWN || msg==WM_SYSKEYUP || msg==WM_KEYDOWN) {
BOOL bAlt = HIWORD(pMsg->lParam) & KF_ALTDOWN; // Alt key down
TCHAR vkey = pMsg->wParam; // get virt key
if (vkey==VK_MENU ||
(vkey==VK_F10 && !((GetKeyState(VK_SHIFT) & 0x80000000) ||
(GetKeyState(VK_CONTROL) & 0x80000000) || bAlt))) {
// key is VK_MENU or F10 with no alt/ctrl/shift: toggle menu mode
if (msg==WM_SYSKEYUP) {
MBTRACE(_T("CMenuBar::TranslateFrameMessage: handle menu key\n"));
ToggleTrackButtonMode();
}
return TRUE;
} else if ((msg==WM_SYSKEYDOWN || msg==WM_KEYDOWN)) {
if (m_iTrackingState == TRACK_BUTTON) {
// I am tracking: handle left/right/up/down/space/Esc
switch (vkey) {
case VK_LEFT:
case VK_RIGHT:
// left or right-arrow: change hot button if tracking buttons
MBTRACE(_T("CMenuBar::TranslateFrameMessage: VK_LEFT/RIGHT\n"));
SetHotItem(GetNextOrPrevButton(GetHotItem(), vkey==VK_LEFT));
return TRUE;
case VK_SPACE: // (personally, I like SPACE to enter menu too)
case VK_UP:
case VK_DOWN:
// up or down-arrow: move into current menu, if any
MBTRACE(_T("CMenuBar::TranslateFrameMessage: VK_UP/DOWN/SPACE\n"));
TrackPopup(GetHotItem());
return TRUE;
case VK_ESCAPE:
// escape key: exit tracking mode
MBTRACE(_T("CMenuBar::TranslateFrameMessage: VK_ESCAPE\n"));
SetTrackingState(TRACK_NONE);
return TRUE;
}
}
// Handle alphanumeric key: invoke menu. Note that Alt-X
// chars come through as WM_SYSKEYDOWN, plain X as WM_KEYDOWN.
if ((bAlt || m_iTrackingState == TRACK_BUTTON) && isalnum(vkey)) {
// Alt-X, or else X while in tracking mode
UINT nID;
if (MapAccelerator(vkey, nID)) {
MBTRACE(_T("CMenuBar::TranslateFrameMessage: map acclerator\n"));
TrackPopup(nID); // found menu mnemonic: track it
return TRUE; // handled
} else if (m_iTrackingState==TRACK_BUTTON && !bAlt) {
MessageBeep(0);
return TRUE;
}
}
// Default for any key not handled so far: return to no-menu state
if (m_iTrackingState > 0) {
MBTRACE(_T("CMenuBar::TranslateFrameMessage: unknown key, stop tracking\n"));
SetTrackingState(TRACK_NONE);
}
}
}
return FALSE; // not handled, pass along
}
#ifdef _DEBUG
void CMenuBar::AssertValid() const
{
CFlatToolBar::AssertValid();
ASSERT(m_hmenu==NULL || ::IsMenu(m_hmenu));
ASSERT(TRACK_NONE<=m_iTrackingState && m_iTrackingState<=TRACK_POPUP);
m_frameHook.AssertValid();
}
void CMenuBar::Dump(CDumpContext& dc) const
{
CFlatToolBar::Dump(dc);
}
#endif
//////////////////////////////////////////////////////////////////
// CMenuBarFrameHook is used to trap menu-related messages sent to the owning
// frame. The same class is also used to trap messages sent to the MDI client
// window in an MDI app. I should really use two classes for this,
// but it uses less code to chare the same class. Note however: there
// are two different INSTANCES of CMenuBarFrameHook in CMenuBar: one for
// the frame and one for the MDI client window.
//
CMenuBarFrameHook::CMenuBarFrameHook()
{
}
CMenuBarFrameHook::~CMenuBarFrameHook()
{
HookWindow((HWND)NULL); // (unhook)
}
//////////////////
// Install hook to trap window messages sent to frame or MDI client.
//
BOOL CMenuBarFrameHook::Install(CMenuBar* pMenuBar, HWND hWndToHook)
{
ASSERT_VALID(pMenuBar);
m_pMenuBar = pMenuBar;
return HookWindow(hWndToHook);
}
//////////////////////////////////////////////////////////////////
// Trap frame/MDI client messages specific to menubar.
//
LRESULT CMenuBarFrameHook::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
{
CMenuBar& mb = *m_pMenuBar;
switch (msg) {
// The following messages are trapped for the frame window
case WM_SYSCOLORCHANGE:
mb.UpdateFont();
break;
case WM_MENUSELECT:
mb.OnMenuSelect((HMENU)lp, (UINT)LOWORD(wp));
break;
}
return CSubclassWnd::WindowProc(msg, wp, lp);
}
@@ -1,141 +0,0 @@
////////////////////////////////////////////////////////////////
// 1998 Microsoft Systems Journal
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// CModuleVersion provides an easy way to get version info
// for a module.(DLL or EXE).
//
#include "StdAfx.h"
#include "UIModulVer.h"
CModuleVersion::CModuleVersion()
{
m_pVersionInfo = NULL; // raw version info data
}
//////////////////
// Destroy: delete version info
//
CModuleVersion::~CModuleVersion()
{
delete [] m_pVersionInfo;
}
//////////////////
// Get file version info for a given module
// Allocates storage for all info, fills "this" with
// VS_FIXEDFILEINFO, and sets codepage.
//
BOOL CModuleVersion::GetFileVersionInfo(LPCTSTR modulename)
{
m_translation.charset = 1252; // default = ANSI code page
memset((VS_FIXEDFILEINFO*)this, 0, sizeof(VS_FIXEDFILEINFO));
CLoadLibrary lib(modulename);
// get module handle
TCHAR filename[_MAX_PATH];
HMODULE hModule = ::GetModuleHandle(modulename);
if (hModule==NULL && modulename!=NULL)
return FALSE;
// get module file name
DWORD len = GetModuleFileName(hModule, filename,
sizeof(filename)/sizeof(filename[0]));
if (len <= 0)
return FALSE;
// read file version info
DWORD dwDummyHandle; // will always be set to zero
len = GetFileVersionInfoSize(filename, &dwDummyHandle);
if (len <= 0)
return FALSE;
if (m_pVersionInfo)
delete m_pVersionInfo;
m_pVersionInfo = new BYTE[len]; // allocate version info
if (!::GetFileVersionInfo(filename, 0, len, m_pVersionInfo))
return FALSE;
LPVOID lpvi;
UINT iLen;
if (!VerQueryValue(m_pVersionInfo, _T("\\"), &lpvi, &iLen))
return FALSE;
// copy fixed info to myself, which am derived from VS_FIXEDFILEINFO
*(VS_FIXEDFILEINFO*)this = *(VS_FIXEDFILEINFO*)lpvi;
// Get translation info
// Note: VerQueryValue could return a value > 4, in which case
// mulitple languages are supported and VerQueryValue returns an
// array of langID/codepage pairs and you have to decide which to use.
if (VerQueryValue(m_pVersionInfo,
_T("\\VarFileInfo\\Translation"), &lpvi, &iLen) && iLen >= 4) {
m_translation = *(TRANSLATION*)lpvi;
TRACE1("code page = %d\n", m_translation.charset);
}
return dwSignature == VS_FFI_SIGNATURE;
}
//////////////////
// Get string file info.
// Key name is something like "CompanyName".
// returns the value as a CString.
//
CString CModuleVersion::GetValue(LPCTSTR lpKeyName)
{
CString sVal;
if (m_pVersionInfo) {
// To get a string value must pass query in the form
//
// "\StringFileInfo\<langID><codepage>\keyname"
//
// where <lang-codepage> is the languageID concatenated with the
// code page, in hex. Wow.
//
CString query;
query.Format(_T("\\StringFileInfo\\%04x%04x\\%s"),
m_translation.langID,
m_translation.charset,
lpKeyName);
LPCTSTR pVal;
UINT iLenVal;
if (VerQueryValue(m_pVersionInfo, (LPTSTR)(LPCTSTR)query,
(LPVOID*)&pVal, &iLenVal)) {
sVal = pVal;
}
}
return sVal;
}
// typedef for DllGetVersion proc
typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
/////////////////
// Get DLL Version by calling DLL's DllGetVersion proc
//
BOOL CModuleVersion::DllGetVersion(LPCTSTR modulename, DLLVERSIONINFO& dvi)
{
CLoadLibrary lib(modulename);
if (!lib)
return FALSE;
// Must use GetProcAddress because the DLL might not implement
// DllGetVersion. Depending upon the DLL, the lack of implementation of the
// function may be a version marker in itself.
//
DLLGETVERSIONPROC pDllGetVersion =
(DLLGETVERSIONPROC)GetProcAddress(lib, "DllGetVersion");
if (!pDllGetVersion)
return FALSE;
memset(&dvi, 0, sizeof(dvi)); // clear
dvi.cbSize = sizeof(dvi); // set size for Windows
return SUCCEEDED((*pDllGetVersion)(&dvi));
}

Some files were not shown because too many files have changed in this diff Show More