home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
recent
/
recent.exe
/
FilesDlg.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-04-13
|
1KB
|
67 lines
#include "stdafx.h"
#include "FilesDlg.h"
FilesDlg::FilesDlg(const TCHAR* initTitle) :
title(initTitle)
{
}
FilesDlg::~FilesDlg()
{
}
LRESULT FilesDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CWindow listBox(GetDlgItem(IDC_LIST));
for(list<tstring>::iterator it = files.begin(); it != files.end(); ++it)
listBox.SendMessage(LB_ADDSTRING, 0, reinterpret_cast<LPARAM>((*it).data()));
listBox.SendMessage(LB_SETCURSEL, 0);
SetWindowText(title.data());
CenterWindow();
return 1;
}
LRESULT FilesDlg::OnOK(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
DoOK();
return 0;
}
LRESULT FilesDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
EndDialog(wID);
return 0;
}
LRESULT FilesDlg::OnList(WORD wNotifyCode, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled)
{
switch(wNotifyCode)
{
case LBN_DBLCLK:
DoOK();
break;
default:
bHandled = FALSE;
}
return 0;
}
void FilesDlg::DoOK()
{
CWindow listBox(GetDlgItem(IDC_LIST));
int selIndex = listBox.SendMessage(LB_GETCURSEL);
if(selIndex != LB_ERR)
{
int len = listBox.SendMessage(LB_GETTEXTLEN, selIndex);
_ASSERT(len != LB_ERR);
TCHAR* selBuff = new TCHAR[len + 1];
listBox.SendMessage(LB_GETTEXT, selIndex, reinterpret_cast<LPARAM>(selBuff));
selected = selBuff;
delete [] selBuff;
}
EndDialog(IDOK);
}