SendMessage???
-
void CMyDlg::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO *plvDispInfo = (LV_DISPINFO *)pNMHDR; LV_ITEM *plvItem = &plvDispInfo->item; **AfxMessageBox("Hello");** *pResult = FALSE; } void CMyDlg::OnButton1() { //??????? //SendMessage() //SendDlgItemMessage() //Send ????????? }
I want to run all code lines in CMyDlg::OnEndlabeleditList() when I click to Button1 such as to display a messagebox "Hello" I dont know how to do it help me thanks:rose::rose: -
void CMyDlg::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO *plvDispInfo = (LV_DISPINFO *)pNMHDR; LV_ITEM *plvItem = &plvDispInfo->item; **AfxMessageBox("Hello");** *pResult = FALSE; } void CMyDlg::OnButton1() { //??????? //SendMessage() //SendDlgItemMessage() //Send ????????? }
I want to run all code lines in CMyDlg::OnEndlabeleditList() when I click to Button1 such as to display a messagebox "Hello" I dont know how to do it help me thanks:rose::rose:Hi, In the message map you have to have something like this: BEGIN_MESSAGE_MAP(...) ... ON_MESSAGE(999,OnEndlabeledList) ... END_MESSAGE_MAP() And in your OnButton1 function you have to SendMessage(999); ----- We are what we repeatedly do. Excellence, then, is not an act, but a habit.
-
void CMyDlg::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO *plvDispInfo = (LV_DISPINFO *)pNMHDR; LV_ITEM *plvItem = &plvDispInfo->item; **AfxMessageBox("Hello");** *pResult = FALSE; } void CMyDlg::OnButton1() { //??????? //SendMessage() //SendDlgItemMessage() //Send ????????? }
I want to run all code lines in CMyDlg::OnEndlabeleditList() when I click to Button1 such as to display a messagebox "Hello" I dont know how to do it help me thanks:rose::rose:2 ways to do this. Easy way: you can break out the relevant code from the OnEndlabeleditList handler into its own public function, and simply call that, e.g.;
void CMyDlg::OnButton1() { CallSomeFunction(); }
Or you can, as you were trying to do, use SendMessage. You will need the window handler of the listbox window, or a listbox class, and call SendMessage on it and send it the appropraite message. If you look at the list box (or is it a list control??) documentation in MSDN you can find the right message. It'll look like one of these:HWND hListWindow = ::GetDlgItem(ITEM_ID_FROM_RC_FILE); ::SendMessage(hListWindow, message_id, wparam, lparam); // Or if you have a CWnd: theListCtrl.SendMessage(message_id, wparam, lparam);
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein -
Hi, In the message map you have to have something like this: BEGIN_MESSAGE_MAP(...) ... ON_MESSAGE(999,OnEndlabeledList) ... END_MESSAGE_MAP() And in your OnButton1 function you have to SendMessage(999); ----- We are what we repeatedly do. Excellence, then, is not an act, but a habit.
Florin Ochiana wrote:
SendMessage(999)
:eek: X| At least try something like#define MAGIC_MESSAGE WM_APP+99
(or some other number)
ON_MESSAGE(MAGIC_MESSAGE,OnEndlabeledList)
...
SendMessage(MAGIC_MESSAGE);MSDN states:
Message numbers in the first range (0 through WM_USER – 1)
are defined by the system. Values in this range that are not explicitly
defined are reserved for future use by the system.WM_USER is defined to be 0x400, so that your value of 0x3E7 (deimal 999) would send some message you did never intend to send to your window.
Who is 'General Failure'? And why is he reading my harddisk?!?