Suresh.hc
February 16th, 2007, 05:50 AM
Hello all,
I have List Box and rich edit box in my Dialog IDC_SLIST & IDC_FILECONT
List Box contains the text file names , When the user double click on the list box that file content should be displayed in the rich edit box.
Can u please tell me what all the changes I have to make and how to do the double click event in win 32 Api application ??
case WM_COMMAND:
switch(LOWORD(wParam))
{
case LBN_DBLCLK:
{
HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);
int iCurSel =::SendMessage(hwndListBox,LB_GETCURSEL,0,0);
TCHAR FName[30];
SendMessage(hwndListBox,LB_GETTEXT,(WPARAM)iCurSel,(LPARAM)FName);
CStdioFile file(FName, CFile::modeRead);
DWORD dwSize = file.GetLength();
char *pBuffer = new char[dwSize + 1];
UINT uRead = file.Read(pBuffer, dwSize);
pBuffer[uRead] = '\0';
file.Close();
HWND hwndRichEdit = GetDlgItem(hwnd, IDC_FILECONT);
::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)pBuffer);
delete [] pBuffer;
}
-----------
this code works in MFC but its not working in win 32 api, i am not able to use CFile what has to be done ??
CStdioFile file(FName, CFile::modeRead);
DWORD dwSize = file.GetLength();
char *pBuffer = new char[dwSize + 1];
UINT uRead = file.Read(pBuffer, dwSize);
pBuffer[uRead] = '\0';
file.Close();
Thanking you,
Suresh HC
I have List Box and rich edit box in my Dialog IDC_SLIST & IDC_FILECONT
List Box contains the text file names , When the user double click on the list box that file content should be displayed in the rich edit box.
Can u please tell me what all the changes I have to make and how to do the double click event in win 32 Api application ??
case WM_COMMAND:
switch(LOWORD(wParam))
{
case LBN_DBLCLK:
{
HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);
int iCurSel =::SendMessage(hwndListBox,LB_GETCURSEL,0,0);
TCHAR FName[30];
SendMessage(hwndListBox,LB_GETTEXT,(WPARAM)iCurSel,(LPARAM)FName);
CStdioFile file(FName, CFile::modeRead);
DWORD dwSize = file.GetLength();
char *pBuffer = new char[dwSize + 1];
UINT uRead = file.Read(pBuffer, dwSize);
pBuffer[uRead] = '\0';
file.Close();
HWND hwndRichEdit = GetDlgItem(hwnd, IDC_FILECONT);
::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)pBuffer);
delete [] pBuffer;
}
-----------
this code works in MFC but its not working in win 32 api, i am not able to use CFile what has to be done ??
CStdioFile file(FName, CFile::modeRead);
DWORD dwSize = file.GetLength();
char *pBuffer = new char[dwSize + 1];
UINT uRead = file.Read(pBuffer, dwSize);
pBuffer[uRead] = '\0';
file.Close();
Thanking you,
Suresh HC