Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SendMessage???

SendMessage???

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _skidrow_vn_
    wrote on last edited by
    #1

    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:

    F N 2 Replies Last reply
    0
    • _ _skidrow_vn_

      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:

      F Offline
      F Offline
      Florin Ochiana
      wrote on last edited by
      #2

      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.

      J 1 Reply Last reply
      0
      • _ _skidrow_vn_

        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:

        N Offline
        N Offline
        Navin
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • F Florin Ochiana

          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.

          J Offline
          J Offline
          jhwurmbach
          wrote on last edited by
          #4

          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?!?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups