root/trunk/FileHistoryDlg.cpp

Revision 5, 2.8 kB (checked in by qbert, 6 years ago)

Initial ( and last :( ) commit

Line 
1 // FileHistoryDlg.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "Elephant.h"
6 #include "FileHistoryDlg.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CFileHistoryDlg dialog
16
17
18 CFileHistoryDlg::CFileHistoryDlg(CWnd* pParent /*=NULL*/)
19     : CDialog(CFileHistoryDlg::IDD, pParent)
20 {
21     //{{AFX_DATA_INIT(CFileHistoryDlg)
22     //}}AFX_DATA_INIT
23 }
24
25
26 void CFileHistoryDlg::DoDataExchange(CDataExchange* pDX)
27 {
28     CDialog::DoDataExchange(pDX);
29     //{{AFX_DATA_MAP(CFileHistoryDlg)
30     DDX_Control(pDX, IDC_COMBO1, m_fileCombo);
31     DDX_Control(pDX, IDC_LIST1, m_fileHistoryList);
32     //}}AFX_DATA_MAP
33 }
34
35
36 BEGIN_MESSAGE_MAP(CFileHistoryDlg, CDialog)
37     //{{AFX_MSG_MAP(CFileHistoryDlg)
38     ON_WM_SIZE()
39     ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
40     //}}AFX_MSG_MAP
41 END_MESSAGE_MAP()
42
43 /////////////////////////////////////////////////////////////////////////////
44 // CFileHistoryDlg message handlers
45
46 BOOL CFileHistoryDlg::OnInitDialog()
47 {
48     CDialog::OnInitDialog();
49    
50     m_fileHistoryList.InsertColumn(0,"File History",LVCFMT_LEFT,200);
51
52     if ( !m_imageList.Create( 16, 16, ILC_COLOR24 | ILC_MASK, 1, 1 ) )
53     {
54         TRACE0("Failed to create image list.\n");
55         return -1;
56     }
57    
58     m_bitmap.LoadBitmap( IDB_IMGLIST_VIEW );
59     m_imageList.Add( &m_bitmap, RGB( 0x00,0xff,0x00 ) );
60
61     m_fileCombo.SetImageList( &m_imageList );
62     m_fileCombo.SetColumnCount(0);
63     m_fileCombo.SetColumnWidth(0,100);
64
65     m_fileHistoryList.SetImageList(&m_imageList,LVSIL_NORMAL);
66    
67     // TODO: Add extra initialization here
68    
69     return TRUE;  // return TRUE unless you set the focus to a control
70                   // EXCEPTION: OCX Property Pages should return FALSE
71 }
72
73 void CFileHistoryDlg::OnSize(UINT nType, int cx, int cy)
74 {
75     CDialog::OnSize(nType, cx, cy);
76    
77     m_fileHistoryList.SetColumnWidth(0,cx);
78
79     m_fileCombo.MoveWindow(0,0,cx,cy); 
80     CRect rect;
81     m_fileCombo.GetClientRect(&rect);
82     m_fileHistoryList.MoveWindow(0,(rect.bottom - rect.top) + 5 ,cx ,cy - ( (rect.bottom - rect.top)  + 5 )  );         // TODO: Add your message handler code here
83    
84 }
85
86 BOOL CFileHistoryDlg::PreTranslateMessage(MSG* pMsg)
87 {
88     return  Globals::theApp.m_pMainWnd->PreTranslateMessage(pMsg);
89    
90     //return CDialog::PreTranslateMessage(pMsg);
91 }
92
93 void CFileHistoryDlg::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
94 {
95     CMainFrame* m = static_cast<CMainFrame*>(Globals::theApp.m_pMainWnd);
96
97     POSITION pos = m_fileHistoryList.GetFirstSelectedItemPosition();
98     if ( pos == NULL ) return;
99     int sel = m_fileHistoryList.GetNextSelectedItem(pos);
100    
101     CString item = m_fileHistoryList.GetItemText(sel,0);
102    
103     //AfxMessageBox(item);
104
105     Globals::theApp.OpenFile(item.GetBuffer(0));
106    
107    
108     *pResult = 0;
109 }
Note: See TracBrowser for help on using the browser.