|
I think its easily possible since there is FindText fucntion on CRichEditCtrl. Searching can be implemented in any direction using the CHARRANGE members of FINDTEXTEX Structure logically. But get conveyed from the programmer why he says so.
|
|
|
|
|
I don't think the use of CRichEditCtrl would have any bearing on it, but you would need to give more detail about the application and why the programmer believes it is not possible.
[edit]According to the MSDN documentation[^] you can set options in the Findtext() function to search forwards or backwards.[/edit]
I must get a clever new signature for 2011.
|
|
|
|
|
Hi. I want to be able to extract all the array associated in a listbox-items, but i am failing to find a thing to put in my for loop. the LB_GETCURSEL doesnt seem to be the correct one here... can someone point me the message I should be using?
HWND handle_List = GetDlgItem(hwnd, IDC_LIST_COMPARE);
count = SendMessage(handle_List, LB_GETCOUNT, 0, 0);
for (i =0; i<count; i++)
{
int index = SendMessage(handle_List, LB_GETCURSEL, 0, 0);
int data = SendMessage(handle_List, LB_GETITEMDATA, (WPARAM)index, 0);
MessageBox (hwnd, (char *)data, "The stored data is", MB_OK);
}
break;
this is the link for MSDN listbox thing. http://msdn.microsoft.com/en-us/library/bb775146%28v=vs.85%29.aspx[^]
can someone please point me which message i should be using? thank you very much.
btw i am sure the information/array is associated to the object in the listbox
|
|
|
|
|
for (i =0; i<count; i++)
{
int data = SendMessage(handle_List, LB_GETITEMDATA, (WPARAM)i, 0);
MessageBox (hwnd, (char *)data, "The stored data is", MB_OK);
}
|
|
|
|
|
You are using the wrong index value and the wrong message(s) see here[^]. Try the following
char textBuf[64];
for (i =0; i<count; i++)
{
SendMessage(handle_List, LB_GETTEXT , (WPARAM)i, (LPARAM)textBuf);
MessageBox (hwnd, textBuf, "The stored data is", MB_OK);
}
[edit]Also, you cannot cast an int to a char* and expect it to display a sensible value.[/edit]
I must get a clever new signature for 2011.
|
|
|
|
|
what is a char* ? ...its an integer pointer to a string, so it really depends on the other code whether it displays sensible data...
|
|
|
|
|
If you read my comment: I said that you cannot cast an int , which is a pure binary number, to a char* , which is a pointer to an array of characters, and expect to get sensible output.
[edit]Hence the OP's comment:
[/edit]
I must get a clever new signature for 2011.
|
|
|
|
|
that's not true... a char* is an integer... if the int holds the location of the initial character of a string (and the array is null terminated) it can be cast that way.
|
|
|
|
|
Is your real name SAKryukov?
I must get a clever new signature for 2011.
|
|
|
|
|
...i don't mean it in a mean way, more of a matter of fact sort of way...
|
|
|
|
|
Sorry LB_GETTEXT is not what I want. I want the data/string associated with the item. GETTEXT shows me the text for the string that is already displaying in the listbox.
|
|
|
|
|
OK just replace the LB_GETTEXT like this:
int data = SendMessage(handle_List, LB_GETITEMDATA, (WPARAM)i, 0);
However you do not say what data you are expecting to get returned from the ListBox . In your original sample you cast the returned value to a char* and then complain you always get "?" printed out, so I am assuming it is not a pointer to a character array. What value do you store in the itemdata when you create the ListBox ?
I must get a clever new signature for 2011.
|
|
|
|
|
i stored a TCHAR File_name in the listbox. here is the code for how i stored it.
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)File_name);
here is the check I have after I add the string in just to make sure.
HWND hList = GetDlgItem(hwnd, IDC_LIST_COMPARE);
int data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
MessageBox (hwnd, (char *)data, "The stored data for the newly selected item is...", MB_OK);
here the message box displays the string fine. I am pretty much using the exact same code as u have suggested, but i just cannot get it to work in the for loop for some stupid reason -_-;;
|
|
|
|
|
A couple of suggestions:
In your data retrieval loop your code might be a bit clearer if you write it as:
char* string = (char*)SendMessage(hList, LB_GETITEMDATA, (WPARAM)i, 0);
Also check that the returned pointer string still points to a valid address. When you add these data items to your list box, if they are pointers to local memory you need to ensure that they are not destroyed. Your code above does not make it clear exactly how they are created, and whether they are permanent.
I must get a clever new signature for 2011.
|
|
|
|
|
LOL still doesnt work. this problem is driving me insane... I need to link the filename with the item in the listbox >.<. why does it work on every single example i see on the web!
here is the full code. Please tell me if I made any mistake
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case ID_CMP_LOADFILE:
{
OPENFILENAME ofn;
TCHAR File_name[MAX_PATH];
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
sprintf(File_name, "1");
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)File_name);
HWND hList = GetDlgItem(hwnd, IDC_LIST_COMPARE);
int data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
MessageBox (hwnd, (char *)data, "The stored data for the newly selected item is...", MB_OK);
fclose(file_opened);
}
break;
}
case ID_CMP_COMPARE:
{
int count;
int i;
HWND handle_list = GetDlgItem(hwnd, IDC_LIST_COMPARE);
count = SendMessage(handle_list, LB_GETCOUNT, 0, 0);
for (i =0; i<count; i++)
{
TCHAR* data = SendMessage(handle_list, LB_GETITEMDATA, (WPARAM)i, 0);
MessageBox (hwnd, data, "The stored data for the newly selected item is...", MB_OK);
}
break;
}
thank you all soo much.. i really need to crack this..
|
|
|
|
|
As I said before, you need to be sure that your data fields are pointing at static memory blocks. You have the following line(s) in your code:
TCHAR File_name[MAX_PATH];
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
sprintf(File_name, "1");
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)File_name);
However, as soon as you leave this function the variable File_name will be destroyed (because it is on the stack) and your pointer is no longer valid.
You need to do something like:
PTSTR pFile_name;
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
pFile_name = new TCHAR[the length of the filename + 1];
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)pFile_name);
now when you leave this function your filename memory buffer will not be destroyed. You should also remember to delete[] all these memory blocks when you destroy your listbox.
I must get a clever new signature for 2011.
|
|
|
|
|
thank you soo much! I actually got it working with a different slightway, because this way everytime I load the filename it gets re-written, so I have to point the pFile_name to a 2D array. And I dnt know whats new, I just used malloc(), but i think it should be the same.
But yeah thank you soo much!
|
|
|
|
|
Had a try, no effect.
I am very sure there are strings associated with it though, because I add a messagebox check when i add the string in
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)File_name);
HWND hList = GetDlgItem(hwnd, IDC_LIST_COMPARE);
int data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
MessageBox (hwnd, (char *)data, "The stored data for the newly selected item is...", MB_OK);
here the string associated displayed fine. Since the dialogue box is zero-based index your code should work fine, but i have no idea why it is now working....
|
|
|
|
|
Hi all,
I have a problem with my app that I am writing (VC6), where when I add a dialog control and then double click to add a member function, VC does not add the function, and I end up with every Generated message map functions doubled up, which of course gives the "member function already defined or declared" compile error.
Every time I repeat this, the functions are added again. Problem also happens even if I double click to add the member function, but immediatly click cancel.
Any suggestions?
Thanks in advance!
Mike
|
|
|
|
|
VC6 was some time ago, but do you have the correct "insertion point comments" in your message map?
|
|
|
|
|
Hi Niklas - thanks for helping.
This is what my generated message map looks like after trying to add a member:
// Generated message map functions
//{{AFX_MSG(CDanuDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
virtual void OnOK();
afx_msg void OnButton1();
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
virtual void OnOK();
afx_msg void OnButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
its slightly different from what you suggested, as it has //{{AFX_MSG(CDanuDlg) - I think this is right however.
Cheers
Mike
|
|
|
|
|
The ones I suggested should be inside your message map, between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP in the cpp-file.
One idea could be to generate a new MFC dialog class, and compare all those generated comments to the ones in your dialog.
|
|
|
|
|
Hi Niklas
I have got to the bottom of this now (after a spending the day trying to work out where it was going wrong)!
In my message map, I had something like this declared:
ON_COMMAND_RANGE(IDC_BUTTON_1, IDC_BUTTON_4, OnMyFunction)
OnMyFunction had been declared as a normal function (void OnMyFunction()). As soon as I moved it to the right message map (afx_msg void OnMyFunction()) problem was solved!
AAAAAGGGGHHHH what a waste of time!
Thanks for your input though!
Mike
|
|
|
|
|
In Process Explorer software
have function view handles of process
i don't know how to get handles same that function
someone give me idea>?
thanks so much
sorry if my english is not good
|
|
|
|
|
Maybe check this[^] as a starting point, it has source code for you to examine.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|