1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 // FileListBox.cpp : implementation file
29 #include "FileListBox.h"
30 #include "TestToolRes.h" // main symbols
35 static char THIS_FILE[] = __FILE__;
38 /////////////////////////////////////////////////////////////////////////////
41 CFileListBox::CFileListBox()
45 CFileListBox::~CFileListBox()
50 BEGIN_MESSAGE_MAP(CFileListBox, CCheckListBox)
51 //{{AFX_MSG_MAP(CFileListBox)
53 ON_COMMAND(IDC_TT_REMOVE, OnRemove)
54 ON_COMMAND(IDC_TT_ADD, OnAdd)
59 /////////////////////////////////////////////////////////////////////////////
60 // CFileListBox message handlers
62 void CFileListBox::OnContextMenu(CWnd* pWnd, CPoint point)
66 menu.LoadMenu(IDR_TT_CONTEXTMENU);
67 CMenu *pPopup=menu.GetSubMenu(0);
69 ScreenToClient(&point);
71 m_nIndex=ItemFromPoint(point,bOutside);
73 GetItemRect(m_nIndex,rect);
74 if(bOutside || !rect.PtInRect(point)){
75 pPopup->EnableMenuItem(IDC_TT_REMOVE,MF_BYCOMMAND|MF_GRAYED);
77 ClientToScreen(&point);
79 for(int i=0;i<GetCount();i++){
85 pPopup->EnableMenuItem(IDC_TT_REMOVE,MF_BYCOMMAND|MF_GRAYED);
88 pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x,point.y,this);
91 void CFileListBox::OnRemove()
93 bool *arb=new bool[GetCount()];
94 for(int i=0;i<GetCount();i++){
97 for(i=GetCount()-1;i>=0;--i){
105 void CFileListBox::OnAdd()
107 GetParent()->SendMessage(WM_COMMAND,IDC_TT_ADD,0);
110 void CFileListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
112 if(VK_DELETE==nChar){
113 SendMessage(WM_COMMAND,IDC_TT_REMOVE,0);
115 CCheckListBox::OnKeyDown(nChar, nRepCnt, nFlags);