root/trunk/FileComboBox.cpp

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

Initial ( and last :( ) commit

Line 
1 // FileComboBox.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "Elephant.h"
6 #include "FileComboBox.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 // CFileComboBox
16
17 CFileComboBox::CFileComboBox()
18 {
19 }
20
21 CFileComboBox::~CFileComboBox()
22 {
23 }
24
25
26 BEGIN_MESSAGE_MAP(CFileComboBox, CComboBoxSuper)
27     //{{AFX_MSG_MAP(CFileComboBox)
28     ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
29     ON_WM_KEYUP()
30     //}}AFX_MSG_MAP
31 END_MESSAGE_MAP()
32
33 /////////////////////////////////////////////////////////////////////////////
34 // CFileComboBox message handlers
35
36 void CFileComboBox::OnSelchange()
37 {
38     CMainFrame* m = static_cast<CMainFrame*>(Globals::theApp.m_pMainWnd);
39
40    
41     int sel = GetCurSel();
42     CString item;
43     GetLBText(sel,item );
44     if ( item == "All Open Files")
45     {
46
47
48         DeleteString(sel);
49         SetCurSel(0);
50
51     }
52    
53     CDocument* doc = (CDocument*)GetItemData(sel);
54     if ( doc) {
55    
56         //CDocument* doc = (CDocument*)m->m_wndTabDockBar.m_fileHistory.m_fileHistoryList.GetItemData(found);
57        
58         if ( !doc ) return;
59         POSITION viewPos = doc->GetFirstViewPosition();
60         CView* v = doc->GetNextView(viewPos);
61         m->MDIActivate(v->GetParent());
62     }
63
64 }
65
66 void CFileComboBox::RemoveFile(CDocument * d )
67 {
68     int count  = GetCount();
69
70     CString title = d->GetTitle();
71     title = StripModifyStar(title).c_str();
72
73     for ( int i = 0 ; i < count;i++ )
74     {
75         CString item;
76         GetLBText(i,item );
77
78         if ( item == title )
79         {
80             DeleteString(i);
81         }
82        
83     }
84
85
86
87 }
88
89 void CFileComboBox::AddFile(CDocument * d )
90 {
91     int count  = GetCount();
92
93     CString title = d->GetTitle();
94     title = StripModifyStar(title).c_str();
95
96     bool inserted = false;
97
98     for ( int i = 0 ; i < count;i++ )
99     {
100         CString item;
101         GetLBText(i,item );
102
103         if ( item == title )
104         {
105             return;
106         }
107        
108     }
109
110     if ( !inserted )
111     {
112
113         InsertString(count,title);
114         SetItemImage(count,0 );
115         SetItemData(count,(DWORD)d);
116
117     }
118
119 }
Note: See TracBrowser for help on using the browser.