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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to "SendMessage" to a listbox in a dialog class?

How to "SendMessage" to a listbox in a dialog class?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++toolstutorial
6 Posts 3 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.
  • O Offline
    O Offline
    oRion
    wrote on last edited by
    #1

    I am currently writing a program which is ported from C++ for DOS. I have a routine which handles the output messages to the screen in DOS, but now I am trying to output it to a ListBox in a Dialog box. Here a fragment of the code i have written.. #include "stdafx.h" void utility::message() { SendMessage(0,WM_MYCALL,0,0); } WM_MYCALL is a handler I defined in a dialog class. Apparently, when I tried this command, nothing really happen. My program is a SDI program. Somehow, WM_MYCALL is not process at all by the dialog class? Why does this happen? Is there something I missed out?:confused:

    M 1 Reply Last reply
    0
    • O oRion

      I am currently writing a program which is ported from C++ for DOS. I have a routine which handles the output messages to the screen in DOS, but now I am trying to output it to a ListBox in a Dialog box. Here a fragment of the code i have written.. #include "stdafx.h" void utility::message() { SendMessage(0,WM_MYCALL,0,0); } WM_MYCALL is a handler I defined in a dialog class. Apparently, when I tried this command, nothing really happen. My program is a SDI program. Somehow, WM_MYCALL is not process at all by the dialog class? Why does this happen? Is there something I missed out?:confused:

      M Offline
      M Offline
      Mike Nordell
      wrote on last edited by
      #2

      You must tell it where to send the message. Somehow I dubt you have a dialog box with a HWND of zero. :-)

      O 1 Reply Last reply
      0
      • M Mike Nordell

        You must tell it where to send the message. Somehow I dubt you have a dialog box with a HWND of zero. :-)

        O Offline
        O Offline
        oRion
        wrote on last edited by
        #3

        Yup, that's right. But I am not sure how to get the handle for my dialog box. Do you have any suggestion? So right now I am sending to the main window. :wtf:

        P M 2 Replies Last reply
        0
        • O oRion

          Yup, that's right. But I am not sure how to get the handle for my dialog box. Do you have any suggestion? So right now I am sending to the main window. :wtf:

          P Offline
          P Offline
          Pavel Klocek
          wrote on last edited by
          #4

          mydlg.GetSafeHwnd() Pavel Sonork 100.15206

          1 Reply Last reply
          0
          • O oRion

            Yup, that's right. But I am not sure how to get the handle for my dialog box. Do you have any suggestion? So right now I am sending to the main window. :wtf:

            M Offline
            M Offline
            Mike Nordell
            wrote on last edited by
            #5

            If you have a dialog, surely you must know its HWND? For every message your dialogs message-pump handles, you get a HWND as part of the MSG (so if you handle WM_INITDIALOG, the WPARAM is the HWND of the dialog).

            O 1 Reply Last reply
            0
            • M Mike Nordell

              If you have a dialog, surely you must know its HWND? For every message your dialogs message-pump handles, you get a HWND as part of the MSG (so if you handle WM_INITDIALOG, the WPARAM is the HWND of the dialog).

              O Offline
              O Offline
              oRion
              wrote on last edited by
              #6

              Thanks for the information. I have tried to use GetSafeHwnd() instead, and pass it to the a global variable type of HWND. It works for now. :)

              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