|
Suresh H wrote: SendMessage(hwndRichEdit,EM_SETTEXTMODE, pBuffer,0);
Use ,
::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)pBuffer);
|
|
|
|
|
Hi Prasad,
Thank you very much for the response.
I tried with this code but no response list box double click event is not working.
<br />
case LBN_DBLCLK:<br />
{<br />
MessageBox(hwnd, "DB click!","DB click event", MB_ICONEXCLAMATION | MB_OK);<br />
}<br />
break;
and also I am not able to use CFile , this works in MFC but I am using win 32 api, what changes I have to make ???
<br />
CStdioFile file(FName, CFile::modeRead);<br />
DWORD dwSize = file.GetLength();<br />
char *pBuffer = new char[dwSize + 1];<br />
UINT uRead = file.Read(pBuffer, dwSize);<br />
pBuffer[uRead] = '\0';<br />
file.Close();<br />
|
|
|
|
|
Do you have LBS_NOTIFY on your listbox?
From the MSDN
Only a list box that has the LBS_NOTIFY style will send this message.
|
|
|
|
|
Hi WhiteSky,
Thanks for the responce.
How to check ????
|
|
|
|
|
Insert LBS_NOTIFY when create listbox
<br />
hList=CreateWindowW(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hWnd,(HMENU)IDC_SLIST,hInst,0); <br />
|
|
|
|
|
Hi whiteSky,
I did that in the
<br />
BOOL CALLBACK SDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(Message)<br />
{<br />
case WM_INITDIALOG:<br />
{<br />
<br />
HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);<br />
hwndListBox=CreateWindowW(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hwnd,(HMENU)IDC_SLIST,hwndListBox,0);<br />
<br />
i am getting error
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [8]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
|
|
|
|
|
I wanted to said insert LBS_NOTIFY when create your listbox
|
|
|
|
|
WhiteSky I am using wizard for creating dialog and dialog controls , I am not using any code to create the dialog.
|
|
|
|
|
He has created list box, shown in above post.
|
|
|
|
|
Suresh H wrote: hwndListBox=CreateWindowW(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hwnd,(HMENU)IDC_SLIST,hwndListBox,0);
Use CreateWindow instead of CreateWindowW . You are trying to use UNICODE version in Non -UNICODE application.
|
|
|
|
|
Hi prasad, again i am getting error..
HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);<br />
hwndListBox=CreateWindow(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hwnd,(HMENU)IDC_SLIST,hwndListBox,0);<br />
error :-
rror C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
|
|
|
|
|
One question HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);
what is it? before CreateWindow
|
|
|
|
|
WhiteSky I am creating a handle for the list box control {IDC_SLIST }
|
|
|
|
|
So do you have two listbox on your project?
|
|
|
|
|
Suresh H wrote: hwndListBox=CreateWindow(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hwnd,(HMENU)IDC_SLIST,hwndListBox,0);
Here, instead of handle you need to pass handle to instance. Pass instance that you will get through WinMain .
|
|
|
|
|
BOOL CALLBACK SDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
{
// HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);
hwnd=CreateWindow(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hwnd,(HMENU)IDC_SLIST,hwnd,0);
again error :-
error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
|
|
|
|
|
You have two hwnds on CreateWindow? wheres HINSTANCE
|
|
|
|
|
Prasad what I am trying to do is
List box contains a list of file names , when we select any item in the list box that file contains should get added to rich edit box.
So is there any way I can do that ??? without double click trouble ???
|
|
|
|
|
Suresh H wrote: List box contains a list of file names , when we select any item in the list box that file contains should get added to rich edit box.
You can handle list box double click in following way,
case WM_COMMAND:
switch(LOWORD(wParam))
case IDC_LIST1:
if (HIWORD(wParam) == LBN_DBLCLK)
{
}
break;
|
|
|
|
|
Hi Prasad,
Thank you very much list box double click event is work.
|
|
|
|
|
Welcome !
|
|
|
|
|
Hi Prasad,
One more last problem. After the double click event
I am trying to read the file contents and display the file connects in rich edit box for that I am trying this code but I am not getting any out put can u please check what changes I have to make.
<br />
const N = 1000;<br />
char cont[N];<br />
<br />
ifstream fin;<br />
fin.open(FName);<br />
while(fin)<br />
{<br />
fin.getline(cont,1000);<br />
::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)cont);<br />
}<br />
<br />
fin.close();<br />
i have tryed this code in mfc this is working properly but this code does not work in win 32 api,
<br />
CStdioFile file(str, CFile::modeRead);<br />
DWORD dwSize = file.GetLength();<br />
char *pBuffer = new char[dwSize + 1];<br />
UINT uRead = file.Read(pBuffer, dwSize);<br />
pBuffer[uRead] = '\0';<br />
file.Close();<br />
::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)pBuffer);<br />
delete [] pBuffer;
|
|
|
|
|
Suresh H wrote: const N = 1000;
char cont[N];
ifstream fin;
fin.open(FName);
while(fin)
{
fin.getline(cont,1000);
::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)cont);
}
fin.close();
Here, are you succesfully able to open the file ?
Initialize char array like this,
char cont[N] = { '\0'};
|
|
|
|
|
Hi Prasad,
I just did that changes but no output.
I traced the statements, it open the file and it reads till end of the file,
Since its in the loop the cont value keeps on changing ….and also nothing is added to the rich edit box.
Is there any way where I can open the file read the complete contents of the file and store it in one variable and pass that variable to get displayed in the rich edit ???
Files which I am trying to open are simple text files which contains lots of blank lines in the starting and end of the file .
|
|
|
|
|
I dont see any problem there, as long as array has some value.
|
|
|
|
|